unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: Menu commands to M-x history?
Date: Mon, 3 Aug 2009 23:51:57 +0200	[thread overview]
Message-ID: <e01d8a50908031451s435f2f9bw4302f11f761b586f@mail.gmail.com> (raw)
In-Reply-To: <jwvk522awd5.fsf-monnier+emacs@gnu.org>

On Tue, Jul 21, 2009 at 5:31 PM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
>> Menu commands are all commands that can be started from M-x.  I think
>> they should be added to M-x history.
>
> Most of them should have a key shortcut anyway, which the user has seen
> in the menu entry.

I think that is impossible. And many times it is not useful (as has
been discussed for rgrep/lgrep).


> 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 Emac
and have a lot to learn.

I have added a simple recipe for my initial suggestion to nXhtml, see
below. A message is shown (if appropriate) when a command is added to
M-x history. If you want to, just include it in Emacs.

(defun ourcomments-M-x-menu-pre ()
  "Add menu command to M-x history."
  (let ((is-menu-command (equal '(menu-bar)
                                (elt (this-command-keys-vector) 0)))
        (pre-len (length extended-command-history)))
    (when (and is-menu-command
               (not (memq this-command '(ourcomments-M-x-menu-mode))))
      (pushnew (symbol-name this-command) extended-command-history)
      (when (< pre-len (length extended-command-history))
        ;; This message is given pre-command and is therefore likely
        ;; to be overwritten, but that is ok in this case. If the user
        ;; has seen one of these messages s?he knows.
        (message "(Added %s to M-x history so you can run it from
there)" this-command)))))

;;;###autoload
(define-minor-mode ourcomments-M-x-menu-mode
  "Add commands started from Emacs menus to M-x history.
The purpose of this is to make it easier to redo them and easier
to learn how to do them from the command line \(which is often
faster if you know how to do it).

Only commands that are not already in M-x history are added."
  :global t
  (if ourcomments-M-x-menu-mode
      (add-hook 'pre-command-hook 'ourcomments-M-x-menu-pre)
    (remove-hook 'pre-command-hook 'ourcomments-M-x-menu-pre)))




  parent reply	other threads:[~2009-08-03 21:51 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 [this message]
2009-08-04 17:31     ` Sillyness (was: Menu commands to M-x history?) Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

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

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).