help-gnu-emacs
[Top][All Lists]
Advanced

[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: Sun, 20 Mar 2022 09:08:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

hw wrote:

> (defun my-perltidy-replace (_)
>   "This function replaces the contents of the current buffer with
> the output of perltidy, and makes a backup of the current buffer.
>
> Before and after modifications to contents of buffers are being
> made, all buffers that need to be auto-saved are being
> auto-saved.
>
> The major-mode of the buffer containing the backup is set to
> 'cperl-mode'."

Emacs thinks

  the second line should not have indentation ...
  
  the first line is not a complete sentence ....
  
  and probably "replaces" should be imperative "replace"!

>       (linum-mode -1)

This is the only one needed.

>       (auto-save-mode nil)

Yuk, not needed ...

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.

>     (linum-mode 1)

Not as ugly! But as equally unnecessary still pretty ugl-
I mean unnecessary.

> (defun my-transient-copy (_)
>   "This function makes a copy of the current buffer to a new
> buffer.  The new buffer does not visit a file.  Its name is based
> on the name of the current buffer.
>
> The 'auto-save-mode' is enabled for the new buffer, and all
> buffers that need to be auto-saved are being auto-saved right
> away, once before the copy is created and once after."

Emacs thinks

Second line should not have indentation

First line is not a complete sentence

Probably "makes" should be imperative "make"

>   (interactive "P")

Interesting, does that work and what does it do?!

>   (do-auto-save)
>   (let ((transient_buffer (generate-new-buffer-name (concat 
> "transient-copy-of-" (buffer-name)))))
>     (copy-to-buffer transient_buffer (point-min) (point-max))

Here is another example - when the last two args a and b and

  (<= (point-min) a b (point-max))

then both formal parameters can be made optional if we had
argument a defaulting to (point-min) and argument b defaulting
to (point-max), right?

>     (with-current-buffer transient_buffer (auto-save-mode
>     nil))

Same.

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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