From: Stefan Kangas <stefan@marxist.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: master 388a874 2/4: Do interactive mode tagging for man.el
Date: Sun, 21 Feb 2021 04:37:45 -0600 [thread overview]
Message-ID: <CADwFkmmRRvhbL1yFFx-tEcZ808sbpVJFqmDjEoDmbfrhVcHPrg@mail.gmail.com> (raw)
In-Reply-To: <87k0r3q65y.fsf@gnus.org>
[-- Attachment #1: Type: text/plain, Size: 515 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Stefan Kangas <stefan@marxist.se> writes:
>
>> 2) Introduce a new mode, `man-shared-mode', inheriting from
>> special-mode, that both `Man-mode' and `woman-mode' can inherit
>> from. Then tag the commands using that.
>
> I think that makes sense, and would have the additional effect of
> documenting, right in the Man-* command functions, that these aren't
> just used in man.el, which may be nice if somebody later alters the
> functions.
OK, here's a patch.
[-- Attachment #2: 0001-Fix-interactive-mode-tagging-for-man-and-woman.patch --]
[-- Type: text/x-diff, Size: 6943 bytes --]
From 583f66871145c60797f0b148f502d6e3516aff5a Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sun, 21 Feb 2021 11:19:57 +0100
Subject: [PATCH] Fix interactive mode tagging for man and woman
* lisp/man.el (man-shared-mode): New mode inheriting special-mode.
(Man-mode):
* lisp/woman.el (woman-mode): Inherit from man-shared-mode.
* 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-shared-mode.
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 70b8aa8eb2..2d8bf340b1 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1024,7 +1024,7 @@ man
;;;###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-shared-mode)
(if (or (not man-args)
(string= man-args ""))
(error "No item under point")
@@ -1143,7 +1143,7 @@ Man-getpage-in-background
(defun Man-update-manpage ()
"Reformat current manpage by calling the man command again synchronously."
- (interactive nil Man-mode)
+ (interactive nil man-shared-mode)
(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 @@ Man-softhyphen-to-minus
(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-shared-mode)
(goto-char (point-min))
;; Fontify ANSI escapes.
(let ((ansi-color-apply-face-function #'ansi-color-apply-text-property-face)
@@ -1355,7 +1355,7 @@ Man-cleanup-manpage
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-shared-mode)
(if (or interactive (not Man-sed-script))
(progn
(goto-char (point-min))
@@ -1527,7 +1527,14 @@ Man-page-from-arguments
(defvar bookmark-make-record-function)
-(define-derived-mode Man-mode special-mode "Man"
+(define-derived-mode man-shared-mode 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-shared-mode "Man"
"A mode for browsing Un*x manual pages.
The following man commands are available in the buffer. Try
@@ -1723,7 +1730,7 @@ Man-unindent
(defun Man-next-section (n)
"Move point to Nth next section (default 1)."
- (interactive "p" Man-mode)
+ (interactive "p" man-shared-mode)
(let ((case-fold-search nil)
(start (point)))
(if (looking-at Man-heading-regexp)
@@ -1739,7 +1746,7 @@ Man-next-section
(defun Man-previous-section (n)
"Move point to Nth previous section (default 1)."
- (interactive "p" Man-mode)
+ (interactive "p" man-shared-mode)
(let ((case-fold-search nil))
(if (looking-at Man-heading-regexp)
(forward-line -1))
@@ -1771,7 +1778,7 @@ Man-goto-section
(chosen (completing-read prompt Man--sections
nil nil nil nil default)))
(list chosen))
- Man-mode)
+ man-shared-mode)
(setq Man--last-section section)
(unless (Man-find-section section)
(error "Section %s not found" section)))
@@ -1780,7 +1787,7 @@ Man-goto-section
(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-shared-mode)
(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 @@ Man-follow-manual-reference
(chosen (completing-read prompt Man--refpages
nil nil nil nil defaults)))
chosen)))
- Man-mode)
+ man-shared-mode)
(if (not Man--refpages)
(error "Can't find any references in the current manpage")
(setq Man--last-refpage reference)
@@ -1844,7 +1851,7 @@ Man-follow-manual-reference
(defun Man-kill ()
"Kill the buffer containing the manpage."
- (interactive nil Man-mode)
+ (interactive nil man-shared-mode)
(quit-window t))
(defun Man-goto-page (page &optional noerror)
@@ -1856,7 +1863,7 @@ Man-goto-page
(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-shared-mode)
(if (and (not Man-page-list) (not noerror))
(error "Not a man page buffer"))
(when Man-page-list
@@ -1878,7 +1885,7 @@ Man-goto-page
(defun Man-next-manpage ()
"Find the next manpage entry in the buffer."
- (interactive nil Man-mode)
+ (interactive nil man-shared-mode)
(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 @@ Man-next-manpage
(defun Man-previous-manpage ()
"Find the previous manpage entry in the buffer."
- (interactive nil Man-mode)
+ (interactive nil man-shared-mode)
(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 98f1a47d24..0cd72cb261 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1856,13 +1856,15 @@ woman-reset-emulation
(defvar bookmark-make-record-function)
-(define-derived-mode woman-mode special-mode "WoMan"
+(define-derived-mode woman-mode man-shared-mode "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-shared-mode' 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))
--
2.30.0
next prev parent reply other threads:[~2021-02-21 10:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 15:56 master 388a874 2/4: Do interactive mode tagging for man.el Eli Zaretskii
2021-02-20 2:24 ` Stefan Kangas
2021-02-20 7:39 ` Eli Zaretskii
2021-02-20 12:26 ` Lars Ingebrigtsen
2021-02-20 12:56 ` Eli Zaretskii
2021-02-20 12:23 ` Lars Ingebrigtsen
2021-02-21 10:37 ` Stefan Kangas [this message]
2021-02-21 15:48 ` Lars Ingebrigtsen
2021-02-21 19:18 ` Stefan Kangas
2021-02-21 17:43 ` Eli Zaretskii
2021-02-21 19:03 ` Stefan Kangas
2021-02-22 22:34 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADwFkmmRRvhbL1yFFx-tEcZ808sbpVJFqmDjEoDmbfrhVcHPrg@mail.gmail.com \
--to=stefan@marxist.se \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).