From: Masatake YAMATO <jet@gyve.org>
Cc: emacs-devel@gnu.org
Subject: |PATCH| describe-minor-mode and describe-minor-mode-from-indicator
Date: Sat, 18 Jan 2003 16:35:43 +0900 (JST) [thread overview]
Message-ID: <20030118.163543.59461489.jet@gyve.org> (raw)
Dear, Stefan Monnier
(I found your name on the MAINTAINERS file as a developer
who has interests on minor-mode/major-mode infrastructure.
So I've put your name to To: field of this mail.)
I've created a prototype of describe-minor-mode.
Background: Few days ago, I found a strange string
on mode-line: "doe". I wonder what is "doe". However,
I cannot find a way to know what is doe. M-x describe-mode
tells me nothing about doe. Finally I have to do
"grep doe emacs/lisp/*.el".
What I did:
I think we need something help
functions for minor mode. I wrote 3 things:
1. M-x describe-minor-mode
The user of describe-minor-mode can give its argument
with completion. The completion table is built from the
name of minor modes activated on the current buffer.
2. M-x describe-minor-mode-from-indicator
Almost the same as describe-minor-mode but the user
can pass an indicator instead of minor mode name to
get help. I could not implment completion.
(You will be not satisfied with "without completion".)
3. I added "Describe `MinorMode'" menu item to "Minor Modes"
popup menu. The user can get help about a minor mode with mouse-3.
I believe these functions helps beginner of Emacs. In other word
the user might be confused with strange minor mode strings.
Regards,
Masatake YAMATO
Index: help.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help.el,v
retrieving revision 1.255
diff -u -r1.255 help.el
--- help.el 13 Jan 2003 08:04:46 -0000 1.255
+++ help.el 18 Jan 2003 08:19:27 -0000
@@ -611,6 +611,20 @@
(setq minor-modes (cdr minor-modes))))
(print-help-return-message))))
+(defun describe-minor-mode (minor-mode)
+ "Display documentation of a minor mode given as MINOR-MODE."
+ (interactive (list (intern (completing-read
+ "Minor mode: "
+ (delete nil (mapcar
+ (function (lambda (x)
+ (if (eval (car x))
+ (list (symbol-name (car x))))))
+ minor-mode-alist))))))
+ (if (fboundp minor-mode)
+ (describe-function minor-mode)
+ (describe-variable minor-mode)))
+
+
\f
;;; Automatic resizing of temporary buffers.
Index: bindings.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.112
diff -u -r1.112 bindings.el
--- bindings.el 21 Dec 2002 20:19:37 -0000 1.112
+++ bindings.el 18 Jan 2003 08:19:28 -0000
@@ -376,6 +376,14 @@
"Return the value of symbol VAR if it is bound, else nil."
`(and (boundp (quote ,var)) ,var))
+
+(define-key mode-line-mode-menu [describe-minor-mode]
+ `(menu-item ,'(format "Describe `%s'"
+ (substring mode-line-mode-menu-grab-mode-indicator 1))
+ (lambda () (interactive) (describe-minor-mode-from-indicator))
+ :visible (and mode-line-mode-menu-grab-mode-indicator
+ (string= " " (substring mode-line-mode-menu-grab-mode-indicator 0 1)))))
+
(define-key mode-line-mode-menu [overwrite-mode]
`(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
:button (:toggle . overwrite-mode)))
@@ -413,9 +421,49 @@
`(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode
:button (:toggle . abbrev-mode)))
+(defun get-mode-indicator-from-event (event)
+ (car (nth 4 (car (cdr event)))))
+(defvar mode-line-mode-menu-grab-mode-indicator nil)
+
(defun mode-line-mode-menu (event)
(interactive "@e")
+ (setq mode-line-mode-menu-grab-mode-indicator (get-mode-indicator-from-event event))
(x-popup-menu event mode-line-mode-menu))
+
+(defun describe-minor-mode-from-indicator (&optional indicator)
+ "Display documentation of a minor mode specified by INDICATOR."
+ (interactive "sIndicator: ")
+ (unless indicator
+ (setq indicator mode-line-mode-menu-grab-mode-indicator))
+ (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
+ (if minor-mode
+ (describe-minor-mode minor-mode)
+ (message "Cannot find minor mode for `%s'" indicator))))
+
+(defun lookup-minor-mode-from-indicator (indicator)
+ "Return a minor mode symbol from its indicator on the modeline."
+ (if (and (< 0 (length indicator))
+ (not (string= " " (substring indicator 0 1))))
+ (setq indicator (concat " " indicator)))
+ (let ((minor-modes minor-mode-alist)
+ result)
+ (while minor-modes
+ (let* ((minor-mode (car (car minor-modes)))
+ (anindicator (car (cdr (car minor-modes)))))
+ (while (and anindicator (symbolp anindicator)
+ (boundp anindicator)
+ (not (eq anindicator (symbol-value anindicator))))
+ (setq anindicator (symbol-value anindicator)))
+ (if (and (consp anindicator)
+ (keywordp (car anindicator))
+ (eq :eval (car anindicator)))
+ (setq anindicator (eval (cadr anindicator))))
+ (if (and (stringp anindicator)
+ (string= anindicator indicator))
+ (setq result minor-mode
+ minor-modes nil)
+ (setq minor-modes (cdr minor-modes)))))
+ result))
;; Add menu of buffer operations to the buffer identification part
;; of the mode line.or header line.
next reply other threads:[~2003-01-18 7:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-18 7:35 Masatake YAMATO [this message]
2003-01-18 14:12 ` |PATCH| describe-minor-mode and describe-minor-mode-from-indicator Masatake YAMATO
2003-01-20 0:49 ` Richard Stallman
2003-01-20 16:06 ` Masatake YAMATO
2003-01-21 6:00 ` Masatake YAMATO
2003-01-22 9:59 ` Richard Stallman
2003-01-23 17:40 ` Masatake YAMATO
2003-01-25 19:23 ` Richard Stallman
2003-01-30 16:04 ` Masatake YAMATO
[not found] ` <E18eghV-0000MM-00@fencepost.gnu.org>
2003-03-30 7:51 ` Masatake YAMATO
2003-03-31 15:51 ` Stefan Monnier
2003-03-31 16:35 ` Masatake YAMATO
2003-03-31 17:14 ` Stefan Monnier
2003-04-01 9:38 ` Richard Stallman
2003-04-01 12:27 ` Masatake YAMATO
2003-04-01 12:58 ` Masatake YAMATO
2003-04-02 9:19 ` Richard Stallman
2003-04-07 15:46 ` Masatake YAMATO
2003-04-08 2:30 ` Richard Stallman
2003-04-10 8:36 ` Masatake YAMATO
2003-04-10 13:21 ` Stefan Monnier
2003-04-11 8:51 ` Richard Stallman
2003-04-11 19:30 ` Masatake YAMATO
2003-04-12 17:08 ` Richard Stallman
2003-04-02 9:18 ` Richard Stallman
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030118.163543.59461489.jet@gyve.org \
--to=jet@gyve.org \
--cc=emacs-devel@gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.