From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: find-aliases, where-did-you-go-little-command Date: Wed, 06 Nov 2002 18:44:27 +0100 Sender: emacs-devel-admin@gnu.org Message-ID: <20021106184041.66CB.LEKTU@terra.es> References: <20021021134029.2852.LEKTU@terra.es> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1036605460 28516 80.91.224.249 (6 Nov 2002 17:57:40 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 6 Nov 2002 17:57:40 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 189UQs-0007Po-00 for ; Wed, 06 Nov 2002 18:57:38 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 189UZT-00084a-00 for ; Wed, 06 Nov 2002 19:06:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 189UOD-0000KF-00; Wed, 06 Nov 2002 12:54:53 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 189UEF-00065q-00 for emacs-devel@gnu.org; Wed, 06 Nov 2002 12:44:35 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 189UEC-00064w-00 for emacs-devel@gnu.org; Wed, 06 Nov 2002 12:44:35 -0500 Original-Received: from [62.22.27.141] (helo=mail.peoplecall.com) by monty-python.gnu.org with esmtp (Exim 4.10) id 189UEB-000642-00; Wed, 06 Nov 2002 12:44:32 -0500 Original-Received: from [62.22.27.143] (jbarranquero.ofi.peoplecall.com [62.22.27.143]) by mail.peoplecall.com (8.11.6/8.11.6) with ESMTP id gA6HiR130333; Wed, 6 Nov 2002 18:44:27 +0100 Original-To: rms@gnu.org In-Reply-To: X-Mailer: Becky! ver. 2.05.06 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9195 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9195 On Mon, 21 Oct 2002 23:13:38 -0400, Richard Stallman 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 "))))