[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to force auto-save of buffers not visiting files, right now?

From: Emanuel Berg
Subject: Re: how to force auto-save of buffers not visiting files, right now?
Date: Tue, 22 Mar 2022 20:50:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

hw wrote:

>> Emacs thinks
>>   the second line should not have indentation ...
> Maybe it was altered during transfer? It isn't indented.
>>   the first line is not a complete sentence ....
> To me, it's a complete sentence. We'd have to ask some
> people who are native speakers of English.
>>   and probably "replaces" should be imperative "replace"!
> Huh? The function /does/ replace the contents. It "shalln't"
> replace them, if there is even such a word.

Well, it's what Emacs thinks anyway. Run these commands to
find out for yourself ... Doing this before you post code here
is appreciated, as is byte-compiling (and fixing the
errors/warnings) since that is ... beneficial.

;;; -*- lexical-binding: t -*-
;; this file:

(require 'checkdoc)

(setq checkdoc-arguments-in-order-flag       t)
(setq checkdoc-permit-comma-termination-flag t)

(defun check-package-style ()
  (let ((msg "Style check..."))
    (message msg)
    (checkdoc-current-buffer t) ; TAKE-NOTES
    (message "%sdone" msg) ))
(defalias 'check-style #'check-package-style)

>>> (linum-mode -1)
>> This is the only one needed.
> The wayland version of emacs screws up the display of the
> line numbers when you have two buffers displayed in the same
> frame besides each other, at least when you're using sway.
> Disabling the mode and re-enabling it is a workaround.

I mean the hard-coded disable case is the only one where you
need an argument to the minor mode function ...

>>>       (auto-save-mode nil)
>> Yuk, not needed ...
> That depends on whether you have auto-save-mode enabled by
> default or not ... In a function, you can either check
> whether auto-save-mode is already enabled or not and enable
> it if it isn't, or just enable it. In any case, it needs to
> be enabled for the function to do what I want it to do, so
> enable it.

(auto-save-mode) will also enable.

>> BTW final args that could be nil (nil is in the function
>> range) could always be optional and default to nil, right?
>> Here tho it is ugly by all means but also unnecessary since
>> it _is_ an optional argument, so all good.
> What do you mean? Not all arguments default to nil, may they
> be optional or not.

If the last argument can default to nil and that is sensible
and done, then it can be made optional as well with nothing
lost and with the gains on cleaner code and less typing.

>>> (linum-mode 1)
>> Not as ugly! But as equally unnecessary still pretty ugl-
>> I mean unnecessary.
> When programming, I follow the principle that it's better to
> be more explicit

If you share such code people will get confused and wonder if
it means something else as the other way around is the
conventional/prefered method.

>>> (interactive "P")
>> Interesting, does that work and what does it do?!
> The function works, yes. Its description tells you what
> it does.

What does (interactive "P") in the context of an
anonymous/unemployed argument?

> With (copy-to-buffer buffer), you copy the region when
> omitting the arguments. Maybe it's prettier, but it isn't
> what I wanted. Maybe that's why the description tells you
> not to omit the arguments.

To use the region on interactive use is called a DWIM function
("do what I mean") and in such cases the last two arguments,
BEG and END, could be optional with (point-min) and
(point-max) as defaults. See:

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]