emacs-devel
[Top][All Lists]
Advanced

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

Re: Tweaking save-some-buffers-action-alist


From: Sergey Organov
Subject: Re: Tweaking save-some-buffers-action-alist
Date: Fri, 18 Jun 2021 22:16:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Daniel Martín <mardani29@yahoo.es> writes:

> Sergey Organov <sorganov@gmail.com> writes:
>
>>
>> #+BEGIN_SRC emacs-lisp
>> (nconc
>>  save-some-buffers-action-alist
>>  '((?\C-\M-g
>>     (lambda (buf)
>>       (with-current-buffer buf
>>         (revert-buffer)))
>>     "revert this buffer")))
>> #+END_SRC
>>
>> I'm concerned as I use `nconc` that sounds unsafe, and then original
>> definition has some ",(" and ",(purecopy" tricks that I dunno if I need
>> to follow, and if so, how?
>
> Purecopy is a no-op except while Emacs is being built and dumped, so
> user customizations can omit it.  Evaluate (info "(elisp) Pure Storage")
> in Emacs to read more about this.
>
> Backquoting the alist will instruct the Elisp interpreter to not
> evaluate KEY, but evaluate the lambda FUNC.  Evaluating lambda
> expressions is generally a good idea because that enables
> byte-compilation and all its benefits: Faster code, less memory usage,
> some static checks, specially under lexical scope, etc.

Thanks for clarification and pointers!

Is `nconc` safe here, or should I `copy-seq` the original and modify
that instead?

>
>>
>> And to finally justify posting to 'emacs-devel', does it make sense to
>> add this capability to the default value of
>> `save-some-buffers-action-alist`?
>>
>
> I think reverting a buffer when compiling is not a very common need.

Surprisingly, it /is/ rather common when one has a lot of (often
unrelated to compilation) buffers, and finding the buffer in question
after compilation just to revert it is boring and is often forgotten
until the next compilation. Annoying.

> More importantly, the prompt already has a lot of options and adding one
> more will make it more complex and difficult to understand.

Well, yes, but I believe that the "Discard changes" option is the second
or third by usefulness among the rest supported: "Save Changes, Discard
Changes, Save All". To me it's "Ignore the change and continue" that
seems to be the least useful one.

I just want to have a way to finish entire prompt series and have no
modified buffers at the end. Doesn't seem to be too much to ask for.

As a side note, if there are too many options already, 'C-r' could be
removed and the buffer in question be shown automatically instead.

> At some point you have to draw the line between what should be a
> customization and what should be included in Emacs

Yep. I just think that the line in this particular case has been chosen
long ago, when `enable-recursive-minibuffers` was enabled by default, or
was unheard of, and now, when it is disabled by default, the line should
be drawn at a different level, making it possible again to conveniently
revert the buffer.

> and I think your suggestion can perfectly be a personal customization.

Probably it could, but right now it isn't. I don't think we can expect a
novice user to be able to tweak it like I did above, no way. Do you
in fact suggest to support this through `customize` or what?

The current state is that to the actual question I got from a novice
user: "How do I discard changes to the buffer when I run `compile` and
Emacs asks me if I want to save some?" I have to either give the "No
way" answer, or tweak Emacs for them. Sad.

BTW, if there were a way to cancel the `save-some-buffers` after 'C-r'
yet leave the modified buffer current, it'd solve the issue as well,
though in a different, less convenient way.

Thanks,
-- Sergey Organov




reply via email to

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