aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2006-02-11 18:42:56 +0000
committerEli Zaretskii2006-02-11 18:42:56 +0000
commit518dc5be4e2547a25a2b33d853602866df5d085b (patch)
tree72aa5277a58ea45a84646d32468400d7942d8af6
parent5fb64ecc5b92d890e3a066188c9c4097712ba33b (diff)
downloademacs-518dc5be4e2547a25a2b33d853602866df5d085b.tar.gz
emacs-518dc5be4e2547a25a2b33d853602866df5d085b.zip
(revert-buffer, recover-file): Replace buffer-read-only with inhibit-read-only. Suggested by Stefan Monnier.
(revert-buffer): Let insert-file-contents discard buffer-undo-list. Simplify code. (find-file, find-file-existing, revert-buffer): Doc-string fixes.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/files.el106
2 files changed, 60 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e8076374547..fe9fd65a1c9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12006-02-11 Martin Rudalics <rudalics@gmx.at>
2
3 * files.el (revert-buffer, recover-file): Replace buffer-read-only
4 with inhibit-read-only. Suggested by Stefan Monnier.
5 (revert-buffer): Let insert-file-contents discard
6 buffer-undo-list. Simplify code.
7 (find-file, find-file-existing, revert-buffer): Doc-string fixes.
8
12006-02-11 Eli Zaretskii <eliz@gnu.org> 92006-02-11 Eli Zaretskii <eliz@gnu.org>
2 10
3 * menu-bar.el (menu-bar-select-yank): Add a doc string. 11 * menu-bar.el (menu-bar-select-yank): Add a doc string.
diff --git a/lisp/files.el b/lisp/files.el
index fee3a5ea65f..59a032759e4 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1025,7 +1025,7 @@ type M-n to pull it into the minibuffer.
1025 1025
1026Interactively, or if WILDCARDS is non-nil in a call from Lisp, 1026Interactively, or if WILDCARDS is non-nil in a call from Lisp,
1027expand wildcards (if any) and visit multiple files. You can 1027expand wildcards (if any) and visit multiple files. You can
1028suppress wildcard expansion by setting `find-file-wildcards'. 1028suppress wildcard expansion by setting `find-file-wildcards' to nil.
1029 1029
1030To visit a file without any kind of conversion and without 1030To visit a file without any kind of conversion and without
1031automatically choosing a major mode, use \\[find-file-literally]." 1031automatically choosing a major mode, use \\[find-file-literally]."
@@ -1077,7 +1077,7 @@ expand wildcards (if any) and visit multiple files."
1077 1077
1078(defun find-file-existing (filename &optional wildcards) 1078(defun find-file-existing (filename &optional wildcards)
1079 "Edit the existing file FILENAME. 1079 "Edit the existing file FILENAME.
1080Like \\[find-file] but only allow files that exists." 1080Like \\[find-file] but only allow a file that exists."
1081 (interactive (find-file-read-args "Find existing file: " t)) 1081 (interactive (find-file-read-args "Find existing file: " t))
1082 (unless (file-exists-p filename) (error "%s does not exist" filename)) 1082 (unless (file-exists-p filename) (error "%s does not exist" filename))
1083 (find-file filename wildcards) 1083 (find-file filename wildcards)
@@ -3795,8 +3795,8 @@ sake of backward compatibility. IGNORE-AUTO is optional, defaulting
3795to nil. 3795to nil.
3796 3796
3797Optional second argument NOCONFIRM means don't ask for confirmation at 3797Optional second argument NOCONFIRM means don't ask for confirmation at
3798all. (The local variable `revert-without-query', if non-nil, prevents 3798all. \(The variable `revert-without-query' offers another way to
3799confirmation.) 3799revert buffers without querying for confirmation.)
3800 3800
3801Optional third argument PRESERVE-MODES non-nil means don't alter 3801Optional third argument PRESERVE-MODES non-nil means don't alter
3802the files modes. Normally we reinitialize them using `normal-mode'. 3802the files modes. Normally we reinitialize them using `normal-mode'.
@@ -3831,13 +3831,10 @@ non-nil, it is called instead of rereading visited file contents."
3831 (error "Buffer does not seem to be associated with any file")) 3831 (error "Buffer does not seem to be associated with any file"))
3832 ((or noconfirm 3832 ((or noconfirm
3833 (and (not (buffer-modified-p)) 3833 (and (not (buffer-modified-p))
3834 (let ((tail revert-without-query) 3834 (catch 'found
3835 (found nil)) 3835 (dolist (regexp revert-without-query)
3836 (while tail 3836 (when (string-match regexp file-name)
3837 (if (string-match (car tail) file-name) 3837 (throw 'found t)))))
3838 (setq found t))
3839 (setq tail (cdr tail)))
3840 found))
3841 (yes-or-no-p (format "Revert buffer from file %s? " 3838 (yes-or-no-p (format "Revert buffer from file %s? "
3842 file-name))) 3839 file-name)))
3843 (run-hooks 'before-revert-hook) 3840 (run-hooks 'before-revert-hook)
@@ -3846,50 +3843,51 @@ non-nil, it is called instead of rereading visited file contents."
3846 (and (not auto-save-p) 3843 (and (not auto-save-p)
3847 (not (verify-visited-file-modtime (current-buffer))) 3844 (not (verify-visited-file-modtime (current-buffer)))
3848 (setq buffer-backed-up nil)) 3845 (setq buffer-backed-up nil))
3849 ;; Get rid of all undo records for this buffer.
3850 (or (eq buffer-undo-list t)
3851 (setq buffer-undo-list nil))
3852 ;; Effectively copy the after-revert-hook status, 3846 ;; Effectively copy the after-revert-hook status,
3853 ;; since after-find-file will clobber it. 3847 ;; since after-find-file will clobber it.
3854 (let ((global-hook (default-value 'after-revert-hook)) 3848 (let ((global-hook (default-value 'after-revert-hook))
3855 (local-hook-p (local-variable-p 'after-revert-hook)) 3849 (local-hook (when (local-variable-p 'after-revert-hook)
3856 (local-hook (and (local-variable-p 'after-revert-hook) 3850 after-revert-hook))
3857 after-revert-hook))) 3851 (inhibit-read-only t))
3858 (let (buffer-read-only 3852 (cond
3859 ;; Don't make undo records for the reversion. 3853 (revert-buffer-insert-file-contents-function
3860 (buffer-undo-list t)) 3854 (unless (eq buffer-undo-list t)
3861 (if revert-buffer-insert-file-contents-function 3855 ;; Get rid of all undo records for this buffer.
3862 (funcall revert-buffer-insert-file-contents-function 3856 (setq buffer-undo-list nil))
3863 file-name auto-save-p) 3857 ;; Don't make undo records for the reversion.
3864 (if (not (file-exists-p file-name)) 3858 (let ((buffer-undo-list t))
3865 (error (if buffer-file-number 3859 (funcall revert-buffer-insert-file-contents-function
3866 "File %s no longer exists!" 3860 file-name auto-save-p)))
3867 "Cannot revert nonexistent file %s") 3861 ((not (file-exists-p file-name))
3868 file-name)) 3862 (error (if buffer-file-number
3869 ;; Bind buffer-file-name to nil 3863 "File %s no longer exists!"
3870 ;; so that we don't try to lock the file. 3864 "Cannot revert nonexistent file %s")
3871 (let ((buffer-file-name nil)) 3865 file-name))
3872 (or auto-save-p 3866 (t
3873 (unlock-buffer))) 3867 ;; Bind buffer-file-name to nil
3874 (widen) 3868 ;; so that we don't try to lock the file.
3875 (let ((coding-system-for-read 3869 (let ((buffer-file-name nil))
3876 ;; Auto-saved file shoule be read by Emacs' 3870 (or auto-save-p
3877 ;; internal coding. 3871 (unlock-buffer)))
3878 (if auto-save-p 'auto-save-coding 3872 (widen)
3879 (or coding-system-for-read 3873 (let ((coding-system-for-read
3880 buffer-file-coding-system-explicit)))) 3874 ;; Auto-saved file should be read by Emacs'
3881 ;; This force after-insert-file-set-coding 3875 ;; internal coding.
3882 ;; (called from insert-file-contents) to set 3876 (if auto-save-p 'auto-save-coding
3883 ;; buffer-file-coding-system to a proper value. 3877 (or coding-system-for-read
3884 (kill-local-variable 'buffer-file-coding-system) 3878 buffer-file-coding-system-explicit))))
3885 3879 ;; This force after-insert-file-set-coding
3886 ;; Note that this preserves point in an intelligent way. 3880 ;; (called from insert-file-contents) to set
3887 (if preserve-modes 3881 ;; buffer-file-coding-system to a proper value.
3888 (let ((buffer-file-format buffer-file-format)) 3882 (kill-local-variable 'buffer-file-coding-system)
3889 (insert-file-contents file-name (not auto-save-p) 3883
3890 nil nil t)) 3884 ;; Note that this preserves point in an intelligent way.
3891 (insert-file-contents file-name (not auto-save-p) 3885 (if preserve-modes
3892 nil nil t))))) 3886 (let ((buffer-file-format buffer-file-format))
3887 (insert-file-contents file-name (not auto-save-p)
3888 nil nil t))
3889 (insert-file-contents file-name (not auto-save-p)
3890 nil nil t)))))
3893 ;; Recompute the truename in case changes in symlinks 3891 ;; Recompute the truename in case changes in symlinks
3894 ;; have changed the truename. 3892 ;; have changed the truename.
3895 (setq buffer-file-truename 3893 (setq buffer-file-truename
@@ -3897,7 +3895,7 @@ non-nil, it is called instead of rereading visited file contents."
3897 (after-find-file nil nil t t preserve-modes) 3895 (after-find-file nil nil t t preserve-modes)
3898 ;; Run after-revert-hook as it was before we reverted. 3896 ;; Run after-revert-hook as it was before we reverted.
3899 (setq-default revert-buffer-internal-hook global-hook) 3897 (setq-default revert-buffer-internal-hook global-hook)
3900 (if local-hook-p 3898 (if local-hook
3901 (set (make-local-variable 'revert-buffer-internal-hook) 3899 (set (make-local-variable 'revert-buffer-internal-hook)
3902 local-hook) 3900 local-hook)
3903 (kill-local-variable 'revert-buffer-internal-hook)) 3901 (kill-local-variable 'revert-buffer-internal-hook))
@@ -3943,7 +3941,7 @@ non-nil, it is called instead of rereading visited file contents."
3943 (insert-directory-safely file-name switches)))) 3941 (insert-directory-safely file-name switches))))
3944 (yes-or-no-p (format "Recover auto save file %s? " file-name))) 3942 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
3945 (switch-to-buffer (find-file-noselect file t)) 3943 (switch-to-buffer (find-file-noselect file t))
3946 (let ((buffer-read-only nil) 3944 (let ((inhibit-read-only t)
3947 ;; Keep the current buffer-file-coding-system. 3945 ;; Keep the current buffer-file-coding-system.
3948 (coding-system buffer-file-coding-system) 3946 (coding-system buffer-file-coding-system)
3949 ;; Auto-saved file shoule be read with special coding. 3947 ;; Auto-saved file shoule be read with special coding.