From: Masatake YAMATO <jet@gyve.org>
Cc: emacs-devel@gnu.org
Subject: Re: |PATCH| describe-minor-mode and describe-minor-mode-from-indicator
Date: Sun, 30 Mar 2003 16:51:24 +0900 (JST) [thread overview]
Message-ID: <20030330.165124.126582929.jet@gyve.org> (raw)
In-Reply-To: <E18eghV-0000MM-00@fencepost.gnu.org>
(Two months ago, my patch is reviewd by RMS and I got comments about help
for minor modes. I could not find time to improve. Now I do.)
This patch provides functions that:
1. you can get help for current selected major mode and minor modes
with clicking major and minor modes string on the mode line.
2. M-x describe-minor-mode, help for a specified minor mode like
M-x describe-mode.
Review results(summary):
I used popup menu to invoke describe-mode and describe-minor-mode.
RMS gave me a comment that I should use mouse-2 and help-echo instead
of popup menu. Here I did.
Masatake YAMATO
2003-03-30 Masatake YAMATO <jet@gyve.org>
* bindings.el (mode-line-major-mode-keymap): New variable.
(mode-line-minor-mode-help): New function. bound to
mode-line-minor-mode-keymap.
(mode-line-modes): split mode-line-mode definitions to
mode-name, mode-line-process and minor-mode-alist.
For mode-name, mode-line-major-mode-keymap is used.
* help.el (describe-minor-mode):
(describe-minor-mode-from-indicator):
(lookup-minor-mode-from-indicator): New functions.
Index: help.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help.el,v
retrieving revision 1.257
diff -u -r1.257 help.el
--- help.el 12 Feb 2003 23:13:43 -0000 1.257
+++ help.el 30 Mar 2003 08:13:16 -0000
@@ -611,6 +611,74 @@
(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))
+ (symbol-name (car x)))))
+ minor-mode-alist))))))
+ (if (fboundp minor-mode)
+ (describe-function minor-mode)
+ (describe-variable minor-mode)))
+
+(defun describe-minor-mode-from-indicator (indicator)
+ "Display documentation of a minor mode specified by INDICATOR."
+ (interactive (list
+ (completing-read
+ "Minor mode indicator: "
+ (delete nil
+ (mapcar
+ #'(lambda (x)
+ (if (eval (car x))
+ (let ((i (expand-minor-mode-indicator-object (cadr x))))
+ (if (and (< 0 (length i))
+ (string= " " (substring i 0 1)))
+ (substring i 1)
+ i))))
+ minor-mode-alist)))))
+ (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
+ (if minor-mode
+ (describe-minor-mode minor-mode)
+ (error "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)))))
+ (setq anindicator (expand-minor-mode-indicator-object anindicator))
+ (if (and (stringp anindicator)
+ (string= anindicator indicator))
+ (setq result minor-mode
+ minor-modes nil)
+ (setq minor-modes (cdr minor-modes)))))
+ result))
+
+(defun expand-minor-mode-indicator-object (obj)
+ "Expand OBJ that represents a minor-mode indicator.
+cdr part of a `minor-mode-alist' element(indicator object) is the
+indicator of minor mode that is in car part. Normally indicator
+object is a string. However, in some case it is more compound object
+like cons cell. This function tries to make the compound object a string."
+ ;; copied from describe-mode
+ (while (and obj (symbolp obj)
+ (boundp obj)
+ (not (eq obj (symbol-value obj))))
+ (setq obj (symbol-value obj)))
+ (when (and (consp obj)
+ (keywordp (car obj))
+ (eq :eval (car obj)))
+ (setq obj (eval (cadr obj))))
+ obj)
+
\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 30 Mar 2003 08:13:16 -0000
@@ -256,11 +256,19 @@
(defvar mode-line-modes nil
"Mode-line control for displaying major and minor modes.")
+(defvar mode-line-major-mode-keymap nil "\
+Keymap to display on major mode.")
+
(defvar mode-line-minor-mode-keymap nil "\
-Keymap to display on major and minor modes.")
+Keymap to display on minor modes.")
+
+(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-2] 'describe-mode)
+ (setq mode-line-major-mode-keymap map))
;; Menu of minor modes.
(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
(define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
(define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
(setq mode-line-minor-mode-keymap map))
@@ -292,8 +300,12 @@
(setq-default mode-line-modes
(list
(propertize "%[(" 'help-echo help-echo)
- `(:propertize ("" mode-name mode-line-process minor-mode-alist)
- help-echo "mouse-3: minor mode menu"
+ `(:propertize ("" mode-name)
+ help-echo "mouse-2: help for current major mode"
+ local-map ,mode-line-major-mode-keymap)
+ `(:propertize ("" mode-line-process))
+ `(:propertize ("" minor-mode-alist)
+ help-echo "mouse-2: help for minor modes, mouse-3: minor mode menu"
local-map ,mode-line-minor-mode-keymap)
(propertize "%n" 'help-echo "mouse-2: widen"
'local-map (make-mode-line-mouse-map
@@ -416,6 +428,12 @@
(defun mode-line-mode-menu (event)
(interactive "@e")
(x-popup-menu event mode-line-mode-menu))
+
+(defun mode-line-minor-mode-help (event)
+ "Describe minor mode for EVENT occured on minor modes area of the mode line."
+ (interactive "@e")
+ (let ((indicator (car (nth 4 (car (cdr event))))))
+ (describe-minor-mode-from-indicator indicator)))
;; Add menu of buffer operations to the buffer identification part
;; of the mode line.or header line.
next prev parent reply other threads:[~2003-03-30 7:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-18 7:35 |PATCH| describe-minor-mode and describe-minor-mode-from-indicator Masatake YAMATO
2003-01-18 14:12 ` 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 [this message]
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=20030330.165124.126582929.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.