* In the easter-egg department...
@ 2005-03-17 23:09 David Kastrup
2005-03-20 0:22 ` Richard Stallman
0 siblings, 1 reply; 2+ messages in thread
From: David Kastrup @ 2005-03-17 23:09 UTC (permalink / raw)
C-h w ignore RET
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: In the easter-egg department...
2005-03-17 23:09 In the easter-egg department David Kastrup
@ 2005-03-20 0:22 ` Richard Stallman
0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2005-03-20 0:22 UTC (permalink / raw)
Cc: emacs-devel
C-h w ignore RET
I think this replacement definition fixes it.
(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."
(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))
(defs nil)
(standard-output (if insert (current-buffer) t)))
;; In DEFS, find all symbols that are aliases for DEFINITION.
(mapatoms (lambda (symbol)
(and (fboundp symbol)
(not (eq symbol definition))
(eq func (condition-case ()
(indirect-function symbol)
(error symbol)))
(push symbol defs))))
;; Look at all the symbols--first DEFINITION,
;; then its aliases.
(dolist (symbol (cons definition defs))
(let* ((remapped (command-remapping symbol))
(keys (where-is-internal
symbol overriding-local-map nil nil remapped))
(keys (mapconcat 'key-description keys ", "))
string)
(setq string
(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))
;; If this is the command the user asked about,
;; and it is not on any key, say so.
;; For other symbols, its aliases, say nothing
;; about them unless they are on keys.
(if (eq symbol definition)
(format "%s is not on any key" symbol)))))
(when string
(unless (eq symbol definition)
(princ ";\n its alias "))
(princ string)))))
nil)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-20 0:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-17 23:09 In the easter-egg department David Kastrup
2005-03-20 0:22 ` Richard Stallman
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.