about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-01-12 17:40:53 -0600
committerCase Duckworth2022-01-12 17:40:53 -0600
commitcaf8d7aa54a5e8fca9ffd6fdceccfb4fa58169dd (patch)
tree52eec47de51d2770d71087196e887b92f5bfb907
parentCoupla small changes (diff)
downloademacs-caf8d7aa54a5e8fca9ffd6fdceccfb4fa58169dd.tar.gz
emacs-caf8d7aa54a5e8fca9ffd6fdceccfb4fa58169dd.zip
Add remember.el (WIP)
-rw-r--r--lisp/remember.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/lisp/remember.el b/lisp/remember.el new file mode 100644 index 0000000..39476d1 --- /dev/null +++ b/lisp/remember.el
@@ -0,0 +1,43 @@
1;; ABANDON ALL HOPE YE WHO ENTER HERE
2
3(defmacro remember-set (&rest symbols)
4 "Setup a closure remembering symbols to apply with
5`remember-reset'. The variables will be renamed using TEMPLATE.
6SYMBOLS is a plist: the properties are symbols or mode names, and
7their values what to set after `remember-setup'."
8 (let* ((template (format "remember--%s-%%s" (gensym)))
9 (reset-fn (intern (format template "reset" "fn")))
10 (list (cl-loop for sym in symbols by #'cddr
11 collect `(,(intern (format template sym))
12 ,sym)
13 into let-list
14 collect (let ((val (plist-get symbols sym)))
15 (cond ((eq val 'enable)
16 `(,sym +1))
17 ((eq val 'disable)
18 `(,sym -1))
19 (t `(setq-local ,sym ,val))))
20 into fn-set-list
21 collect (let ((val (plist-get symbols sym))
22 (rem (intern (format template sym))))
23 (cond ((memq val '(enable disable))
24 `(,sym (if ,rem +1 -1)))
25 (t `(setq-local ,sym ,rem))))
26 into fn-reset-list
27 finally return (list let-list
28 fn-reset-list
29 fn-set-list))))
30 `(progn
31 (defvar-local ,reset-fn nil
32 "Function to recall values from `remember-set'.")
33 (let ,(cl-first list)
34 (setf (symbol-function ',reset-fn)
35 (lambda ()
36 ,@(cl-second list))))
37 ,@(cl-third list)
38 ',reset-fn)))
39
40;; test
41
42(setq fn (remember-set display-fill-column-indicator-mode disable))
43(funcall fn)