From: "Drew Adams" <drew.adams@oracle.com>
To: <dann@ics.uci.edu>
Cc: emacs-devel@gnu.org
Subject: RE: mode-line menu for minor modes
Date: Wed, 20 Feb 2008 16:11:44 -0800 [thread overview]
Message-ID: <007601c8741e$57f0d120$c2b22382@us.oracle.com> (raw)
In-Reply-To: <200802200629.m1K6TIoH027637@sallyv1.ics.uci.edu>
> > > The new feature to pop a menu when clicking on the mode-line
> > > :lighter for
> > > minor modes is great.
> > >
> > > But for minor modes that don't provide a menu, just an error
> > > message is
> > > displayed: "No menu for minor mode `BLAH'". This is
> > > not very helpful
> > > for the user, it would be nicer to pop up a menu that
> > > has (at least) 2
> > > entries: - one to turn off the minor mode
> > > - one to show the help for that minor mode.
> > >
> > > Yes, these are available elsewhere, but it's better to
> > > provide something
> > > useful and consistent for mouse-1 instead of just
> > > complaining that a menu is not available.
> >
> > Good idea.
>
> Given that you wrote the rest of the minor mode menu popup
> code, do you
> want to implement this too?
OK - see below. I wanted to make a patch, but apparently I don't know how to
find the latest CVS version. When I look at what I think would be the latest
version, namely the first download link at
http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/bindings.el?view=log, it
shows a version of bindings.el that does not have the changes I submitted.
But you are apparently seeing some version that does include that patch.
If you tell me how to find the right version to patch, I'll send a patch. If
not, here is the updated function definition - just substitute this for the
definition I sent in my September patch.
Note: I added (sleep-for 1) because the turned-off message is otherwise
erased immediately, at least in my environment. If it works for you without
the sleep-for, then go ahead and remove it.
(defun minor-mode-menu-from-indicator (indicator) ; e.g. " Icy"
"Show menu for minor mode specified by INDICATOR.
Interactively, INDICATOR is read using completion.
If there is no menu defined for the minor mode, then create one with
items `Turn Off' and `Help'."
(interactive (list (completing-read "Minor mode indicator: "
(describe-minor-mode-completion-table-for-indicator))))
(let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
(unless minor-mode (error "Cannot find minor mode for `%s'" indicator))
(let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist)))
(menu (and (keymapp map) (lookup-key map [menu-bar]))))
(if menu
(popup-menu menu)
(read-event) ; Swallow the mouse up event.
(setq menu `(keymap
(,(intern indicator) ,indicator
keymap
(turn-off menu-item "Turn Off"
(lambda ()
(interactive)
(,minor-mode -1)
(message ,(format "`%S' turned OFF"
minor-mode))
(sleep-for 1)))
(help menu-item "Help"
(lambda () (interactive) (describe-function
',minor-mode))))))
(popup-menu menu)))))
next prev parent reply other threads:[~2008-02-21 0:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-19 8:09 mode-line menu for minor modes Dan Nicolaescu
2008-02-20 3:39 ` Drew Adams
2008-02-20 6:29 ` Dan Nicolaescu
2008-02-21 0:11 ` Drew Adams [this message]
2008-02-21 9:17 ` Dan Nicolaescu
2008-02-21 9:27 ` Drew Adams
2008-02-21 9:32 ` Dan Nicolaescu
2008-02-25 7:48 ` Bastien Guerry
2008-02-25 15:22 ` Drew Adams
2008-02-25 15:37 ` Bastien Guerry
2008-02-25 16:32 ` Drew Adams
2008-02-25 15:47 ` Stefan Monnier
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='007601c8741e$57f0d120$c2b22382@us.oracle.com' \
--to=drew.adams@oracle.com \
--cc=dann@ics.uci.edu \
--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.