From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: In the easter-egg department... Date: Sat, 19 Mar 2005 19:22:15 -0500 Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1111279142 11676 80.91.229.2 (20 Mar 2005 00:39:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 20 Mar 2005 00:39:02 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 20 01:39:01 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DCoT3-0001Oi-Gz for ged-emacs-devel@m.gmane.org; Sun, 20 Mar 2005 01:38:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DCojq-0000j9-K3 for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2005 19:56:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DCoiK-000053-I0 for emacs-devel@gnu.org; Sat, 19 Mar 2005 19:54:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DCoi7-0008QQ-9g for emacs-devel@gnu.org; Sat, 19 Mar 2005 19:54:34 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DCoi6-0008ND-VZ for emacs-devel@gnu.org; Sat, 19 Mar 2005 19:54:31 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DCoCu-00044d-1t for emacs-devel@gnu.org; Sat, 19 Mar 2005 19:22:16 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1DCoCt-0006RB-LC; Sat, 19 Mar 2005 19:22:15 -0500 Original-To: David Kastrup In-reply-to: (message from David Kastrup on Fri, 18 Mar 2005 00:09:10 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34796 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34796 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)