From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Menu commands to M-x history? Date: Mon, 3 Aug 2009 23:51:57 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1249349764 17405 80.91.229.12 (4 Aug 2009 01:36:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Aug 2009 01:36:04 +0000 (UTC) Cc: Emacs-Devel devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 04 03:35:57 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 1MY8wV-0002TG-Ax for ged-emacs-devel@m.gmane.org; Tue, 04 Aug 2009 03:35:55 +0200 Original-Received: from localhost ([127.0.0.1]:38814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY8wU-00079r-RU for ged-emacs-devel@m.gmane.org; Mon, 03 Aug 2009 21:35:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MY5Rs-0008K5-VI for emacs-devel@gnu.org; Mon, 03 Aug 2009 17:52:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MY5Rn-0008GC-RZ for emacs-devel@gnu.org; Mon, 03 Aug 2009 17:52:03 -0400 Original-Received: from [199.232.76.173] (port=37903 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY5Rn-0008Fl-CC for emacs-devel@gnu.org; Mon, 03 Aug 2009 17:51:59 -0400 Original-Received: from mail-yw0-f189.google.com ([209.85.211.189]:47150) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MY5Rm-0001o0-Ty for emacs-devel@gnu.org; Mon, 03 Aug 2009 17:51:59 -0400 Original-Received: by ywh27 with SMTP id 27so4371523ywh.26 for ; Mon, 03 Aug 2009 14:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=CEgtezggYIZzih2a+5no9rLFW9WOv20MgEz8nOy4Ehc=; b=TvvZDlAcsUY5ZZpchBa9RYvaTYkSufgt8514dZRRvnq7CXTnVbzkRLR18nVFp+FV2D Qy5UkOC9AmLInCoTSTvM5KWnxW2vBWOxsT2amp928upxYtAkJs8MkE3xSEGyX2I7m+Cm YAnSYjMtyttWt0Z17+oHWY+IOzrADwpNoLIs8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=uV/oh4qC/jjUBTIZXK0Oclt/zMdFmY5wRrd3g9x7XFNYSncfHTHS5TEWgyzc0TTmNZ nDeoiUFtlmtmE1Pw/U1/vbcNz08SH85pu2n+TPYYhECMxjR56YIF6sNOXs4bAa+kbheb JOYJ0010zsPlcTQMXDpx7vTM1IMz2vtE1n+SY= Original-Received: by 10.100.58.14 with SMTP id g14mr7850057ana.5.1249336317982; Mon, 03 Aug 2009 14:51:57 -0700 (PDT) In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:113632 Archived-At: On Tue, Jul 21, 2009 at 5:31 PM, Stefan Monnier w= rote: >> Menu commands are all commands that can be started from M-x. =C2=A0I thi= nk >> 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)))