* [PATCH] Reimplement auto-saving to visited files [not found] <CAArVCkQSt+GtxxWBOkgUVzZeWKPEGab5hB7xXyXpPm5rMQ0zvA@mail.gmail.com> @ 2017-04-29 18:49 ` Philipp Stephani 2017-04-29 19:20 ` bug#25478: " Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Philipp Stephani @ 2017-04-29 18:49 UTC (permalink / raw) To: eliz, emacs-devel, 25478, rgm; +Cc: Philipp Stephani This reacts to confusing behavior of 'auto-save-visited-file-name', cf. Bug#25478. * lisp/files.el (auto-save-visited-interval): New customization option. (auto-save-visited-mode): New global minor mode. (auto-save-visited-file-name): Make obsolete. (auto-save--timer): New internal helper variable. * doc/emacs/files.texi (Auto Save Files): Document 'auto-save-visited-mode' instead of obsolete 'auto-save-visited-file-name'. (Auto Save Control): Document customization option 'auto-save-visited-interval'. --- doc/emacs/files.texi | 29 ++++++++++++++++++++++------- etc/NEWS | 6 ++++++ lisp/files.el | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index ed17f66ca2..55eda00d0c 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1040,14 +1040,23 @@ Auto Save Files this happens, save the buffer with @kbd{C-x C-s}, or use @kbd{C-u 1 M-x auto-save-mode}. -@vindex auto-save-visited-file-name +@vindex auto-save-visited-mode If you want auto-saving to be done in the visited file rather than -in a separate auto-save file, set the variable -@code{auto-save-visited-file-name} to a non-@code{nil} value. In this -mode, auto-saving is very similar to explicit saving. However, -differences still exist, in particular for modes which modify the -buffer-saving process in non-trivial ways via various hooks -(@pxref{Saving Buffers,,, elisp, The Emacs Lisp Reference Manual}). +in a separate auto-save file, enable the global minor mode +@code{auto-save-visited-mode}. In this mode, auto-saving is identical +to explicit saving. Note that this mode is orthogonal to the +@code{auto-save} mode described above; you can enable both at the same +time. However, if @code{auto-save} mode is active in some buffer and +the obsolete @code{auto-save-visited-file-name} variable is set to a +non-@code{nil} value, that buffer won't be affected by +@code{auto-save-visited-mode}. + + You can use the variable @code{auto-save-visited-interval} to +customize the interval between auto-save operations in +@code{auto-save-visited-mode}; by default it's five seconds. +@code{auto-save-interval} and @code{auto-save-timeout} have no effect +on @code{auto-save-visited-mode}. See @xref{Auto Save Control} for +details on these variables. @vindex delete-auto-save-files A buffer's auto-save file is deleted when you save the buffer in its @@ -1091,6 +1100,12 @@ Auto Save Control a while; second, it may avoid some auto-saving while you are actually typing. +@vindex auto-save-visited-interval + When @code{auto-save-visited-mode} is enabled, Emacs will auto-save +file-visiting buffers after five seconds of idle time. You can +customize the variable @code{auto-save-visited-interval} to change the +idle time interval. + Emacs also does auto-saving whenever it gets a fatal error. This includes killing the Emacs job with a shell command such as @samp{kill %emacs}, or disconnecting a phone line or network connection. diff --git a/etc/NEWS b/etc/NEWS index 9d4c72d6dc..173c4e466b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -383,6 +383,12 @@ Strings such as ΌΣΟΣ are now correctly converted to Όσος when capitalized instead of incorrect Όσοσ (compare lowercase sigma at the end of the word). +** Emacs can now auto-save buffers to visited files in a more robust +manner via the new mode 'auto-save-visited-mode'. Unlike +'auto-save-visited-file-name', this mode uses the normal saving +procedure and therefore obeys saving hooks. +'auto-save-visited-file-name' is now obsolete. + \f * Changes in Specialized Modes and Packages in Emacs 26.1 diff --git a/lisp/files.el b/lisp/files.el index 6848818cad..d3958b5643 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -393,6 +393,46 @@ auto-save-file-name-transforms :initialize 'custom-initialize-delay :version "21.1") +(defvar auto-save--timer nil "Timer for `auto-save-visited-mode'.") + +(defcustom auto-save-visited-interval 5 + "Interval in seconds for `auto-save-visited-mode'. +If `auto-save-visited-mode' is enabled, Emacs will save all +buffers visiting a file to the visited file after it has been +idle for `auto-save-visited-interval' seconds." + :group 'auto-save + :type 'number + :version "26.1" + :set (lambda (symbol value) + (set-default symbol value) + (when auto-save--timer + (timer-set-idle-time auto-save--timer value :repeat)))) + +(define-minor-mode auto-save-visited-mode + "Toggle automatic saving to file-visiting buffers on or off. +With a prefix argument ARG, enable regular saving of all buffers +visiting a file if ARG is positive, and disable it otherwise. +Unlike `auto-save-mode', this mode will auto-save buffer contents +to the visited files directly and will also run all save-related +hooks. See Info node `Saving' for details of the save process. + +If called from Lisp, enable the mode if ARG is omitted or nil, +and toggle it if ARG is `toggle'." + :group 'auto-save + :global t + (when auto-save--timer (kill-timer auto-save--timer)) + (setq auto-save--timer + (when auto-save-visited-mode + (run-with-idle-timer + auto-save-visited-interval :repeat + #'save-some-buffers :no-prompt + (lambda () + (not (and buffer-auto-save-file-name + auto-save-visited-file-name))))))) + +(make-obsolete-variable 'auto-save-visited-file-name 'auto-save-visited-mode + "Emacs 26.1") + (defcustom save-abbrevs t "Non-nil means save word abbrevs too when files are saved. If `silently', don't ask the user before saving." -- 2.12.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#25478: [PATCH] Reimplement auto-saving to visited files 2017-04-29 18:49 ` [PATCH] Reimplement auto-saving to visited files Philipp Stephani @ 2017-04-29 19:20 ` Eli Zaretskii 2017-04-29 19:31 ` Philipp Stephani 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2017-04-29 19:20 UTC (permalink / raw) To: Philipp Stephani; +Cc: phst, emacs-devel, 25478 > From: Philipp Stephani <p.stephani2@gmail.com> > Cc: Philipp Stephani <phst@google.com> > Date: Sat, 29 Apr 2017 20:49:09 +0200 > > +on @code{auto-save-visited-mode}. See @xref{Auto Save Control} for @xref itself produces "See", so the "See" before it is unnecessary. Other than that, I think this can go in. Thanks for working on this. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-29 19:20 ` bug#25478: " Eli Zaretskii @ 2017-04-29 19:31 ` Philipp Stephani 2017-04-29 22:19 ` Peter Vasil 0 siblings, 1 reply; 8+ messages in thread From: Philipp Stephani @ 2017-04-29 19:31 UTC (permalink / raw) To: Eli Zaretskii; +Cc: phst, rgm, 25478, emacs-devel [-- Attachment #1: Type: text/plain, Size: 481 bytes --] Eli Zaretskii <eliz@gnu.org> schrieb am Sa., 29. Apr. 2017 um 21:21 Uhr: > > From: Philipp Stephani <p.stephani2@gmail.com> > > Cc: Philipp Stephani <phst@google.com> > > Date: Sat, 29 Apr 2017 20:49:09 +0200 > > > > +on @code{auto-save-visited-mode}. See @xref{Auto Save Control} for > > @xref itself produces "See", so the "See" before it is unnecessary. > > Other than that, I think this can go in. Thanks for working on this. > Thanks, pushed as 4db844a453 and 89159e78bb. [-- Attachment #2: Type: text/html, Size: 958 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-29 19:31 ` Philipp Stephani @ 2017-04-29 22:19 ` Peter Vasil 2017-04-30 2:41 ` Kaushal Modi ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Peter Vasil @ 2017-04-29 22:19 UTC (permalink / raw) To: emacs-devel Hello, I get an error when compiling Emacs on Fedora 25 with files.el Loading /home/peter/src/emacs/lisp/files.el (source)... Symbol’s function definition is void: define-minor-mode Makefile:735: recipe for target 'bootstrap-emacs' failed make[2]: *** [bootstrap-emacs] Error 255 make[2]: Leaving directory '/home/peter/src/emacs/src' Makefile:416: recipe for target 'src' failed make[1]: *** [src] Error 2 Regards, Peter On 04/29/2017 09:31 PM, Philipp Stephani wrote: > > > Eli Zaretskii <eliz@gnu.org <mailto:eliz@gnu.org>> schrieb am Sa., 29. > Apr. 2017 um 21:21 Uhr: > > > From: Philipp Stephani <p.stephani2@gmail.com > <mailto:p.stephani2@gmail.com>> > > Cc: Philipp Stephani <phst@google.com <mailto:phst@google.com>> > > Date: Sat, 29 Apr 2017 20:49:09 +0200 > > > > +on @code{auto-save-visited-mode}. See @xref{Auto Save Control} for > > @xref itself produces "See", so the "See" before it is unnecessary. > > Other than that, I think this can go in. Thanks for working on this. > > > Thanks, pushed as 4db844a453 and 89159e78bb. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-29 22:19 ` Peter Vasil @ 2017-04-30 2:41 ` Kaushal Modi 2017-04-30 2:43 ` Tino Calancha 2017-05-01 15:37 ` Philipp Stephani 2 siblings, 0 replies; 8+ messages in thread From: Kaushal Modi @ 2017-04-30 2:41 UTC (permalink / raw) To: Peter Vasil, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1043 bytes --] On Sat, Apr 29, 2017 at 6:20 PM Peter Vasil <mailing_lists@petervasil.net> wrote: > Hello, > > I get an error when compiling Emacs on Fedora 25 with files.el > > Loading /home/peter/src/ema/lisp/files.el (source)... > Symbol’s function definition is void: define-minor-mode > Makefile:735: recipe for target 'bootstrap-emacs' failed > make[2]: *** [bootstrap-emacs] Error 255 > make[2]: Leaving directory '/home/peter/src/emacs/src' > Makefile:416: recipe for target 'src' failed > make[1]: *** [src] Error 2 > > Regards, > Peter > I am getting the same error after make bookstrap on RHEL 6.6 too. Loading /home/kmodi/downloads/git/emacs/lisp/files.el (source)... Symbol’s function definition is void: define-minor-mode make[2]: *** [Makefile:736: bootstrap-emacs] Error 255 make[2]: Leaving directory '/home/kmodi/downloads/git/emacs/src' make[1]: *** [Makefile:416: src] Error 2 make[1]: Leaving directory '/home/kmodi/downloads/git/emacs' make: *** [Makefile:1099: bootstrap] Error 2 -- Kaushal Modi [-- Attachment #2: Type: text/html, Size: 1536 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-29 22:19 ` Peter Vasil 2017-04-30 2:41 ` Kaushal Modi @ 2017-04-30 2:43 ` Tino Calancha 2017-04-30 3:16 ` Kaushal Modi 2017-05-01 15:37 ` Philipp Stephani 2 siblings, 1 reply; 8+ messages in thread From: Tino Calancha @ 2017-04-30 2:43 UTC (permalink / raw) To: Peter Vasil; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 829 bytes --] On Sun, 30 Apr 2017, Peter Vasil wrote: > Hello, > > I get an error when compiling Emacs on Fedora 25 with files.el > > Loading /home/peter/src/emacs/lisp/files.el (source)... > Symbol’s function definition is void: define-minor-mode > Makefile:735: recipe for target 'bootstrap-emacs' failed > make[2]: *** [bootstrap-emacs] Error 255 > make[2]: Leaving directory '/home/peter/src/emacs/src' > Makefile:416: recipe for target 'src' failed > make[1]: *** [src] Error 2 Thanks. I have pushed the following fix: diff --git a/lisp/files.el b/lisp/files.el index af2a713822..0978fa254f 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -28,6 +28,10 @@ ;;; Code: +(eval-when-compile + (require 'pcase) + (require 'easy-mmode)) ; For `define-minor-mode'. + (defvar font-lock-keywords) (defgroup backup nil -- 2.11.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-30 2:43 ` Tino Calancha @ 2017-04-30 3:16 ` Kaushal Modi 0 siblings, 0 replies; 8+ messages in thread From: Kaushal Modi @ 2017-04-30 3:16 UTC (permalink / raw) To: Tino Calancha, Peter Vasil; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 508 bytes --] On Sat, Apr 29, 2017 at 10:43 PM Tino Calancha <tino.calancha@gmail.com> wrote: > I have pushed the following fix: > > diff --git a/lisp/files.el b/lisp/files.el > index af2a713822..0978fa254f 100644 > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -28,6 +28,10 @@ > > ;;; Code: > > +(eval-when-compile > + (require 'pcase) > + (require 'easy-mmode)) ; For `define-minor-mode'. > + > (defvar font-lock-keywords) > > (defgroup backup nil > -- > 2.11.0 > Thanks. I confirm the fix. -- Kaushal Modi [-- Attachment #2: Type: text/html, Size: 934 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reimplement auto-saving to visited files 2017-04-29 22:19 ` Peter Vasil 2017-04-30 2:41 ` Kaushal Modi 2017-04-30 2:43 ` Tino Calancha @ 2017-05-01 15:37 ` Philipp Stephani 2 siblings, 0 replies; 8+ messages in thread From: Philipp Stephani @ 2017-05-01 15:37 UTC (permalink / raw) To: Peter Vasil, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1360 bytes --] Ah, sorry, I forgot that autoloading doesn't work during bootstrapping. Peter Vasil <mailing_lists@petervasil.net> schrieb am So., 30. Apr. 2017 um 00:20 Uhr: > Hello, > > I get an error when compiling Emacs on Fedora 25 with files.el > > Loading /home/peter/src/emacs/lisp/files.el (source)... > Symbol’s function definition is void: define-minor-mode > Makefile:735: recipe for target 'bootstrap-emacs' failed > make[2]: *** [bootstrap-emacs] Error 255 > make[2]: Leaving directory '/home/peter/src/emacs/src' > Makefile:416: recipe for target 'src' failed > make[1]: *** [src] Error 2 > > Regards, > Peter > > On 04/29/2017 09:31 PM, Philipp Stephani wrote: > > > > > > Eli Zaretskii <eliz@gnu.org <mailto:eliz@gnu.org>> schrieb am Sa., 29. > > Apr. 2017 um 21:21 Uhr: > > > > > From: Philipp Stephani <p.stephani2@gmail.com > > <mailto:p.stephani2@gmail.com>> > > > Cc: Philipp Stephani <phst@google.com <mailto:phst@google.com>> > > > Date: Sat, 29 Apr 2017 20:49:09 +0200 > > > > > > +on @code{auto-save-visited-mode}. See @xref{Auto Save Control} > for > > > > @xref itself produces "See", so the "See" before it is unnecessary. > > > > Other than that, I think this can go in. Thanks for working on this. > > > > > > Thanks, pushed as 4db844a453 and 89159e78bb. > > > > [-- Attachment #2: Type: text/html, Size: 2188 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-05-01 15:37 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CAArVCkQSt+GtxxWBOkgUVzZeWKPEGab5hB7xXyXpPm5rMQ0zvA@mail.gmail.com> 2017-04-29 18:49 ` [PATCH] Reimplement auto-saving to visited files Philipp Stephani 2017-04-29 19:20 ` bug#25478: " Eli Zaretskii 2017-04-29 19:31 ` Philipp Stephani 2017-04-29 22:19 ` Peter Vasil 2017-04-30 2:41 ` Kaushal Modi 2017-04-30 2:43 ` Tino Calancha 2017-04-30 3:16 ` Kaushal Modi 2017-05-01 15:37 ` Philipp Stephani
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).