Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 849:503b6a57cf47
[xemacs-hg @ 2002-05-21 10:29:07 by stephent]
revert-buffer docs, eldap.c <87hel1er8q.fsf@tleepslib.sk.tsukuba.ac.jp> <87d6vper2g.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Tue, 21 May 2002 10:29:15 +0000 |
parents | 047d37eb70d7 |
children | e7ee5f8bde58 |
comparison
equal
deleted
inserted
replaced
848:0cb55b2a2c66 | 849:503b6a57cf47 |
---|---|
2762 | 2762 |
2763 (put 'revert-buffer-insert-file-contents-function 'permanent-local t) | 2763 (put 'revert-buffer-insert-file-contents-function 'permanent-local t) |
2764 (defvar revert-buffer-insert-file-contents-function nil | 2764 (defvar revert-buffer-insert-file-contents-function nil |
2765 "Function to use to insert contents when reverting this buffer. | 2765 "Function to use to insert contents when reverting this buffer. |
2766 Gets two args, first the nominal file name to use, | 2766 Gets two args, first the nominal file name to use, |
2767 and second, t if reading the auto-save file.") | 2767 and second, t if reading the auto-save file. |
2768 If the current buffer contents are to be discarded, the function must do | |
2769 so itself.") | |
2768 | 2770 |
2769 (defvar before-revert-hook nil | 2771 (defvar before-revert-hook nil |
2770 "Normal hook for `revert-buffer' to run before reverting. | 2772 "Normal hook for `revert-buffer' to run before reverting. |
2771 If `revert-buffer-function' is used to override the normal revert | 2773 If `revert-buffer-function' is used to override the normal revert |
2772 mechanism, this hook is not used.") | 2774 mechanism, this hook is not used.") |
2787 "Replace the buffer text with the text of the visited file on disk. | 2789 "Replace the buffer text with the text of the visited file on disk. |
2788 This undoes all changes since the file was visited or saved. | 2790 This undoes all changes since the file was visited or saved. |
2789 With a prefix argument, offer to revert from latest auto-save file, if | 2791 With a prefix argument, offer to revert from latest auto-save file, if |
2790 that is more recent than the visited file. | 2792 that is more recent than the visited file. |
2791 | 2793 |
2792 This command also works for special buffers that contain text which | 2794 This command also refreshes certain special buffers that contain text |
2793 doesn't come from a file, but reflects some other data base instead: | 2795 which doesn't come from a file, but reflects some other data base |
2794 for example, Dired buffers and buffer-list buffers. In these cases, | 2796 instead: for example, Dired buffers and buffer-list buffers. This is |
2795 it reconstructs the buffer contents from the appropriate data base. | 2797 implemented by having the modes set `revert-buffer-function'. |
2796 | 2798 |
2797 When called from Lisp, the first argument is IGNORE-AUTO; only offer | 2799 When called from Lisp, the first argument is IGNORE-AUTO; only offer |
2798 to revert from the auto-save file when this is nil. Note that the | 2800 to revert from the auto-save file when this is nil. Note that the |
2799 sense of this argument is the reverse of the prefix argument, for the | 2801 sense of this argument is the reverse of the prefix argument, for the |
2800 sake of backward compatibility. IGNORE-AUTO is optional, defaulting | 2802 sake of backward compatibility. IGNORE-AUTO is optional, defaulting |
2802 | 2804 |
2803 Optional second argument NOCONFIRM means don't ask for confirmation at | 2805 Optional second argument NOCONFIRM means don't ask for confirmation at |
2804 all. | 2806 all. |
2805 | 2807 |
2806 Optional third argument PRESERVE-MODES non-nil means don't alter | 2808 Optional third argument PRESERVE-MODES non-nil means don't alter |
2807 the files modes. Normally we reinitialize them using `normal-mode'. | 2809 the buffer's modes. Otherwise, reinitialize them using `normal-mode'. |
2808 | 2810 |
2809 If the value of `revert-buffer-function' is non-nil, it is called to | 2811 If the value of `revert-buffer-function' is non-nil, it is called to |
2810 do all the work for this command. Otherwise, the hooks | 2812 do all the work for this command. Otherwise, the hooks |
2811 `before-revert-hook' and `after-revert-hook' are run at the beginning | 2813 `before-revert-hook' and `after-revert-hook' are run at the beginning |
2812 and the end, and if `revert-buffer-insert-file-contents-function' is | 2814 and the end, and if `revert-buffer-insert-file-contents-function' is |
2813 non-nil, it is called instead of rereading visited file contents. | 2815 non-nil, it is called instead of rereading visited file contents. |
2814 | 2816 |
2815 If the buffer has not been obviously modified, and no auto-save file | 2817 If the buffer-modified flag is nil, and we are not reverting from an |
2816 exists, then `revert-buffer-internal' is | 2818 auto-save file, then compare the contents of the buffer and the file. |
2817 called. `revert-buffer-internal' will not actually change the buffer | 2819 Revert only if they differ." |
2818 at all if reversion would not cause any user-visible changes." | |
2819 | 2820 |
2820 ;; I admit it's odd to reverse the sense of the prefix argument, but | 2821 ;; I admit it's odd to reverse the sense of the prefix argument, but |
2821 ;; there is a lot of code out there which assumes that the first | 2822 ;; there is a lot of code out there which assumes that the first |
2822 ;; argument should be t to avoid consulting the auto-save file, and | 2823 ;; argument should be t to avoid consulting the auto-save file, and |
2823 ;; there's no straightforward way to encourage authors to notice a | 2824 ;; there's no straightforward way to encourage authors to notice a |
2966 (after-find-file nil nil t t t)) | 2967 (after-find-file nil nil t t t)) |
2967 (t t)) | 2968 (t t)) |
2968 t))))) | 2969 t))))) |
2969 | 2970 |
2970 (defun revert-buffer-internal (&optional file-name) | 2971 (defun revert-buffer-internal (&optional file-name) |
2972 "Read contents of FILE-NAME into a buffer, and compare to current buffer. | |
2973 Return nil if identical, and the new buffer if different." | |
2974 | |
2971 (let* ((newbuf (get-buffer-create " *revert*")) | 2975 (let* ((newbuf (get-buffer-create " *revert*")) |
2972 bmin bmax) | 2976 bmin bmax) |
2973 (save-excursion | 2977 (save-excursion |
2974 (set-buffer newbuf) | 2978 (set-buffer newbuf) |
2975 (with-obsolete-variable '(before-change-function after-change-function) | 2979 (with-obsolete-variable '(before-change-function after-change-function) |