aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorEric Abrahamsen2017-09-12 16:06:12 -0700
committerEric Abrahamsen2017-09-12 16:06:12 -0700
commit9b980e2691afa3a7a967011fc004d352750fe618 (patch)
tree5d5cc5e432da299eaa5ab9dfb8384b12e7101d36 /doc
parentd07fd34722b84ae2c407f195c82d7632a94de704 (diff)
downloademacs-9b980e2691afa3a7a967011fc004d352750fe618.tar.gz
emacs-9b980e2691afa3a7a967011fc004d352750fe618.zip
Allow write-contents-functions to short-circuit buffer save
Bug#28412 * lisp/files.el (basic-save-buffer): Re-arrange function so that write-contents-functions are run earlier. If they return non-nil, consider the buffer saved without requiring the buffer to be visiting a file. (save-some-buffers): This function should consider any buffer with a buffer-local value for write-contents-functions eligible for saving. * test/lisp/files-tests.el (files-test-no-file-write-contents): New test. * doc/lispref/files.texi (Saving Buffers): Mention in docs. * etc/NEWS: And in NEWS.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/files.texi18
1 files changed, 13 insertions, 5 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 901382fe9bd..6be998f0b2e 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -457,15 +457,23 @@ Even though this is not a normal hook, you can use @code{add-hook} and
457@defvar write-contents-functions 457@defvar write-contents-functions
458This works just like @code{write-file-functions}, but it is intended 458This works just like @code{write-file-functions}, but it is intended
459for hooks that pertain to the buffer's contents, not to the particular 459for hooks that pertain to the buffer's contents, not to the particular
460visited file or its location. Such hooks are usually set up by major 460visited file or its location, and can be used to create arbitrary save
461modes, as buffer-local bindings for this variable. This variable 461processes for buffers that aren't visiting files at all. Such hooks
462automatically becomes buffer-local whenever it is set; switching to a 462are usually set up by major modes, as buffer-local bindings for this
463new major mode always resets this variable, but calling 463variable. This variable automatically becomes buffer-local whenever
464@code{set-visited-file-name} does not. 464it is set; switching to a new major mode always resets this variable,
465but calling @code{set-visited-file-name} does not.
465 466
466If any of the functions in this hook returns non-@code{nil}, the file 467If any of the functions in this hook returns non-@code{nil}, the file
467is considered already written and the rest are not called and neither 468is considered already written and the rest are not called and neither
468are the functions in @code{write-file-functions}. 469are the functions in @code{write-file-functions}.
470
471When using this hook to save buffers that are not visiting files (for
472instance, special-mode buffers), keep in mind that, if the function
473fails to save correctly and returns a @code{nil} value,
474@code{save-buffer} will go on to prompt the user for a file to save
475the buffer in. If this is undesirable, consider having the function
476fail by raising an error.
469@end defvar 477@end defvar
470 478
471@defopt before-save-hook 479@defopt before-save-hook