Mercurial > emacs
comparison lisp/files.el @ 11982:a88f862b3927
(revert-buffer): Save after-revert-hook (both local and
global values) before reverting, and run the saved values at the end.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 29 May 1995 06:59:26 +0000 |
parents | 405d4e500223 |
children | ea774a7c610c |
comparison
equal
deleted
inserted
replaced
11981:405d4e500223 | 11982:a88f862b3927 |
---|---|
2003 (not (verify-visited-file-modtime (current-buffer))) | 2003 (not (verify-visited-file-modtime (current-buffer))) |
2004 (setq buffer-backed-up nil)) | 2004 (setq buffer-backed-up nil)) |
2005 ;; Get rid of all undo records for this buffer. | 2005 ;; Get rid of all undo records for this buffer. |
2006 (or (eq buffer-undo-list t) | 2006 (or (eq buffer-undo-list t) |
2007 (setq buffer-undo-list nil)) | 2007 (setq buffer-undo-list nil)) |
2008 (let ((buffer-read-only nil) | 2008 ;; Effectively copy the after-revert-hook status, |
2009 ;; Don't make undo records for the reversion. | 2009 ;; since after-find-file will clobber it. |
2010 (buffer-undo-list t)) | 2010 (let ((global-hook (default-value 'after-revert-hook)) |
2011 (if revert-buffer-insert-file-contents-function | 2011 (local-hook-p (local-variable-p 'after-revert-hook)) |
2012 (funcall revert-buffer-insert-file-contents-function | 2012 (local-hook (and (local-variable-p 'after-revert-hook) |
2013 file-name auto-save-p) | 2013 after-revert-hook))) |
2014 (if (not (file-exists-p file-name)) | 2014 (let (buffer-read-only |
2015 (error "File %s no longer exists!" file-name)) | 2015 ;; Don't make undo records for the reversion. |
2016 ;; Bind buffer-file-name to nil | 2016 (buffer-undo-list t)) |
2017 ;; so that we don't try to lock the file. | 2017 (if revert-buffer-insert-file-contents-function |
2018 (let ((buffer-file-name nil)) | 2018 (funcall revert-buffer-insert-file-contents-function |
2019 (or auto-save-p | 2019 file-name auto-save-p) |
2020 (unlock-buffer))) | 2020 (if (not (file-exists-p file-name)) |
2021 (widen) | 2021 (error "File %s no longer exists!" file-name)) |
2022 (insert-file-contents file-name (not auto-save-p) | 2022 ;; Bind buffer-file-name to nil |
2023 nil nil t))) | 2023 ;; so that we don't try to lock the file. |
2024 (goto-char (min opoint (point-max))) | 2024 (let ((buffer-file-name nil)) |
2025 ;; Recompute the truename in case changes in symlinks | 2025 (or auto-save-p |
2026 ;; have changed the truename. | 2026 (unlock-buffer))) |
2027 (setq buffer-file-truename | 2027 (widen) |
2028 (abbreviate-file-name (file-truename buffer-file-name))) | 2028 (insert-file-contents file-name (not auto-save-p) |
2029 (after-find-file nil nil t t) | 2029 nil nil t))) |
2030 (run-hooks 'after-revert-hook) | 2030 (goto-char (min opoint (point-max))) |
2031 ;; Recompute the truename in case changes in symlinks | |
2032 ;; have changed the truename. | |
2033 (setq buffer-file-truename | |
2034 (abbreviate-file-name (file-truename buffer-file-name))) | |
2035 (after-find-file nil nil t t) | |
2036 ;; Run after-revert-hook as it was before we reverted. | |
2037 (setq-default revert-buffer-internal-hook global-hook) | |
2038 (if local-hook-p | |
2039 (progn | |
2040 (make-local-variable 'revert-buffer-internal-hook) | |
2041 (setq revert-buffer-internal-hook local-hook)) | |
2042 (kill-local-variable 'revert-buffer-internal-hook)) | |
2043 (run-hooks 'revert-buffer-internal-hook)) | |
2031 t))))) | 2044 t))))) |
2032 | 2045 |
2033 (defun recover-file (file) | 2046 (defun recover-file (file) |
2034 "Visit file FILE, but get contents from its last auto-save file." | 2047 "Visit file FILE, but get contents from its last auto-save file." |
2035 ;; Actually putting the file name in the minibuffer should be used | 2048 ;; Actually putting the file name in the minibuffer should be used |