GNU bug report logs -
#71277
30.0.50; last-prefix-arg lost when universal-argument used
Previous Next
Reported by: Sean Whitton <spwhitton <at> spwhitton.name>
Date: Thu, 30 May 2024 11:48:02 UTC
Severity: normal
Found in version 30.0.50
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 30 May 2024 16:31:23 +0100
with message-id <877cfbs4dw.fsf <at> zephyr.silentflame.com>
and subject line Re: bug#71277: 30.0.50; last-prefix-arg lost when universal-argument used
has caused the debbugs.gnu.org bug report #71277,
regarding 30.0.50; last-prefix-arg lost when universal-argument used
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
71277: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71277
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hello,
Consider
(defun counter ()
(interactive)
(when (eq last-command this-command)
(setq current-prefix-arg
(+ (prefix-numeric-value current-prefix-arg)
(prefix-numeric-value last-prefix-arg))))
(message "%s!" (prefix-numeric-value current-prefix-arg)))
(global-set-key "\M-." #'counter)
If you type M-. M-. M-. then you see "3!" as expected.
Similarly if you type "C-u M-. M-. M-." then you see "6!".
However, if you type "M-. M-. C-u M-." then you get "5!".
Unlses something is wrong with my arithmetic, this is not correct.
You should get "6!" after the third example too.
The use of C-u clobbers last-prefix-arg, basically.
I believe this will fix it:
-- >8 --
Subject: [PATCH] universal-argument--preserve: Preserve last-prefix-arg
* lisp/simple.el (universal-argument--preserve): Set
current-prefix-arg to last-prefix-arg in order to preserve
last-prefix-arg, too.
---
lisp/simple.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 44197c3189a..76fb81c9df5 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5414,7 +5414,8 @@ universal-argument--description
(add-hook 'prefix-command-preserve-state-hook
#'universal-argument--preserve)
(defun universal-argument--preserve ()
- (setq prefix-arg current-prefix-arg))
+ (setq prefix-arg current-prefix-arg)
+ (setq current-prefix-arg last-prefix-arg))
(defvar universal-argument-map
(let ((map (make-sparse-keymap))
--
Sean Whitton
[Message part 3 (message/rfc822, inline)]
Hello,
On Thu 30 May 2024 at 10:42am -04, Stefan Monnier wrote:
>>> Unlses something is wrong with my arithmetic, this is not correct.
>>> You should get "6!" after the third example too.
>>> The use of C-u clobbers last-prefix-arg, basically.
>>>
>>> I believe this will fix it:
>>
>> Thanks, I'm adding Stefan to this discussion.
>
> Hmm... I didn't know about `last-prefix-arg`.
> [ I'm not sure I like the idea of such a variable, but
> well... it's there. ]
> The patch looks fine to me, thank you.
Installed, thanks for the review.
--
Sean Whitton
This bug report was last modified 356 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.