unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lektu@terra.es>
Cc: emacs-devel@gnu.org
Subject: Re: find-aliases, where-did-you-go-little-command
Date: Wed, 06 Nov 2002 18:44:27 +0100	[thread overview]
Message-ID: <20021106184041.66CB.LEKTU@terra.es> (raw)
In-Reply-To: <E183pUA-0000XA-00@fencepost.gnu.org>

On Mon, 21 Oct 2002 23:13:38 -0400, Richard Stallman <rms@gnu.org> wrote:

> This seems like a useful feature for where-is.

Here's a first cut at an implementation.

Points to take into account:

1.- I've put a variable `where-is-show-aliases' to activate the new
behavior. In the code below it is set to t, but perhaps nil would be a
better default.

2.- The output format is not very elaborated. Better suggestions very
welcome.

3.- Same, and more so, for the "insert" behavior of `where-is'.

Comments?

Thanks,

                                                           /L/e/k/t/u




(eval-when-compile
 (require 'cl))

(defcustom where-is-show-aliases t
  "*Whether `where-is' must also show keybindings for aliases."
  :type 'boolean
  :group 'help
  :version "21.4")

(defun where-is (definition &optional insert)
  "Print message listing key sequences that invoke the command DEFINITION.
Argument is a command definition, usually a symbol with a function definition.
If INSERT (the prefix arg) is non-nil, insert the message in the buffer.
If `where-is-show-aliases is non-nil, show also keybindings for aliases of DEFINITION."
  (interactive
   (let ((fn (function-called-at-point))
	 (enable-recursive-minibuffers t)
	 val)
     (setq val (completing-read (if fn
				    (format "Where is command (default %s): " fn)
				  "Where is command: ")
				obarray 'commandp t))
     (list (if (equal val "")
	       fn (intern val))
	   current-prefix-arg)))
  (let ((func (indirect-function definition))
        (map nil)
        (standard-output (if insert (current-buffer) t)))
    (when where-is-show-aliases
      (mapatoms #'(lambda (symbol)
                    (when (and (not (eq symbol definition))
                               (eq func (ignore-errors (indirect-function symbol))))
                      (setq map (cons symbol map))))))
    (princ (mapconcat #'(lambda (symbol)
                          (let* ((remapped (remap-command symbol))
                                 (keys (mapconcat 'key-description
                                                  (where-is-internal symbol overriding-local-map nil nil remapped)
                                                  ", ")))
                            (if insert
                                (if (> (length keys) 0)
                                    (if remapped
                                        (format "%s (%s) (remapped from %s)" keys remapped symbol)
                                      (format "%s (%s)" keys symbol))
                                  (format "M-x %s RET" symbol))
                              (if (> (length keys) 0)
                                  (if remapped
                                      (format "%s is remapped to %s which is on %s" definition symbol keys)
                                    (format "%s is on %s" symbol keys))
                                (format "%s is not on any key" symbol)))))
                      (cons definition map)
                      ";\nand "))))

  parent reply	other threads:[~2002-11-06 17:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-21 11:50 find-aliases, where-did-you-go-little-command Juanma Barranquero
2002-10-22  3:13 ` Richard Stallman
2002-10-22  8:46   ` Juanma Barranquero
2002-10-22 14:28     ` Stefan Monnier
2002-10-22 14:41       ` Juanma Barranquero
2002-10-23  7:12       ` Richard Stallman
2002-10-23  7:35         ` Stefan Monnier
2002-11-06 17:44   ` Juanma Barranquero [this message]
2002-11-06 19:27     ` Stefan Monnier
2002-11-06 21:49       ` Juanma Barranquero
2002-11-07  7:23         ` Kai Großjohann
2002-11-07 15:08     ` Richard Stallman
2002-11-07 16:52       ` Juanma Barranquero

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=20021106184041.66CB.LEKTU@terra.es \
    --to=lektu@terra.es \
    --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).