bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6219: Lauching nroff command from nroff-mode


From: Masatake YAMATO
Subject: bug#6219: Lauching nroff command from nroff-mode
Date: Wed, 19 May 2010 19:32:47 +0900 (JST)

This is not a bug report. This a request to review a patch to
include the official emacs source tree.

This patch provides the way to nroff-mode user to preview one's
document quickly.

2010-04-04  Masatake YAMATO  <yamato@redhat.com>

        * textmodes/nroff-mode.el (nroff-preview-as-man-page): Add new function.
        (nroff-mode-map): Put `nroff-preview-as-man-page' to the key map and
        menu map.

=== modified file 'lisp/textmodes/nroff-mode.el'
--- lisp/textmodes/nroff-mode.el        2010-01-13 08:35:10 +0000
+++ lisp/textmodes/nroff-mode.el        2010-04-04 21:14:58 +0000
@@ -55,6 +55,7 @@
     (define-key map "\n"  'nroff-electric-newline)
     (define-key map "\en" 'nroff-forward-text-line)
     (define-key map "\ep" 'nroff-backward-text-line)
+    (define-key map "\C-c\C-c" 'nroff-preview-as-man-page)
     (define-key map [menu-bar nroff-mode] (cons "Nroff" menu-map))
     (define-key menu-map [nn]
       '(menu-item "Newline" nroff-electric-newline
@@ -73,6 +74,9 @@
                  nroff-electric-mode
                  :help "Auto insert closing requests if necessary"
                  :button (:toggle . nroff-electric-mode)))
+    (define-key menu-map [npm]
+      '(menu-item "Preview as man page" nroff-preview-as-man-page
+                 :help "Run man on this file."))
     map)
   "Major mode keymap for `nroff-mode'.")
 
@@ -301,6 +305,15 @@
   :lighter " Electric"
   (or (derived-mode-p 'nroff-mode) (error "Must be in nroff mode")))
 
+(defun nroff-preview-as-man-page ()
+  "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"))))
+        
 ;; Old names that were not namespace clean.
 (define-obsolete-function-alias 'count-text-lines 'nroff-count-text-lines 
"22.1")
 (define-obsolete-function-alias 'forward-text-line 'nroff-forward-text-line 
"22.1")






reply via email to

[Prev in Thread] Current Thread [Next in Thread]