From: Simon Josefsson <jas@extundo.com>
Cc: emacs-devel@gnu.org
Subject: Re: Defcustom write-file-functions and write-contents-functions?
Date: Wed, 31 Dec 2003 20:56:21 +0100 [thread overview]
Message-ID: <ilu4qvgu5ga.fsf@latte.josefsson.org> (raw)
In-Reply-To: <200312311927.hBVJR8H29112@raven.dms.auburn.edu> (Luc Teirlinck's message of "Wed, 31 Dec 2003 13:27:08 -0600 (CST)")
You convinced me, thanks for the feedback. How about this patch,
instead?
2003-12-31 Simon Josefsson <jas@extundo.com>
* files.el (before-save-hook): Add.
(basic-save-buffer): Use before-save-hook.
* emacs-lisp/copyright.el: Use before-save-hook instead of
write-file-functions.
Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.673
diff -u -p -r1.673 files.el
--- lisp/files.el 29 Dec 2003 19:14:03 -0000 1.673
+++ lisp/files.el 31 Dec 2003 19:51:10 -0000
@@ -2990,6 +2990,12 @@ the last real save, but optional arg FOR
(defvar auto-save-hook nil
"Normal hook run just before auto-saving.")
+(defcustom before-save-hook nil
+ "Normal hook that is run before a buffer is saved to its file."
+ :options '(copyright-update)
+ :type 'hook
+ :group 'files)
+
(defcustom after-save-hook nil
"Normal hook that is run after a buffer is saved to its file."
:options '(executable-make-buffer-file-executable-if-script-p)
@@ -3012,7 +3018,8 @@ in such cases.")
The hooks `write-contents-functions' and `write-file-functions' get a chance
to do the job of saving; if they do not, then the buffer is saved in
the visited file file in the usual way.
-After saving the buffer, this function runs `after-save-hook'."
+Before and after saving the buffer, this function runs
+`before-save-hook' and `after-save-hook', respectively."
(interactive)
(save-current-buffer
;; In an indirect buffer, save its base buffer instead.
@@ -3068,6 +3075,7 @@ After saving the buffer, this function r
(insert ?\n))))
;; Support VC version backups.
(vc-before-save)
+ (run-hooks 'before-save-hook)
(or (run-hook-with-args-until-success 'write-contents-functions)
(run-hook-with-args-until-success 'local-write-file-hooks)
(run-hook-with-args-until-success 'write-file-functions)
Index: lisp/emacs-lisp/copyright.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/copyright.el,v
retrieving revision 1.43
diff -u -p -r1.43 copyright.el
--- lisp/emacs-lisp/copyright.el 1 Sep 2003 15:45:20 -0000 1.43
+++ lisp/emacs-lisp/copyright.el 31 Dec 2003 19:51:10 -0000
@@ -27,7 +27,8 @@
;; Allows updating the copyright year and above mentioned GPL version manually
;; or when saving a file.
-;; Do (add-hook 'write-file-functions 'copyright-update).
+;; Do (add-hook 'before-save-hook 'copyright-update), or use
+;; M-x customize-variable RET before-save-hook RET.
;;; Code:
next prev parent reply other threads:[~2003-12-31 19:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-31 14:38 Defcustom write-file-functions and write-contents-functions? Simon Josefsson
2003-12-31 16:57 ` Luc Teirlinck
2003-12-31 17:26 ` Simon Josefsson
2003-12-31 19:27 ` Luc Teirlinck
2003-12-31 19:56 ` Simon Josefsson [this message]
2003-12-31 20:10 ` Luc Teirlinck
2004-01-01 5:52 ` Eli Zaretskii
2004-01-01 12:22 ` Simon Josefsson
2004-01-01 14:45 ` Eli Zaretskii
2004-01-04 23:33 ` Stefan Monnier
2004-01-05 0:14 ` Luc Teirlinck
2004-01-05 0:31 ` Miles Bader
2004-01-05 0:46 ` Simon Josefsson
2004-01-05 17:56 ` Richard Stallman
2004-01-05 18:38 ` Simon Josefsson
2004-01-04 14:54 ` Per Abrahamsen
2004-01-05 4:41 ` Luc Teirlinck
2004-01-07 2:07 ` Luc Teirlinck
2004-01-07 3:03 ` Luc Teirlinck
2004-01-07 15:05 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ilu4qvgu5ga.fsf@latte.josefsson.org \
--to=jas@extundo.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.