all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Lennart Borgman <lennart.borgman@gmail.com>
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Sillyness (was: Menu commands to M-x history?)
Date: Tue, 04 Aug 2009 13:31:11 -0400	[thread overview]
Message-ID: <jwvmy6f8pdj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <e01d8a50908031451s435f2f9bw4302f11f761b586f@mail.gmail.com> (Lennart Borgman's message of "Mon, 3 Aug 2009 23:51:57 +0200")

>> 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 @@
 
 
 \f
+/* 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)




      reply	other threads:[~2009-08-04 17:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-20 23:05 Menu commands to M-x history? Lennart Borgman
2009-07-21  3:44 ` Bill Wohler
2009-07-22  1:43   ` Richard Stallman
2009-07-22  2:03     ` Drew Adams
2009-07-22  2:18     ` Lennart Borgman
2009-07-22  4:15     ` Bill Wohler
2009-07-22 18:34       ` Mathias Dahl
2009-07-27  1:47         ` Drew Adams
2009-07-27  9:51           ` Lennart Borgman
2009-07-27 15:48             ` Drew Adams
2009-07-27 15:59               ` Lennart Borgman
2009-07-27 16:21                 ` Drew Adams
2009-07-27 16:39                   ` Lennart Borgman
2009-07-27 18:57                     ` Drew Adams
2009-07-27 19:22                       ` Lennart Borgman
2009-07-27 20:26                         ` Drew Adams
2009-07-27 20:53                           ` Lennart Borgman
2009-07-27 21:16                             ` Drew Adams
2009-07-27 21:34                               ` Lennart Borgman
2009-07-27 21:47                                 ` Drew Adams
2009-08-01 20:20                                   ` Drew Adams
2009-08-04 17:23                                     ` Stefan Monnier
2009-07-27 22:00                 ` Mathias Dahl
2009-07-21 15:31 ` Stefan Monnier
2009-07-21 17:43   ` Lennart Borgman
2009-08-03 21:51   ` Lennart Borgman
2009-08-04 17:31     ` Stefan Monnier [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmy6f8pdj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    /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 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.