comparison lisp/files.el @ 24925:5169ebe70135

(revert-buffer): Don't preserve point here. (revert-buffer-insert-file-contents-function): Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Mon, 05 Jul 1999 22:49:45 +0000
parents ccece04c47a1
children a51a012046c4
comparison
equal deleted inserted replaced
24924:ef8649234d91 24925:5169ebe70135
2655 2655
2656 (put 'revert-buffer-insert-file-contents-function 'permanent-local t) 2656 (put 'revert-buffer-insert-file-contents-function 'permanent-local t)
2657 (defvar revert-buffer-insert-file-contents-function nil 2657 (defvar revert-buffer-insert-file-contents-function nil
2658 "Function to use to insert contents when reverting this buffer. 2658 "Function to use to insert contents when reverting this buffer.
2659 Gets two args, first the nominal file name to use, 2659 Gets two args, first the nominal file name to use,
2660 and second, t if reading the auto-save file.") 2660 and second, t if reading the auto-save file.
2661
2662 The function you specify is responsible for updating (or preserving) point.")
2661 2663
2662 (defvar before-revert-hook nil 2664 (defvar before-revert-hook nil
2663 "Normal hook for `revert-buffer' to run before reverting. 2665 "Normal hook for `revert-buffer' to run before reverting.
2664 If `revert-buffer-function' is used to override the normal revert 2666 If `revert-buffer-function' is used to override the normal revert
2665 mechanism, this hook is not used.") 2667 mechanism, this hook is not used.")
2712 ;; reversal of the argument sense. So I'm just changing the user 2714 ;; reversal of the argument sense. So I'm just changing the user
2713 ;; interface, but leaving the programmatic interface the same. 2715 ;; interface, but leaving the programmatic interface the same.
2714 (interactive (list (not current-prefix-arg))) 2716 (interactive (list (not current-prefix-arg)))
2715 (if revert-buffer-function 2717 (if revert-buffer-function
2716 (funcall revert-buffer-function ignore-auto noconfirm) 2718 (funcall revert-buffer-function ignore-auto noconfirm)
2717 (let* ((opoint (point)) 2719 (let* ((auto-save-p (and (not ignore-auto)
2718 (auto-save-p (and (not ignore-auto)
2719 (recent-auto-save-p) 2720 (recent-auto-save-p)
2720 buffer-auto-save-file-name 2721 buffer-auto-save-file-name
2721 (file-readable-p buffer-auto-save-file-name) 2722 (file-readable-p buffer-auto-save-file-name)
2722 (y-or-n-p 2723 (y-or-n-p
2723 "Buffer has been auto-saved recently. Revert from auto-save file? "))) 2724 "Buffer has been auto-saved recently. Revert from auto-save file? ")))
2769 (let ((coding-system-for-read 2770 (let ((coding-system-for-read
2770 ;; Auto-saved file shoule be read without 2771 ;; Auto-saved file shoule be read without
2771 ;; any code conversion. 2772 ;; any code conversion.
2772 (if auto-save-p 'no-conversion 2773 (if auto-save-p 'no-conversion
2773 coding-system-for-read))) 2774 coding-system-for-read)))
2775 ;; Note that this preserves point in an intelligent way.
2774 (insert-file-contents file-name (not auto-save-p) 2776 (insert-file-contents file-name (not auto-save-p)
2775 nil nil t)))) 2777 nil nil t))))
2776 (goto-char (min opoint (point-max)))
2777 ;; Recompute the truename in case changes in symlinks 2778 ;; Recompute the truename in case changes in symlinks
2778 ;; have changed the truename. 2779 ;; have changed the truename.
2779 (setq buffer-file-truename 2780 (setq buffer-file-truename
2780 (abbreviate-file-name (file-truename buffer-file-name))) 2781 (abbreviate-file-name (file-truename buffer-file-name)))
2781 (after-find-file nil nil t t preserve-modes) 2782 (after-find-file nil nil t t preserve-modes)