[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to count number of C-u prefixes?
From: |
Jean Louis |
Subject: |
How to count number of C-u prefixes? |
Date: |
Fri, 04 Feb 2022 17:11:29 +0300 |
I would like this function to give me number of times I have pressed
C-u, and here is the attempt to solve it:
(defun how-many-times (&optional prefix query)
(interactive "p")
(let* ((times (if (> prefix 1) (1+ (/ (sqrt prefix) 4)) 1)))
(message "Times %s" times)))
M-x how-many-times = 1
C-u M-x how-many-times = 1.5, but I would like 1 as answer.
C-u C-u M-x how-many-times = 2.0 which is what I expect
C-u C-u C-u M-x how-many-times = 3.0 which is what I expect
C-u C-u C-u C-u M-x how-many-times = 5.0 which I don't expect
I would like to simply count the number of pressed C-u prefixes.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/