From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Aaron S. Hawley" Newsgroups: gmane.emacs.devel Subject: Re: bug: "C-x z" ("repeat") no longer works correctly with M-x Date: Sat, 2 Jun 2012 18:07:52 -0400 Message-ID: References: <87396ylx5m.fsf@catnip.gol.com> <87pq9ndq0n.fsf@gnu.org> <8762ba8b6p.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1338674909 12431 80.91.229.3 (2 Jun 2012 22:08:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 2 Jun 2012 22:08:29 +0000 (UTC) Cc: emacs-devel@gnu.org, Miles Bader To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 03 00:08:23 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SawUZ-0004h8-U1 for ged-emacs-devel@m.gmane.org; Sun, 03 Jun 2012 00:08:16 +0200 Original-Received: from localhost ([::1]:57052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SawUZ-0002XI-JW for ged-emacs-devel@m.gmane.org; Sat, 02 Jun 2012 18:08:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SawUQ-0002Ck-8T for emacs-devel@gnu.org; Sat, 02 Jun 2012 18:08:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SawUO-00033G-Ew for emacs-devel@gnu.org; Sat, 02 Jun 2012 18:08:05 -0400 Original-Received: from mail-bk0-f41.google.com ([209.85.214.41]:41056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SawUH-00032R-4D; Sat, 02 Jun 2012 18:07:57 -0400 Original-Received: by bkcjm19 with SMTP id jm19so3313352bkc.0 for ; Sat, 02 Jun 2012 15:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iYWy4mbdyZjPJlohzVPJfi0LqFghrBJdEZlsE7mGZQ8=; b=Vt3Mta2vGeJvV0InRHWPrOGo+18P5/ZKA4KkTAuDr/2cbpa0G4Yt+2a5A3Nl/Fvr+l 9o7E0IBEq48110ZiBnFSmCG0xNdSeICCRQSh0ecrSbj9kVNjZJBk789HBsxhkgVb6J2L pdhaSgve8GFY0vHr+RQbdWE0CxfkQcgPPW6jwC9H5roI+921mgm0je/UO0/8lqYlFCIZ n+Mh23Dr2di+JWSdwABUWwEGibvuZ0whWgZktExWRmx7znwVFyCa1jt2uYIT+ZOZ4o1N 9ZEuwjIDoiK7mtDLi/t8F6KD7LPLbm7cGCTu+GxwW6HeI2LbtTr07/nF3xzLFLxbKjNv fDRg== Original-Received: by 10.204.154.80 with SMTP id n16mr4224081bkw.112.1338674872993; Sat, 02 Jun 2012 15:07:52 -0700 (PDT) Original-Received: by 10.204.35.145 with HTTP; Sat, 2 Jun 2012 15:07:52 -0700 (PDT) In-Reply-To: <8762ba8b6p.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150744 Archived-At: On 6/2/12, Chong Yidong wrote: > "Aaron S. Hawley" writes: > >> I had given a more literal translation of the C command to the >> gnu-emacs-sources mailing list back in March. Stefan and I discussed >> it but hadn't run across this issue with repeat. He later made some >> modifications to my submission and committed it in May. I have only >> now run it and can confirm this bug with repeat. I'm not sure what's >> causing it though, but found the following fixes it. Again, I'm not >> sure why. Nor am I sure if it's a wholly appropriate fix. > > No, tweaking the interactive spec does not really fix the problem. > > The problem is that the old execute-extended-command sets the > real_this_command internal variable, which causes the Emacs command loop > to record the command that was actually executed into real-last-command > and last-repeatable-command. > > In other words, it's not just the fact that `C-x z' doesn't work > properly. Moving execute-extended-command to Lisp produces a > backward-incompatible change in the values of the real-last-command and > last-repeatable-command variables for M-x. I suspect this may break > things other than `C-x z'. I guess we could fix this by exposing > real_this_command to Lisp too, but that kinda defeats the point of that > variable... > > Is there a strong rationale for moving execute-extended-command to Lisp, > other than the general principle that we want as much functionality > implemented Lisp as possible? If not, it may not be worth making this > change, at least in Emacs 24.2, due to the risk of gratuitous > incompatibilities. I agree, it's not worth it if things break. As I wrote to gnu-emacs-sources, I've been using a Lisp version of M-x for several years. Obviously, I ran into issues when I first tried writing the code, but haven't run into any issues since. I am a big user of repeat and repeat-complex-command and keyboard macros. I think it's possible to get this Lisp version to work as well as the C version. I understand your concern about real_this_command in command_loop and call-interactively. However, it's not clear if there's any reason for it for M-x. I'd be interested to know if there other issues. Perhaps the timeline of 24.2 won't allow for it? I've made sure repeat works if M-x is a mouse event by adding it to the tool-bar or the menu-bar. (define-key menu-bar-tools-menu [m-x] `(menu-item ,(purecopy "M-x") execute-extended-command :enable (menu-bar-non-minibuffer-window-p) :help ,(purecopy "Execute extended command"))) (tool-bar-add-item-from-menu 'execute-extended-command "mpc/add" nil :label "Execute extended command" :vert-only t) I do suggest the following fixes to rework Stefan's revision, including the change to the interactive spec. Some of it is white space changes and a comment that no longer applies. 2012-05-29 Aaron S. Hawley * simple.el (execute-extended-command): Reading command-name in interactive form breaks the repeat command. Improve error message for empty command-name. --- simple.el 2012-05-29 08:21:45.000000000 -0400 +++ simple.el 2012-05-29 18:46:04.836717200 -0400 @@ -1373,17 +1373,20 @@ Noninteractively, the argument PREFIXARG is the prefix argument to give to the command you invoke, if it asks for an argument." - (interactive (list current-prefix-arg (read-extended-command))) + (interactive "P") ;; Emacs<24 calling-convention was with a single `prefixarg' argument. - (if (null command-name) (setq command-name (read-extended-command))) + (when (null command-name) + ;; Could be in `interactive' as well, but it breaks `repeat'. + (setq command-name (read-extended-command))) (let* ((function (and (stringp command-name) (intern-soft command-name))) (binding (and suggest-key-bindings - (not executing-kbd-macro) - (where-is-internal function overriding-local-map t)))) + (not executing-kbd-macro) + (where-is-internal function overriding-local-map t)))) + (when (and (stringp command-name) + (= 0 (length command-name))) + (error "No command name given")) (unless (commandp function) (error "`%s' is not a valid command name" command-name)) - ;; Set this_command_keys to the concatenation of saved-keys and - ;; function, followed by a RET. (setq this-command function) (let ((prefix-arg prefixarg)) (command-execute function 'record)) -- In general, we reserve the right to have a poor memory--the computer, however, is supposed to remember! Poor computer. -- Guy Lewis Steele Jr.