aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-04-03 00:06:40 -0700
committerGlenn Morris2014-04-03 00:06:40 -0700
commitd738ebdccfd2cdcac50f12d55a8c0c311edbc063 (patch)
tree8bee9742617962d5736beefe3ded4f116db1bca3
parent062e286b7ccf2b23cfafef1bf1128eaf91e0ec94 (diff)
downloademacs-d738ebdccfd2cdcac50f12d55a8c0c311edbc063.tar.gz
emacs-d738ebdccfd2cdcac50f12d55a8c0c311edbc063.zip
Doc updates related to changes in revert-buffer function variables
* lisp/files.el (make-backup-file-name-function) (make-backup-file-name, make-backup-file-name--default-function) (make-backup-file-name-1, find-backup-file-name) (revert-buffer-function, revert-buffer-insert-file-contents-function) (buffer-stale--default-function, buffer-stale-function) (before-revert-hook, after-revert-hook, revert-buffer-in-progress-p) (revert-buffer, revert-buffer--default) (revert-buffer-insert-file-contents--default-function): Doc fixes related to defaults no longer being nil. (make-backup-file-name-function): Bump :version. Restore nil as a valid but deprecated custom type. * etc/NEWS: Related edit.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/files.el96
3 files changed, 80 insertions, 37 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 81aebf09c37..32490aefd5c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1397,9 +1397,10 @@ argument, with the same interpretation as the returned value of
1397 1397
1398** Revert and Autorevert changes 1398** Revert and Autorevert changes
1399 1399
1400*** The default value of `revert-buffer-function' is no longer nil. 1400*** The default values of `make-backup-file-name-function',
1401Instead it defaults to a function that does what the nil value used to. 1401`revert-buffer-function', `revert-buffer-insert-file-contents-function',
1402The same applies for `revert-buffer-insert-file-contents-function'. 1402and `buffer-stale-function' are no longer nil. Instead they default
1403to functions that do what the nil value used to.
1403 1404
1404--- 1405---
1405*** If Emacs is compiled with file notification support, it uses notifications 1406*** If Emacs is compiled with file notification support, it uses notifications
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5ea2d4483c4..ee7d61c7389 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12014-04-03 Glenn Morris <rgm@gnu.org>
2
3 * files.el (make-backup-file-name-function)
4 (make-backup-file-name, make-backup-file-name--default-function)
5 (make-backup-file-name-1, find-backup-file-name)
6 (revert-buffer-function, revert-buffer-insert-file-contents-function)
7 (buffer-stale--default-function, buffer-stale-function)
8 (before-revert-hook, after-revert-hook, revert-buffer-in-progress-p)
9 (revert-buffer, revert-buffer--default)
10 (revert-buffer-insert-file-contents--default-function):
11 Doc fixes related to defaults no longer being nil.
12 (make-backup-file-name-function): Bump :version.
13 Restore nil as a valid but deprecated custom type.
14
12014-04-03 Stefan Monnier <monnier@iro.umontreal.ca> 152014-04-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 16
3 * progmodes/perl-mode.el (perl-syntax-propertize-function): Handle $' 17 * progmodes/perl-mode.el (perl-syntax-propertize-function): Handle $'
diff --git a/lisp/files.el b/lisp/files.el
index 6d0be9234e6..d5c6028ff47 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4215,15 +4215,22 @@ FILENAME defaults to `buffer-file-name'."
4215 4215
4216(defcustom make-backup-file-name-function 4216(defcustom make-backup-file-name-function
4217 #'make-backup-file-name--default-function 4217 #'make-backup-file-name--default-function
4218 "A function to use instead of the default `make-backup-file-name'. 4218 "A function that `make-backup-file-name' uses to create backup file names.
4219The function receives a single argument, the original file name.
4219 4220
4220This could be buffer-local to do something special for specific 4221If you change this, you may need to change `backup-file-name-p' and
4221files. If you define it, you may need to change `backup-file-name-p' 4222`file-name-sans-versions' too.
4222and `file-name-sans-versions' too. 4223
4224You could make this buffer-local to do something special for specific files.
4225
4226For historical reasons, a value of nil means to use the default function.
4227This should not be relied upon.
4223 4228
4224See also `backup-directory-alist'." 4229See also `backup-directory-alist'."
4230 :version "24.4" ; nil -> make-backup-file-name--default-function
4225 :group 'backup 4231 :group 'backup
4226 :type '(function :tag "Your function")) 4232 :type '(choice (const :tag "Deprecated way to get the default function" nil)
4233 (function :tag "Function")))
4227 4234
4228(defcustom backup-directory-alist nil 4235(defcustom backup-directory-alist nil
4229 "Alist of filename patterns and backup directory names. 4236 "Alist of filename patterns and backup directory names.
@@ -4280,20 +4287,17 @@ Checks for files in `temporary-file-directory',
4280 4287
4281(defun make-backup-file-name (file) 4288(defun make-backup-file-name (file)
4282 "Create the non-numeric backup file name for FILE. 4289 "Create the non-numeric backup file name for FILE.
4283Normally this will just be the file's name with `~' appended. 4290This calls the function that `make-backup-file-name-function' specifies,
4284Customization hooks are provided as follows. 4291with a single argument FILE."
4285
4286The value of `make-backup-file-name-function' should be a function which
4287will be called with FILE as its argument; the resulting name is used.
4288
4289By default, a match for FILE is sought in `backup-directory-alist'; see
4290the documentation of that variable. If the directory for the backup
4291doesn't exist, it is created."
4292 (funcall (or make-backup-file-name-function 4292 (funcall (or make-backup-file-name-function
4293 #'make-backup-file-name--default-function) 4293 #'make-backup-file-name--default-function)
4294 file)) 4294 file))
4295 4295
4296(defun make-backup-file-name--default-function (file) 4296(defun make-backup-file-name--default-function (file)
4297 "Default function for `make-backup-file-name'.
4298Normally this just returns FILE's name with `~' appended.
4299It searches for a match for FILE in `backup-directory-alist'.
4300If the directory for the backup doesn't exist, it is created."
4297 (if (and (eq system-type 'ms-dos) 4301 (if (and (eq system-type 'ms-dos)
4298 (not (msdos-long-file-names))) 4302 (not (msdos-long-file-names)))
4299 (let ((fn (file-name-nondirectory file))) 4303 (let ((fn (file-name-nondirectory file)))
@@ -4305,7 +4309,8 @@ doesn't exist, it is created."
4305 (concat (make-backup-file-name-1 file) "~"))) 4309 (concat (make-backup-file-name-1 file) "~")))
4306 4310
4307(defun make-backup-file-name-1 (file) 4311(defun make-backup-file-name-1 (file)
4308 "Subroutine of `make-backup-file-name' and `find-backup-file-name'." 4312 "Subroutine of `make-backup-file-name--default-function'.
4313The function `find-backup-file-name' also uses this."
4309 (let ((alist backup-directory-alist) 4314 (let ((alist backup-directory-alist)
4310 elt backup-directory abs-backup-directory) 4315 elt backup-directory abs-backup-directory)
4311 (while alist 4316 (while alist
@@ -4382,8 +4387,8 @@ the index in the name where the version number begins."
4382Value is a list whose car is the name for the backup file 4387Value is a list whose car is the name for the backup file
4383and whose cdr is a list of old versions to consider deleting now. 4388and whose cdr is a list of old versions to consider deleting now.
4384If the value is nil, don't make a backup. 4389If the value is nil, don't make a backup.
4385Uses `backup-directory-alist' in the same way as does 4390Uses `backup-directory-alist' in the same way as
4386`make-backup-file-name'." 4391`make-backup-file-name--default-function' does."
4387 (let ((handler (find-file-name-handler fn 'find-backup-file-name))) 4392 (let ((handler (find-file-name-handler fn 'find-backup-file-name)))
4388 ;; Run a handler for this function so that ange-ftp can refuse to do it. 4393 ;; Run a handler for this function so that ange-ftp can refuse to do it.
4389 (if handler 4394 (if handler
@@ -5319,22 +5324,32 @@ comparison."
5319 5324
5320(put 'revert-buffer-function 'permanent-local t) 5325(put 'revert-buffer-function 'permanent-local t)
5321(defvar revert-buffer-function #'revert-buffer--default 5326(defvar revert-buffer-function #'revert-buffer--default
5322 "Function to use to revert this buffer, or nil to do the default. 5327 "Function to use to revert this buffer.
5323The function receives two arguments IGNORE-AUTO and NOCONFIRM, 5328The function receives two arguments IGNORE-AUTO and NOCONFIRM,
5324which are the arguments that `revert-buffer' received. 5329which are the arguments that `revert-buffer' received.
5325It also has access to the `preserve-modes' argument of `revert-buffer' 5330It also has access to the `preserve-modes' argument of `revert-buffer'
5326via the `revert-buffer-preserve-modes' dynamic variable.") 5331via the `revert-buffer-preserve-modes' dynamic variable.
5332
5333For historical reasons, a value of nil means to use the default function.
5334This should not be relied upon.")
5327 5335
5328(put 'revert-buffer-insert-file-contents-function 'permanent-local t) 5336(put 'revert-buffer-insert-file-contents-function 'permanent-local t)
5329(defvar revert-buffer-insert-file-contents-function 5337(defvar revert-buffer-insert-file-contents-function
5330 #'revert-buffer-insert-file-contents--default-function 5338 #'revert-buffer-insert-file-contents--default-function
5331 "Function to use to insert contents when reverting this buffer. 5339 "Function to use to insert contents when reverting this buffer.
5332Gets two args, first the nominal file name to use, 5340The function receives two arguments: the first the nominal file name to use;
5333and second, t if reading the auto-save file. 5341the second is t if reading the auto-save file.
5334 5342
5335The function you specify is responsible for updating (or preserving) point.") 5343The function is responsible for updating (or preserving) point.
5344
5345For historical reasons, a value of nil means to use the default function.
5346This should not be relied upon.")
5336 5347
5337(defun buffer-stale--default-function (&optional _noconfirm) 5348(defun buffer-stale--default-function (&optional _noconfirm)
5349 "Default function to use for `buffer-stale-function'.
5350This function ignores its argument.
5351This returns non-nil if the current buffer is visiting a readable file
5352whose modification time does not match that of the buffer."
5338 (and buffer-file-name 5353 (and buffer-file-name
5339 (file-readable-p buffer-file-name) 5354 (file-readable-p buffer-file-name)
5340 (not (verify-visited-file-modtime (current-buffer))))) 5355 (not (verify-visited-file-modtime (current-buffer)))))
@@ -5353,13 +5368,16 @@ non-nil if the buffer is going to be reverted without asking the
5353user. In such situations, one has to be careful with potentially 5368user. In such situations, one has to be careful with potentially
5354time consuming operations. 5369time consuming operations.
5355 5370
5371For historical reasons, a value of nil means to use the default function.
5372This should not be relied upon.
5373
5356For more information on how this variable is used by Auto Revert mode, 5374For more information on how this variable is used by Auto Revert mode,
5357see Info node `(emacs)Supporting additional buffers'.") 5375see Info node `(emacs)Supporting additional buffers'.")
5358 5376
5359(defvar before-revert-hook nil 5377(defvar before-revert-hook nil
5360 "Normal hook for `revert-buffer' to run before reverting. 5378 "Normal hook for `revert-buffer' to run before reverting.
5361If `revert-buffer-function' is used to override the normal revert 5379The function `revert-buffer--default' runs this.
5362mechanism, this hook is not used.") 5380A customized `revert-buffer-function' need not run this hook.")
5363 5381
5364(defvar after-revert-hook nil 5382(defvar after-revert-hook nil
5365 "Normal hook for `revert-buffer' to run after reverting. 5383 "Normal hook for `revert-buffer' to run after reverting.
@@ -5367,12 +5385,11 @@ Note that the hook value that it runs is the value that was in effect
5367before reverting; that makes a difference if you have buffer-local 5385before reverting; that makes a difference if you have buffer-local
5368hook functions. 5386hook functions.
5369 5387
5370If `revert-buffer-function' is used to override the normal revert 5388The function `revert-buffer--default' runs this.
5371mechanism, this hook is not used.") 5389A customized `revert-buffer-function' need not run this hook.")
5372 5390
5373(defvar revert-buffer-in-progress-p nil 5391(defvar revert-buffer-in-progress-p nil
5374 "Non-nil if a `revert-buffer' operation is in progress, nil otherwise. 5392 "Non-nil if a `revert-buffer' operation is in progress, nil otherwise.")
5375This is true even if a `revert-buffer-function' is being used.")
5376 5393
5377(defvar revert-buffer-internal-hook) 5394(defvar revert-buffer-internal-hook)
5378 5395
@@ -5409,12 +5426,10 @@ the files modes. Normally we reinitialize them using `normal-mode'.
5409 5426
5410This function binds `revert-buffer-in-progress-p' non-nil while it operates. 5427This function binds `revert-buffer-in-progress-p' non-nil while it operates.
5411 5428
5412If the value of `revert-buffer-function' is non-nil, it is called to 5429This function calls the function that `revert-buffer-function' specifies
5413do all the work for this command. Otherwise, the hooks 5430to do the work, with arguments IGNORE-AUTO and NOCONFIRM.
5414`before-revert-hook' and `after-revert-hook' are run at the beginning 5431The default function runs the hooks `before-revert-hook' and
5415and the end, and if `revert-buffer-insert-file-contents-function' is 5432`after-revert-hook'."
5416non-nil, it is called instead of rereading visited file contents."
5417
5418 ;; I admit it's odd to reverse the sense of the prefix argument, but 5433 ;; I admit it's odd to reverse the sense of the prefix argument, but
5419 ;; there is a lot of code out there which assumes that the first 5434 ;; there is a lot of code out there which assumes that the first
5420 ;; argument should be t to avoid consulting the auto-save file, and 5435 ;; argument should be t to avoid consulting the auto-save file, and
@@ -5426,7 +5441,16 @@ non-nil, it is called instead of rereading visited file contents."
5426 (revert-buffer-preserve-modes preserve-modes)) 5441 (revert-buffer-preserve-modes preserve-modes))
5427 (funcall (or revert-buffer-function #'revert-buffer--default) 5442 (funcall (or revert-buffer-function #'revert-buffer--default)
5428 ignore-auto noconfirm))) 5443 ignore-auto noconfirm)))
5444
5429(defun revert-buffer--default (ignore-auto noconfirm) 5445(defun revert-buffer--default (ignore-auto noconfirm)
5446 "Default function for `revert-buffer'.
5447The arguments IGNORE-AUTO and NOCONFIRM are as described for `revert-buffer'.
5448Runs the hooks `before-revert-hook' and `after-revert-hook' at the
5449start and end.
5450
5451Calls `revert-buffer-insert-file-contents-function' to reread the
5452contents of the visited file, with two arguments: the first is the file
5453name, the second is non-nil if reading an auto-save file."
5430 (with-current-buffer (or (buffer-base-buffer (current-buffer)) 5454 (with-current-buffer (or (buffer-base-buffer (current-buffer))
5431 (current-buffer)) 5455 (current-buffer))
5432 (let* ((auto-save-p (and (not ignore-auto) 5456 (let* ((auto-save-p (and (not ignore-auto)
@@ -5480,6 +5504,10 @@ non-nil, it is called instead of rereading visited file contents."
5480 t))))) 5504 t)))))
5481 5505
5482(defun revert-buffer-insert-file-contents--default-function (file-name auto-save-p) 5506(defun revert-buffer-insert-file-contents--default-function (file-name auto-save-p)
5507 "Default function for `revert-buffer-insert-file-contents-function'.
5508The function `revert-buffer--default' calls this.
5509FILE-NAME is the name of the file. AUTO-SAVE-P is non-nil if this is
5510an auto-save file."
5483 (cond 5511 (cond
5484 ((not (file-exists-p file-name)) 5512 ((not (file-exists-p file-name))
5485 (error (if buffer-file-number 5513 (error (if buffer-file-number