summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/emacs-lisp/copyright.el5
-rw-r--r--lisp/files.el10
-rw-r--r--lisp/finder.el1
-rw-r--r--lisp/net/ange-ftp.el4
-rw-r--r--lispref/ChangeLog5
-rw-r--r--lispref/files.texi9
-rw-r--r--lispref/hooks.texi3
9 files changed, 56 insertions, 6 deletions
diff --git a/etc/NEWS b/etc/NEWS
index e904c06c699..43566ebea29 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1737,6 +1737,11 @@ configuration files.
* Lisp Changes in Emacs 21.4
+** The new hook `before-save-hook' is invoked by `basic-save-buffer'
+before saving buffers. This allows packages to perform various final
+tasks, for example; it can be used by the copyright package to make
+sure saved files have the current year in any copyright headers.
+
** The function `insert-for-yank' now supports strings where the
`yank-handler' property does not span the first character of the
string. The old behavior is available if you call
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 14963f0ef8c..67e62e7025a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,23 @@
+2004-01-05 Karl Berry <karl@gnu.org>
+
+ * emacs-lisp/copyright.el (copyright-regexp): might as well allow
+ / and *, too.
+
+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: Fix comment to recommend
+ before-save-hook instead of write-file-functions.
+
+2004-01-05 Richard M. Stallman <rms@gnu.org>
+
+ * finder.el (finder-commentary): Call delete-other-windows.
+
+ * net/ange-ftp.el (ange-ftp-file-attributes):
+ Pass 2 args to ange-ftp-real-file-attributes only if ID-FORMAT non-nil.
+
2004-01-04 Karl Berry <karl@gnu.org>
* emacs-lisp/copyright.el (copyright-regexp): allow the common
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 4532f7e5b77..6a95c60f859 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -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:
@@ -47,7 +48,7 @@ A value of nil means to search whole buffer."
(defcustom copyright-regexp
"\\([]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\
\\|[Cc]opyright\\s *:?\\s *[]\\)\
-\\s *\\([1-9]\\([-0-9, ';%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
+\\s *\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
"*What your copyright notice looks like.
The second \\( \\) construct must match the years."
:group 'copyright
diff --git a/lisp/files.el b/lisp/files.el
index ec58906e485..e74ef0bcbc1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2990,6 +2990,12 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
(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 runs `after-save-hook'."
(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)
diff --git a/lisp/finder.el b/lisp/finder.el
index 2958f36c3d9..0bd001752fe 100644
--- a/lisp/finder.el
+++ b/lisp/finder.el
@@ -282,6 +282,7 @@ FILE should be in a form suitable for passing to `locate-library'."
(error "Can't find any Commentary section"))
;; This used to use *Finder* but that would clobber the
;; directory of categories.
+ (delete-other-windows)
(pop-to-buffer "*Finder-package*")
(setq buffer-read-only nil)
(erase-buffer)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 0277bd0aabc..8e1068a5bed 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -3468,7 +3468,9 @@ system TYPE.")
inode ;10 "inode number".
-1 ;11 device number [v19 only]
))))
- (ange-ftp-real-file-attributes file id-format))))
+ (if id-format
+ (ange-ftp-real-file-attributes file id-format)
+ (ange-ftp-real-file-attributes file)))))
(defun ange-ftp-file-newer-than-file-p (f1 f2)
(let ((f1-parsed (ange-ftp-ftp-name f1))
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 1ef5bca1d46..d61b756401a 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-01 Simon Josefsson <jas@extundo.com>
+
+ * hooks.texi (Standard Hooks): Add before-save-hook.
+ * files.texi (Saving Buffers): Likewise.
+
2004-01-03 Richard M. Stallman <rms@gnu.org>
* frames.texi (Frames and Windows): Delete frame-root-window.
diff --git a/lispref/files.texi b/lispref/files.texi
index 575a90ccf92..b461273b5fe 100644
--- a/lispref/files.texi
+++ b/lispref/files.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2004
@c Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/files
@@ -410,6 +410,13 @@ This variable automatically becomes buffer-local whenever it is set;
switching to a new major mode always resets this variable.
@end defvar
+@defvar before-save-hook
+This normal hook runs before a buffer has been saved in its visited
+file. One use of this hook is for the Copyright package; it uses this
+hook to make sure the file has the current year in the copyright
+header.
+@end defvar
+
@c Emacs 19 feature
@defvar after-save-hook
This normal hook runs after a buffer has been saved in its visited file.
diff --git a/lispref/hooks.texi b/lispref/hooks.texi
index fde028a3d14..bc90c8773c2 100644
--- a/lispref/hooks.texi
+++ b/lispref/hooks.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1998 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1998, 2004 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/hooks
@node Standard Hooks, Index, Standard Keymaps, Top
@@ -47,6 +47,7 @@ however, we have renamed all of those.)
@item before-init-hook
@item before-make-frame-hook
@item before-revert-hook
+@item before-save-hook
@item blink-paren-function
@item buffer-access-fontify-functions
@item c-mode-hook