unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: |PATCH| describe-minor-mode and describe-minor-mode-from-indicator
Date: Mon, 31 Mar 2003 10:51:01 -0500	[thread overview]
Message-ID: <200303311551.h2VFp1xQ016968@rum.cs.yale.edu> (raw)
In-Reply-To: 20030330.165124.126582929.jet@gyve.org

> +(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)

`function' is not necessary, and it forces too much indendation here.

> +						       (if (eval (car x))
> +							   (symbol-name (car x)))))

I generally believe that `eval' should be avoided.  This is especially
true here since you call `symbol-name' so you already assume that (car x)
is a symbol, so you could just call `symbol-value' instead of `eval'.
But note also that nothing guarantees you that (car x) is bound.
Finally, I think it's perfectly OK (if not preferable) to list all
the minor modes rather than just the currently active ones, so
I'd just use

  (delq nil (mapcar (lambda (x) (symbol-name (car x))) minor-mode-alist))

> +(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)))))

How about

 (delq nil (mapcar (lambda (x)
                     (let ((i (format-mode-line x)))
                       (if (> (length i) 0)
                           (if (eq (aref i 0) ?\ )
                               (substring i 1) i))))
                   minor-mode-alist)) ?

> +(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)))

I'd rather not assume that indicators start with a space.

> +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.

Actually, minor-mode-alist is a mode-line-spec.
So we can simply use `formal-mode-line' to interpret it.

>  (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))

I recommend the use of

  (defvar foo-map
    (let ((map (...)
      (define-key ...)
      ...
      map))

I think that the coding cnvention also recommend it.  Admittedly, a lot
of Emacs code doesn't use it :-(

In any case, it seems that your patch removes the "mouse-3 on major mode"
behavior that allowed to turn on minor modes by clicking mouse-3
on the major-mode name.  I think this is important since it can
often happen that there is no active minor-mode on which to
click mouse-3.


	Stefan

  reply	other threads:[~2003-03-31 15: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
2003-03-31 15:51                 ` Stefan Monnier [this message]
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

  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=200303311551.h2VFp1xQ016968@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.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 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).