From: Kan-Ru Chen Date: Sat, 18 Sep 2010 01:25:31 +0000 (-0400) Subject: * textmodes/nroff-mode.el (nroff-view): Kill old buffer before refreshing the preview... X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~47^2~99 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dbbd7ad43914c269bee90e1d6c08185dc2bdf7a5;p=emacs.git * textmodes/nroff-mode.el (nroff-view): Kill old buffer before refreshing the preview buffer. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 653822a86fd..ccc0531778a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-14 Kan-Ru Chen (tiny change) + + * textmodes/nroff-mode.el (nroff-view): Kill old buffer before + refreshing the preview buffer. + 2010-09-18 Stefan Monnier * textmodes/tex-mode.el (tex-syntax-propertize-rules) diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el index 14b0b106bb3..52538064053 100644 --- a/lisp/textmodes/nroff-mode.el +++ b/lisp/textmodes/nroff-mode.el @@ -311,10 +311,16 @@ turns it on if arg is positive, otherwise off." "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")