bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22107: this-command-keys no longer returns prefix argument


From: Kaushal Modi
Subject: bug#22107: this-command-keys no longer returns prefix argument
Date: Wed, 11 May 2016 13:33:18 +0000

Hi all,

I stumbled upon this bug recently, when something in my config ( https://github.com/kaushalmodi/.emacs.d/commit/912c4fc8bf4ed0c84e28dc837b0500b9a2e172ca ) wasn't working the same way in emacs 24.5 as it does in emacs 25.x.

Here is a dummy example to demonstrate this (which is almost the same as posted by Artur in the first email of this thread):

=====
(defun foo ()
  (interactive)
  (message (format "this-command-keys: %S, this-single-command-keys: %s"
  (this-command-keys)
  (this-single-command-keys))))
(global-set-key (kbd "C-c ;") #'foo)
=====

After evaluating the above, doing C-u C-c ; gives the following results on different versions of emacs:

24.5: this-command-keys: "^U^C;", this-single-command-keys: [3 59]
25.0.93: this-command-keys: "^C;", this-single-command-keys: [3 59]

(of course I have stringified the ^U and ^C portions above to make them visible in the email)

I looked at the related commit based on this bug: http://git.savannah.gnu.org/cgit/emacs.git/commit/src/keyboard.c?h=emacs-25&id=9d2b8e768f2015a89f7609dedf7b28ea5e8123b5

It's commit log says "Restore the feature whereby C-u was part of this-command-keys, but not of this-single-command-keys.". But it looks like no restore happened. "^U" is still not part of this-command-keys.

Currently this-command-keys and this-single-command-keys look essentially the same, except the this-command-keys is a string and this-single-command-keys is a vector of asciis.

Also as Artur stated in the original bug report, the function documentation is not in sync with what actually is happening:

C-h f this-command-keys on emacs 25.0.93 gives:

=====
this-command-keys is a built-in function in ‘C source code’.

(this-command-keys)

Return the key sequence that invoked this command.
However, if the command has called ‘read-key-sequence’, it returns
the last key sequence that has been read.
The value is a string or a vector.
=====

C-h f this-single-command-keys on emacs 25.0.93 gives:

=====
this-single-command-keys is a built-in function in ‘C source code’.

(this-single-command-keys)

Return the key sequence that invoked this command.
More generally, it returns the last key sequence read, either by
the command loop or by ‘read-key-sequence’.
Unlike ‘this-command-keys’, this function’s value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
does not include prefix arguments.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value is always a vector.
=====
--

--
Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]