From unknown Tue Sep 09 16:57:06 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17151: 24.3.50; Disabled commands are executed anyway Resent-From: Nicolas Richard Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Mar 2014 19:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17151 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 17151@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.139629462915793 (code B ref -1); Mon, 31 Mar 2014 19:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Mar 2014 19:37:09 +0000 Received: from localhost ([127.0.0.1]:58220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUi15-00046d-TW for submit@debbugs.gnu.org; Mon, 31 Mar 2014 15:37:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57836) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUi12-00046S-Jm for submit@debbugs.gnu.org; Mon, 31 Mar 2014 15:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUi0w-0001iL-M8 for submit@debbugs.gnu.org; Mon, 31 Mar 2014 15:37:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:40981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUi0w-0001iH-JG for submit@debbugs.gnu.org; Mon, 31 Mar 2014 15:36:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUi0r-0005k5-34 for bug-gnu-emacs@gnu.org; Mon, 31 Mar 2014 15:36:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUi0g-0001gY-48 for bug-gnu-emacs@gnu.org; Mon, 31 Mar 2014 15:36:53 -0400 Received: from mailrelay005.isp.belgacom.be ([195.238.6.171]:58248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUi0f-0001gL-R1 for bug-gnu-emacs@gnu.org; Mon, 31 Mar 2014 15:36:42 -0400 X-Belgacom-Dynamic: yes Received: from 55.22-200-80.adsl-dyn.isp.belgacom.be (HELO LDLC-portable) ([80.200.22.55]) by relay.skynet.be with ESMTP; 31 Mar 2014 21:36:40 +0200 From: Nicolas Richard Date: Mon, 31 Mar 2014 21:36:40 +0200 Message-ID: <8761mutb1z.fsf@yahoo.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain I report two problems, but they really are the same bug. 1st problem: >From emacs -Q : select e.g. the first line of the scratch buffer hit C-x n n (that is a disabled command, so you get a prompt) answer 'n' to the prompt the buffer is narrowed anyway. I expected nothing to happen wrt narrowing. 2nd problem: >From emacs -Q, eval : (defun my-command () (interactive) (message "Got called !")) (put 'my-command 'disabled t) then: M-x my-command RET (you get a prompt) hit SPC to execute just once and leave disabled hit C-h e to show the *Messages* buffer You can see: Got called ! [2 times] I expected to see "Got called !" (only once). Both of these seem to be fixed with the attached patch. However, with this patch, when `disabled-command-function' decides to run the command, it does so by invoking call-interactively, thereby not executing what command-execute would have done if the command had not been disabled. It doesn't seem right but I'm not sure (and have no idea what to change anyway). Here's the patch : --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-lisp-simple.el-command-execute-Do-not-execute-disabl.patch >From d5259941c61fb9de3967135925d1649a3aaa9381 Mon Sep 17 00:00:00 2001 From: Nicolas Richard Date: Mon, 31 Mar 2014 19:41:22 +0200 Subject: [PATCH] * lisp/simple.el (command-execute): Do not execute disabled commands. --- lisp/ChangeLog | 4 ++++ lisp/simple.el | 60 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 747bbcf..6ad449f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-03-31 Nicolas Richard + + * simple.el (command-execute): Do not execute the command when it + is disabled. 2014-03-29 Juri Linkov * dired-aux.el (dired-compress-file): Don't use string-match-p diff --git a/lisp/simple.el b/lisp/simple.el index 98604a4..b469fc1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1628,36 +1628,36 @@ a special event, so ignore the prefix argument and don't clear it." (prog1 prefix-arg (setq current-prefix-arg prefix-arg) (setq prefix-arg nil))))) - (and (symbolp cmd) - (get cmd 'disabled) - ;; FIXME: Weird calling convention! - (run-hooks 'disabled-command-function)) - (let ((final cmd)) - (while - (progn - (setq final (indirect-function final)) - (if (autoloadp final) - (setq final (autoload-do-load final cmd))))) - (cond - ((arrayp final) - ;; If requested, place the macro in the command history. For - ;; other sorts of commands, call-interactively takes care of this. - (when record-flag - (push `(execute-kbd-macro ,final ,prefixarg) command-history) - ;; Don't keep command history around forever. - (when (and (numberp history-length) (> history-length 0)) - (let ((cell (nthcdr history-length command-history))) - (if (consp cell) (setcdr cell nil))))) - (execute-kbd-macro final prefixarg)) - (t - ;; Pass `cmd' rather than `final', for the backtrace's sake. - (prog1 (call-interactively cmd record-flag keys) - (when (and (symbolp cmd) - (get cmd 'byte-obsolete-info) - (not (get cmd 'command-execute-obsolete-warned))) - (put cmd 'command-execute-obsolete-warned t) - (message "%s" (macroexp--obsolete-warning - cmd (get cmd 'byte-obsolete-info) "command"))))))))) + (if (and (symbolp cmd) + (get cmd 'disabled)) + ;; FIXME: Weird calling convention! + (run-hooks 'disabled-command-function) + (let ((final cmd)) + (while + (progn + (setq final (indirect-function final)) + (if (autoloadp final) + (setq final (autoload-do-load final cmd))))) + (cond + ((arrayp final) + ;; If requested, place the macro in the command history. For + ;; other sorts of commands, call-interactively takes care of this. + (when record-flag + (push `(execute-kbd-macro ,final ,prefixarg) command-history) + ;; Don't keep command history around forever. + (when (and (numberp history-length) (> history-length 0)) + (let ((cell (nthcdr history-length command-history))) + (if (consp cell) (setcdr cell nil))))) + (execute-kbd-macro final prefixarg)) + (t + ;; Pass `cmd' rather than `final', for the backtrace's sake. + (prog1 (call-interactively cmd record-flag keys) + (when (and (symbolp cmd) + (get cmd 'byte-obsolete-info) + (not (get cmd 'command-execute-obsolete-warned))) + (put cmd 'command-execute-obsolete-warned t) + (message "%s" (macroexp--obsolete-warning + cmd (get cmd 'byte-obsolete-info) "command")))))))))) (defvar minibuffer-history nil "Default minibuffer history list. -- 1.9.1 --=-=-= Content-Type: text/plain -- Nico. --=-=-=-- From unknown Tue Sep 09 16:57:06 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17151: 24.3.50; Disabled commands are executed anyway Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Apr 2014 06:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17151 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nicolas Richard Cc: 17151@debbugs.gnu.org Received: via spool by 17151-submit@debbugs.gnu.org id=B17151.139642163612864 (code B ref 17151); Wed, 02 Apr 2014 06:54:02 +0000 Received: (at 17151) by debbugs.gnu.org; 2 Apr 2014 06:53:56 +0000 Received: from localhost ([127.0.0.1]:60192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WVF3b-0003LP-LG for submit@debbugs.gnu.org; Wed, 02 Apr 2014 02:53:56 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:47013) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WVF3Z-0003LH-96 for 17151@debbugs.gnu.org; Wed, 02 Apr 2014 02:53:53 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WVF3Y-0007Bs-CI; Wed, 02 Apr 2014 02:53:52 -0400 From: Glenn Morris References: <8761mutb1z.fsf@yahoo.fr> X-Spook: virus USCODE clones infowar bce BLU-114/B domestic X-Ran: )?y;VkSg/:uxfSL;@]HeRl?Tl)&._Dza9V8`lo$[3Sf%BR(YS#KV1Fk%e7:sdyZ-cyqIv8 X-Hue: cyan X-Attribution: GM Date: Wed, 02 Apr 2014 02:53:52 -0400 In-Reply-To: <8761mutb1z.fsf@yahoo.fr> (Nicolas Richard's message of "Mon, 31 Mar 2014 21:36:40 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.9 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.9 (----) Thanks; applied. It would be good if someone could write a test-case for this. (Maybe use a custom disabled-command-function.) From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 02:54:13 2014 Received: (at control) by debbugs.gnu.org; 2 Apr 2014 06:54:13 +0000 Received: from localhost ([127.0.0.1]:60196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WVF3s-0003MM-Ku for submit@debbugs.gnu.org; Wed, 02 Apr 2014 02:54:13 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:47015) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WVF3p-0003MB-GW for control@debbugs.gnu.org; Wed, 02 Apr 2014 02:54:10 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WVF3p-0007Cn-AP for control@debbugs.gnu.org; Wed, 02 Apr 2014 02:54:09 -0400 Date: Wed, 02 Apr 2014 02:54:09 -0400 Message-Id: Subject: control message for bug 17151 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.6 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.6 (-----) close 17151 24.4