GNU bug report logs -
#46374
28.0.50; Ask me to save buffers only if they are under callers dir
Previous Next
Reported by: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sun, 7 Feb 2021 22:33:01 UTC
Severity: wishlist
Tags: fixed
Merged with 50380
Fixed in version 28.0.60
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>>>> Why not simply add a new option to the existing variable
>>>> save-some-buffers-default-predicate? For example:
>>>>
>>>> (defcustom save-some-buffers-default-predicate nil
>>>> "Default predicate for `save-some-buffers'."
>>>> :group 'auto-save
>>>> ;; FIXME nil should not be a valid option, let alone the default,
>>>> ;; eg so that add-function can be used.
>>>> :type '(choice (const :tag "Default" nil)
>>>> (const :tag "Subdirs of default directory" default-directory)
>>>> (const :tag "Project root" project-root)
>>>> function)
>>>
>>> Indeed, this was my initial implemention.
>>> Then I moved to the one I shared here; I found my second version
>>> superior for the following reason:
>>>
>>> 1. Users can restrict the buffer default directory AND still pass a
>>> predicate to filter by any other thing they wish;
>>> i.e. you don't need to chose either one of the other.
>>>
>>> 2. I find it cleaner having it in a separated option.
>>
>> I'm not sure if there is a need for adding
>> another dimension with another option.
>
> This is explained in my point 1. above.
> I might want to restrict to the caller subdir and still filter with
> a function. You cannot get both things just with one option.
>
> For my normal worflow, this is a very important addition and I am looking
> forward to see it added in master soon.
Please consider the consequences of backward-incompatibility
of adding such a separate option. For example, in the org package:
org-mobile-push:
(save-some-buffers nil
(lambda () (memq (current-buffer) agenda-buffers)))
When a user customizes a new option to restrict saving of buffers to
the subdirectories only, this means it will skip saving agenda-buffers
since most of them usually are located outside of the current directory.
This change would have a drastic effect for external packages where
a new option can't be forced to be bound to nil.
More examples:
org-save-all-org-buffers:
(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
etc.
This means reusing the existing save-some-buffers-default-predicate
would be still preferable that guarantees backward-compatibility.
When it's customized to a predicate to filter out non-current subdirs,
then such call '(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))'
still overrides the customized value. This is the right thing to do.
>> But if yes, then still shouldn't a new option
>> provide a wider choice of restricting predicates
>> like above?
>
> Yeah, we could made wider the new option as you've suggested:
>>>> (const :tag "Subdirs of default directory" default-directory)
>>>> (const :tag "Project root" project-root)
>
> Since Stefan mentioned `project-root` is not ready and I am not familiar
> with it, I suggest we add the option as it is, possibly with a modified
> name that fit well our future intention and a TODO comment.
> Then, me or someone else, can update the option when `project-root`
> become mature.
>
> Agreed?
Then the option could be named 'project-root-or-subdirs',
so when a command is called outside a project, it will
fall back to subdirs.
This bug report was last modified 3 years and 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.