diff options
author | Eli Zaretskii <eliz@gnu.org> | 2008-01-12 17:17:41 +0000 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2008-01-12 17:17:41 +0000 |
commit | dd18f44f3b00001171e7b98b8ca5a8b036e337f2 (patch) | |
tree | 68f22c713d15130d0032b3d8dcb8b1cd1a966a3a | |
parent | 48d93bebd51abdfd8d70c74d3c03bcbc2e3bb036 (diff) | |
download | emacs-dd18f44f3b00001171e7b98b8ca5a8b036e337f2.tar.gz |
(view-file-other-window, view-file-other-frame): Fix last change.
(kill-buffer-if-not-modified): New function.
(view-file): Don't kill the buffer if it is modified.
-rw-r--r-- | lisp/ChangeLog | 2 | ||||
-rw-r--r-- | lisp/view.el | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b86777131eb..ef40bc36c9e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,8 @@ * view.el (view-file-other-window, view-file-other-frame): Don't kill the buffer if it is modified. Doc fixes. + (kill-buffer-if-not-modified): New function. + (view-file): Don't kill the buffer if it is modified. * progmodes/ebrowse.el (ebrowse-view-file-other-window): Delete function. diff --git a/lisp/view.el b/lisp/view.el index d2a7d5c9b44..bdf7f6a5728 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -238,6 +238,12 @@ This is local in each buffer, once it is used.") ;;; Commands that enter or exit view mode. +(defun kill-buffer-if-not-modified (buf) + "Like `kill-buffer', but does nothing if the buffer is modified." + (let ((buf (or (bufferp buf) (get-buffer buf)))) + (and buf (not (buffer-modified-p buf)) + (kill-buffer buf)))) + ;;;###autoload (defun view-file (file) "View FILE in View mode, returning to previous buffer when done. @@ -258,7 +264,7 @@ This command runs the normal hook `view-mode-hook'." (progn (switch-to-buffer buffer) (message "Not using View mode because the major mode is special")) - (view-buffer buffer (and (not had-a-buf) 'kill-buffer))))) + (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified))))) ;;;###autoload (defun view-file-other-window (file) @@ -279,8 +285,7 @@ This command runs the normal hook `view-mode-hook'." (buf-to-view (find-file-noselect file))) (view-buffer-other-window buf-to-view nil (and (not had-a-buf) - (not (buffer-modified-p buf-to-view)) - 'kill-buffer)))) + 'kill-buffer-if-not-modified)))) ;;;###autoload (defun view-file-other-frame (file) @@ -302,8 +307,7 @@ This command runs the normal hook `view-mode-hook'." (buf-to-view (find-file-noselect file))) (view-buffer-other-frame buf-to-view nil (and (not had-a-buf) - (not (buffer-modified-p buf-to-view)) - 'kill-buffer)))) + 'kill-buffer-if-not-modified)))) ;;;###autoload |