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