emacs-diffs
[Top][All Lists]
Advanced

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

master ff759b1: Fix interactive mode tagging for man and woman


From: Stefan Kangas
Subject: master ff759b1: Fix interactive mode tagging for man and woman
Date: Sun, 21 Feb 2021 14:14:47 -0500 (EST)

branch: master
commit ff759b1d0a901e5408a9dfea6c6bc77d1ae1dbf3
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Fix interactive mode tagging for man and woman
    
    * lisp/man.el (man-common): New mode inheriting special-mode.
    (Man-mode):
    * lisp/woman.el (woman-mode): Inherit from man-common.
    
    * lisp/man.el (man-follow, Man-update-manpage)
    (Man-fontify-manpage, Man-cleanup-manpage, Man-next-section)
    (Man-previous-section, Man-goto-section)
    (Man-goto-see-also-section, Man-follow-manual-reference)
    (Man-kill, Man-goto-page, Man-next-manpage)
    (Man-previous-manpage): Change interactive mode tag to man-common.
    
    This was discussed in:
    https://lists.gnu.org/r/emacs-devel/2021-02/msg01619.html
---
 lisp/man.el   | 35 +++++++++++++++++++++--------------
 lisp/woman.el |  4 +++-
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/lisp/man.el b/lisp/man.el
index 70b8aa8..abb9bba 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1024,7 +1024,7 @@ to auto-complete your input based on the installed manual 
pages."
 ;;;###autoload
 (defun man-follow (man-args)
   "Get a Un*x manual page of the item under point and put it in a buffer."
-  (interactive (list (Man-default-man-entry)) Man-mode)
+  (interactive (list (Man-default-man-entry)) man-common)
   (if (or (not man-args)
          (string= man-args ""))
       (error "No item under point")
@@ -1143,7 +1143,7 @@ Return the buffer in which the manpage will appear."
 
 (defun Man-update-manpage ()
   "Reformat current manpage by calling the man command again synchronously."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (when (eq Man-arguments nil)
     ;;this shouldn't happen unless it is not in a Man buffer."
     (error "Man-arguments not initialized"))
@@ -1239,7 +1239,7 @@ See the variable `Man-notify-method' for the different 
notification behaviors."
 (defun Man-fontify-manpage ()
   "Convert overstriking and underlining to the correct fonts.
 Same for the ANSI bold and normal escape sequences."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (goto-char (point-min))
   ;; Fontify ANSI escapes.
   (let ((ansi-color-apply-face-function #'ansi-color-apply-text-property-face)
@@ -1355,7 +1355,7 @@ default type, `Man-xref-man-page' is used for the 
buttons."
 Normally skip any jobs that should have been done by the sed script,
 but when called interactively, do those jobs even if the sed
 script would have done them."
-  (interactive "p" Man-mode)
+  (interactive "p" man-common)
   (if (or interactive (not Man-sed-script))
       (progn
        (goto-char (point-min))
@@ -1527,7 +1527,14 @@ manpage command."
 
 (defvar bookmark-make-record-function)
 
-(define-derived-mode Man-mode special-mode "Man"
+(define-derived-mode man-common special-mode "Man Shared"
+  "Parent mode for `Man-mode' like modes.
+This mode is here to be inherited by modes that need to use
+commands from `Man-mode'.  Used by `woman'.
+(In itself, this mode currently does nothing.)"
+  :interactive nil)
+
+(define-derived-mode Man-mode man-common "Man"
   "A mode for browsing Un*x manual pages.
 
 The following man commands are available in the buffer.  Try
@@ -1723,7 +1730,7 @@ The following key bindings are currently in effect in the 
buffer:
 
 (defun Man-next-section (n)
   "Move point to Nth next section (default 1)."
-  (interactive "p" Man-mode)
+  (interactive "p" man-common)
   (let ((case-fold-search nil)
         (start (point)))
     (if (looking-at Man-heading-regexp)
@@ -1739,7 +1746,7 @@ The following key bindings are currently in effect in the 
buffer:
 
 (defun Man-previous-section (n)
   "Move point to Nth previous section (default 1)."
-  (interactive "p" Man-mode)
+  (interactive "p" man-common)
   (let ((case-fold-search nil))
     (if (looking-at Man-heading-regexp)
        (forward-line -1))
@@ -1771,7 +1778,7 @@ Returns t if section is found, nil otherwise."
           (chosen (completing-read prompt Man--sections
                                    nil nil nil nil default)))
      (list chosen))
-   Man-mode)
+   man-common)
   (setq Man--last-section section)
   (unless (Man-find-section section)
     (error "Section %s not found" section)))
@@ -1780,7 +1787,7 @@ Returns t if section is found, nil otherwise."
 (defun Man-goto-see-also-section ()
   "Move point to the \"SEE ALSO\" section.
 Actually the section moved to is described by `Man-see-also-regexp'."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (if (not (Man-find-section Man-see-also-regexp))
       (error "%s" (concat "No " Man-see-also-regexp
                     " section found in the current manpage"))))
@@ -1835,7 +1842,7 @@ Specify which REFERENCE to use; default is based on word 
at point."
             (chosen (completing-read prompt Man--refpages
                                      nil nil nil nil defaults)))
         chosen)))
-   Man-mode)
+   man-common)
   (if (not Man--refpages)
       (error "Can't find any references in the current manpage")
     (setq Man--last-refpage reference)
@@ -1844,7 +1851,7 @@ Specify which REFERENCE to use; default is based on word 
at point."
 
 (defun Man-kill ()
   "Kill the buffer containing the manpage."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (quit-window t))
 
 (defun Man-goto-page (page &optional noerror)
@@ -1856,7 +1863,7 @@ Specify which REFERENCE to use; default is based on word 
at point."
         (error "You're looking at the only manpage in the buffer")
        (list (read-minibuffer (format "Go to manpage [1-%d]: "
                                       (length Man-page-list))))))
-    Man-mode)
+    man-common)
   (if (and (not Man-page-list) (not noerror))
       (error "Not a man page buffer"))
   (when Man-page-list
@@ -1878,7 +1885,7 @@ Specify which REFERENCE to use; default is based on word 
at point."
 
 (defun Man-next-manpage ()
   "Find the next manpage entry in the buffer."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (if (= (length Man-page-list) 1)
       (error "This is the only manpage in the buffer"))
   (if (< Man-current-page (length Man-page-list))
@@ -1889,7 +1896,7 @@ Specify which REFERENCE to use; default is based on word 
at point."
 
 (defun Man-previous-manpage ()
   "Find the previous manpage entry in the buffer."
-  (interactive nil Man-mode)
+  (interactive nil man-common)
   (if (= (length Man-page-list) 1)
       (error "This is the only manpage in the buffer"))
   (if (> Man-current-page 1)
diff --git a/lisp/woman.el b/lisp/woman.el
index 98f1a47..d4f7e8c 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1856,13 +1856,15 @@ Argument EVENT is the invoking mouse event."
 
 (defvar bookmark-make-record-function)
 
-(define-derived-mode woman-mode special-mode "WoMan"
+(define-derived-mode woman-mode man-common "WoMan"
   "Turn on (most of) Man mode to browse a buffer formatted by WoMan.
 WoMan is an ELisp emulation of much of the functionality of the Emacs
 `man' command running the standard UN*X man and ?roff programs.
 WoMan author: F.J.Wright@Maths.QMW.ac.uk
 See `Man-mode' for additional details.
 \\{woman-mode-map}"
+  ;; FIXME: Should all this just be re-arranged so that this can just
+  ;; inherit `man-common' and be done with it?
   (let ((Man-build-page-list (symbol-function 'Man-build-page-list))
        (Man-strip-page-headers (symbol-function 'Man-strip-page-headers))
        (Man-unindent (symbol-function 'Man-unindent))



reply via email to

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