]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/nroff-mode.el
Update copyright year to 2016
[gnu-emacs] / lisp / textmodes / nroff-mode.el
index 14b0b106bb3fd90a9696c2eaa3af984106c4a9a7..b064f6d2b3136003f2b48f1a16c4c48572206040 100644 (file)
@@ -1,9 +1,9 @@
 ;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source
 
-;; Copyright (C) 1985, 1986, 1994, 1995, 1997, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2016 Free Software
+;; Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: wp
 
 ;; This file is part of GNU Emacs.
@@ -297,11 +297,17 @@ automatically inserts the matching closing request after point."
       (forward-char 1))))
 
 (define-minor-mode nroff-electric-mode
-  "Toggle `nroff-electric-newline' minor mode.
-`nroff-electric-newline' forces Emacs to check for an nroff request at the
-beginning of the line, and insert the matching closing request if necessary.
-This command toggles that mode (off->on, on->off), with an argument,
-turns it on if arg is positive, otherwise off."
+  "Toggle automatic nroff request pairing (Nroff Electric mode).
+With a prefix argument ARG, enable Nroff Electric mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+Nroff Electric mode is a buffer-local minor mode, for use with
+`nroff-mode'.  When enabled, Emacs checks for an nroff request at
+the beginning of the line, and inserts the matching closing
+request if necessary.  This command toggles that mode (off->on,
+on->off), with an argument, turns it on if arg is positive,
+otherwise off."
   :lighter " Electric"
   (or (derived-mode-p 'nroff-mode) (error "Must be in nroff mode")))
 
@@ -311,10 +317,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")
@@ -325,5 +337,4 @@ turns it on if arg is positive, otherwise off."
 
 (provide 'nroff-mode)
 
-;; arch-tag: 6e276340-6c65-4f65-b4e3-0ca431ddfb6c
 ;;; nroff-mode.el ends here