emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer ba


From: Philipp Stephani
Subject: Re: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis.
Date: Sun, 5 Apr 2020 17:51:18 +0200

Am So., 5. Apr. 2020 um 16:19 Uhr schrieb Stefan Monnier
<address@hidden>:
>
> >> diff --git a/lisp/files.el b/lisp/files.el
> >> index 55a0958f54..5132aa456a 100644
> >> --- a/lisp/files.el
> >> +++ b/lisp/files.el
> >> @@ -441,6 +441,7 @@ auto-save-visited-mode
> >>             #'save-some-buffers :no-prompt
> >>             (lambda ()
> >>               (and buffer-file-name
> >> +                  auto-save-visited-mode
> >>                    (not (and buffer-auto-save-file-name
> >>                              auto-save-visited-file-name))))))))
> >
> > Is this really OK?
>
> Depends what you mean by "this".  The above patch is definitely
> OK, yes.  It's actually "standard operation procedure" for a minor mode
> to double check its minor mode variable in timers and hooks ;-)
>
> > All minor mode variables, including auto-save-visited-mode, by default
> > get the "Setting this variable directly does not take effect"
> > documentation string, because we want to use minor mode variables only
> > for checking a mode's state and always want users to call the
> > mode function.
>
> Indeed the above implies suggestions to do:
>
>     (add-hook 'foo-mode-hook
>               (lambda () (setq-local auto-save-visited-mode nil)))
>
> which doesn't go through such functions and is hence arguably "bad
> style".  Especially it will likely encourage the use of plain `setq` on
> the variable.
>
> This part of what I meant by "...but lacks the rest of the code".
> The rest would be something like
>
>     (define-minor-mode auto-save-visited-local-mode ...)
>
> which would do the `setq-local` internally and might take inspiration
> from `electric-indent-local-mode`.
>


Wouldn't such a minor mode be confusing, because you'd have to enable
both the global and the local minor mode for the functionality to
work?



reply via email to

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