blob: 029f5be82c453891d6539aade2db601204e36daa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
Some terse "context-free" Emacs Lisp snippets that hopefully speak for
themselves.
* The prefix argument
#+begin_src elisp
(defun my/prefix-arg-demo (arg)
(interactive (list current-prefix-arg))
(insert
(let ((num (prefix-numeric-value arg)))
(format "%s %d %s\n"
arg
num
(cond ((null arg) "N/A")
((numberp arg) (format "M-%d or C-u %d" arg arg))
((equal arg '-) (format "M-- or C-u -"))
((listp arg)
(if (< num 0)
(format "(M-- or C-u -) C-u × %d" (log (- num) 4))
(format "C-u × %d" (log num 4)))))))))
#+end_src
#+begin_example
nil 1 N/A
2 2 M-2 or C-u 2
- -1 M-- or C-u -
(-16) -16 (M-- or C-u -) C-u × 2
(64) 64 C-u × 3
#+end_example
|