From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Sillyness (was: Menu commands to M-x history?) Date: Tue, 04 Aug 2009 13:31:11 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1249407095 10210 80.91.229.12 (4 Aug 2009 17:31:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Aug 2009 17:31:35 +0000 (UTC) Cc: Emacs-Devel devel To: Lennart Borgman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 04 19:31:28 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MYNrA-00086S-Ie for ged-emacs-devel@m.gmane.org; Tue, 04 Aug 2009 19:31:24 +0200 Original-Received: from localhost ([127.0.0.1]:32887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYNr9-0003St-Vy for ged-emacs-devel@m.gmane.org; Tue, 04 Aug 2009 13:31:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MYNr5-0003Sb-8l for emacs-devel@gnu.org; Tue, 04 Aug 2009 13:31:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MYNr0-0003QM-Hf for emacs-devel@gnu.org; Tue, 04 Aug 2009 13:31:18 -0400 Original-Received: from [199.232.76.173] (port=49942 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYNr0-0003QD-Bn for emacs-devel@gnu.org; Tue, 04 Aug 2009 13:31:14 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:46303) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MYNr0-0002yb-0U for emacs-devel@gnu.org; Tue, 04 Aug 2009 13:31:14 -0400 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n74HVENZ001469; Tue, 4 Aug 2009 13:31:15 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 9549F3A1B3; Tue, 4 Aug 2009 13:31:11 -0400 (EDT) In-Reply-To: (Lennart Borgman's message of "Mon, 3 Aug 2009 23:51:57 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3333=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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 Xref: news.gmane.org gmane.emacs.devel:113671 Archived-At: >> For those entries which don't have a keyboard shortcut, maybe we could >> (along the lines of what M-x does) output a message like "You can run >> this command with M-x foo-bar-baz". > I do not think that will work. Those messages will very often be > hidden. And you will forget them - especially if you are new to Emacs > and have a lot to learn. Clearly they're more discrete (thus easier to forget or fail to notice), but they should almost never be hidden. BTW, on an unrelated note, here is a piece of useless code that some people who like partial-completion-mode may find funny. It told me You can run `gnus-read-ephemeral-emacs-bug-group' with M-x -r-em RET -- Stefan --- src/keyboard.c 2009-07-03 17:07:02 +0000 +++ src/keyboard.c 2009-07-24 18:45:56 +0000 @@ -10528,6 +10322,7 @@ +/* FIXME: Move to Elisp. */ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, 1, 1, "P", doc: /* Read function name, then read its arguments and call it. @@ -10637,7 +10432,10 @@ value = Fcommand_execute (function, Qt, Qnil, Qnil); /* If the command has a key binding, print it now. */ - if (!NILP (bindings) + if (SYMBOLP (Vsuggest_key_bindings) + && !NILP (Ffboundp (Vsuggest_key_bindings))) + call2 (Vsuggest_key_bindings, function, bindings); + else if (!NILP (bindings) && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), Qmouse_movement))) { and then (defun suggest-key-binding-1 (name length) (cond ((zerop length) (list "")) ((equal name "") nil) (t (nconc (mapcar (lambda (s) (concat (substring name 0 1) s)) (suggest-key-binding-1 (substring name 1) (1- length))) (when (string-match "\\`\\(-\\)?[^-]*" name) (suggest-key-binding-1 (substring name (match-end 0)) length)))))) (defun suggest-key-binding (cmd binding) (unless (or binding executing-kbd-macro (not (symbolp cmd)) (<= (length (symbol-name cmd)) 2)) ;; There's no binding for CMD. Let's try and find the shortest ;; string to use in M-x. (let ((name (symbol-name cmd)) (candidates '()) (len 1)) (while (not binding) (unless candidates (setq len (1+ len)) (setq candidates (suggest-key-binding-1 name len))) (let ((candidate (pop candidates))) (when (equal name (car-safe (completion-try-completion candidate obarray 'commandp len))) (setq binding candidate)))))) (when (and binding (sit-for (if (current-message) 2 0)) (null unread-command-events)) (let ((msg (current-message)) (message-log-max nil)) (message "You can run the command `%s' with %s" cmd (if (stringp binding) (concat "M-x " binding " RET") (key-description binding))) (when (and (sit-for 2) msg) (message msg))))) (setq suggest-key-bindings 'suggest-key-binding)