summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2022-06-24 08:21:22 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2022-06-24 08:21:22 +0200
commitfc831dafd081ebeffc9d98c2a35597bef2a0d34a (patch)
treee7932ef02b76e06160496a816388403721039a91
parent9b2bda7f2b714e59c5c53ab6bea7221730da0cea (diff)
downloadmemory-leaks-fc831dafd081ebeffc9d98c2a35597bef2a0d34a.tar.xz
Add an Elisp "cheatsheet"
-rw-r--r--guides/emacs/elisp-demos.org28
1 files changed, 28 insertions, 0 deletions
diff --git a/guides/emacs/elisp-demos.org b/guides/emacs/elisp-demos.org
new file mode 100644
index 0000000..029f5be
--- /dev/null
+++ b/guides/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
+