aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2008-01-12 17:17:41 +0000
committerEli Zaretskii2008-01-12 17:17:41 +0000
commitdd18f44f3b00001171e7b98b8ca5a8b036e337f2 (patch)
tree68f22c713d15130d0032b3d8dcb8b1cd1a966a3a
parent48d93bebd51abdfd8d70c74d3c03bcbc2e3bb036 (diff)
downloademacs-dd18f44f3b00001171e7b98b8ca5a8b036e337f2.tar.gz
emacs-dd18f44f3b00001171e7b98b8ca5a8b036e337f2.zip
(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/ChangeLog2
-rw-r--r--lisp/view.el14
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 @@
2 2
3 * view.el (view-file-other-window, view-file-other-frame): Don't 3 * view.el (view-file-other-window, view-file-other-frame): Don't
4 kill the buffer if it is modified. Doc fixes. 4 kill the buffer if it is modified. Doc fixes.
5 (kill-buffer-if-not-modified): New function.
6 (view-file): Don't kill the buffer if it is modified.
5 7
6 * progmodes/ebrowse.el (ebrowse-view-file-other-window): Delete 8 * progmodes/ebrowse.el (ebrowse-view-file-other-window): Delete
7 function. 9 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.")
238 238
239;;; Commands that enter or exit view mode. 239;;; Commands that enter or exit view mode.
240 240
241(defun kill-buffer-if-not-modified (buf)
242 "Like `kill-buffer', but does nothing if the buffer is modified."
243 (let ((buf (or (bufferp buf) (get-buffer buf))))
244 (and buf (not (buffer-modified-p buf))
245 (kill-buffer buf))))
246
241;;;###autoload 247;;;###autoload
242(defun view-file (file) 248(defun view-file (file)
243 "View FILE in View mode, returning to previous buffer when done. 249 "View FILE in View mode, returning to previous buffer when done.
@@ -258,7 +264,7 @@ This command runs the normal hook `view-mode-hook'."
258 (progn 264 (progn
259 (switch-to-buffer buffer) 265 (switch-to-buffer buffer)
260 (message "Not using View mode because the major mode is special")) 266 (message "Not using View mode because the major mode is special"))
261 (view-buffer buffer (and (not had-a-buf) 'kill-buffer))))) 267 (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified)))))
262 268
263;;;###autoload 269;;;###autoload
264(defun view-file-other-window (file) 270(defun view-file-other-window (file)
@@ -279,8 +285,7 @@ This command runs the normal hook `view-mode-hook'."
279 (buf-to-view (find-file-noselect file))) 285 (buf-to-view (find-file-noselect file)))
280 (view-buffer-other-window buf-to-view nil 286 (view-buffer-other-window buf-to-view nil
281 (and (not had-a-buf) 287 (and (not had-a-buf)
282 (not (buffer-modified-p buf-to-view)) 288 'kill-buffer-if-not-modified))))
283 'kill-buffer))))
284 289
285;;;###autoload 290;;;###autoload
286(defun view-file-other-frame (file) 291(defun view-file-other-frame (file)
@@ -302,8 +307,7 @@ This command runs the normal hook `view-mode-hook'."
302 (buf-to-view (find-file-noselect file))) 307 (buf-to-view (find-file-noselect file)))
303 (view-buffer-other-frame buf-to-view nil 308 (view-buffer-other-frame buf-to-view nil
304 (and (not had-a-buf) 309 (and (not had-a-buf)
305 (not (buffer-modified-p buf-to-view)) 310 'kill-buffer-if-not-modified))))
306 'kill-buffer))))
307 311
308 312
309;;;###autoload 313;;;###autoload