changeset 110404:afd1f9799297

* textmodes/nroff-mode.el (nroff-view): Kill old buffer before refreshing the preview buffer.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 17 Sep 2010 21:25:31 -0400
parents 14dab55b2888
children 0abd5adc0fae
files lisp/ChangeLog lisp/textmodes/nroff-mode.el
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Sep 18 02:35:00 2010 +0200
+++ b/lisp/ChangeLog	Fri Sep 17 21:25:31 2010 -0400
@@ -1,3 +1,8 @@
+2010-09-14  Kan-Ru Chen  <kanru@kanru.info>  (tiny change)
+
+	* textmodes/nroff-mode.el (nroff-view): Kill old buffer before
+	refreshing the preview buffer.
+
 2010-09-18  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* textmodes/tex-mode.el (tex-syntax-propertize-rules)
--- a/lisp/textmodes/nroff-mode.el	Sat Sep 18 02:35:00 2010 +0200
+++ b/lisp/textmodes/nroff-mode.el	Fri Sep 17 21:25:31 2010 -0400
@@ -311,10 +311,16 @@
   "Run man on this file."
   (interactive)
   (require 'man)
-  (let* ((file (buffer-file-name)))
-    (if file
-	(Man-getpage-in-background file)
-      (error "No associated file for the current buffer"))))
+  (let* ((file (buffer-file-name))
+	 (viewbuf (get-buffer (concat "*Man " file "*"))))
+    (unless file
+      (error "Buffer is not associated with any file"))
+    (and (buffer-modified-p)
+	 (y-or-n-p (format "Save buffer %s first? " (buffer-name)))
+	 (save-buffer))
+    (if viewbuf
+	(kill-buffer viewbuf))
+    (Man-getpage-in-background file)))
 
 ;; Old names that were not namespace clean.
 (define-obsolete-function-alias 'count-text-lines 'nroff-count-text-lines "22.1")