diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2025-01-14 22:48:35 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2025-01-14 23:26:44 +0100 |
| commit | cf8a3f15ee1c80b874be10cbdd34496b84560f59 (patch) | |
| tree | c7a77d6938c6d8d539a6ae1e72160732d440ccf5 /guides/applications/emacs/elisp-demos.org | |
| parent | faf50994d58d2651a2ab1bb1ed94dce1feb246bd (diff) | |
| download | memory-leaks-cf8a3f15ee1c80b874be10cbdd34496b84560f59.tar.xz | |
Sort guides up a bit
Diffstat (limited to 'guides/applications/emacs/elisp-demos.org')
| -rw-r--r-- | guides/applications/emacs/elisp-demos.org | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/guides/applications/emacs/elisp-demos.org b/guides/applications/emacs/elisp-demos.org new file mode 100644 index 0000000..029f5be --- /dev/null +++ b/guides/applications/emacs/elisp-demos.org @@ -0,0 +1,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 + |
