GNU bug report logs - #17151
24.3.50; Disabled commands are executed anyway

Previous Next

Package: emacs;

Reported by: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>

Date: Mon, 31 Mar 2014 19:38:02 UTC

Severity: important

Found in version 24.3.50

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17151 in the body.
You can then email your comments to 17151 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17151; Package emacs. (Mon, 31 Mar 2014 19:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Richard <theonewiththeevillook <at> yahoo.fr>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 31 Mar 2014 19:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; Disabled commands are executed anyway
Date: Mon, 31 Mar 2014 21:36:40 +0200
[Message part 1 (text/plain, inline)]
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 :
[0001-lisp-simple.el-command-execute-Do-not-execute-disabl.patch (text/x-diff, inline)]
From d5259941c61fb9de3967135925d1649a3aaa9381 Mon Sep 17 00:00:00 2001
From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
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  <theonewiththeevillook <at> yahoo.fr>
+
+	* simple.el (command-execute): Do not execute the command when it
+	is disabled.
 2014-03-29  Juri Linkov  <juri <at> jurta.org>
 
 	* 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

[Message part 3 (text/plain, inline)]
-- 
Nico.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17151; Package emacs. (Wed, 02 Apr 2014 06:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 17151 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
Cc: 17151 <at> debbugs.gnu.org
Subject: Re: bug#17151: 24.3.50; Disabled commands are executed anyway
Date: Wed, 02 Apr 2014 02:53:52 -0400
Thanks; applied.

It would be good if someone could write a test-case for this.
(Maybe use a custom disabled-command-function.)




bug marked as fixed in version 24.4, send any further explanations to 17151 <at> debbugs.gnu.org and Nicolas Richard <theonewiththeevillook <at> yahoo.fr> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 02 Apr 2014 06:55:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 30 Apr 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.