about summary refs log tree commit diff stats
path: root/lisp/acdw.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r--lisp/acdw.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index eab0719..2aa6c1f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -87,21 +87,6 @@ ARG). When called with multiple arguments or a list, it returns
87 (save-restriction 87 (save-restriction
88 (unfill-region (point-min) (point-max)))))) 88 (unfill-region (point-min) (point-max))))))
89 89
90(defun kill-ring-save-unfilled (start end &optional region)
91 "Unfill, kill, then re-fill the region defined by START and END positions.
92REGION is passed straight to `kill-ring-save'."
93 (interactive "*r")
94 (let ((sentence-end-double-space nil))
95 (unfill-region start end)
96 (kill-ring-save
97 ;; A quick hack to try and ameliorate the "Args out of range" error when
98 ;; `unfill-region' removes some newlines. I'm not sure if this will work
99 ;; if calling from Lisp or other such nonsense.
100 (max start (point-min))
101 (min end (point-max))
102 region))
103 (fill-region start end))
104
105(defmacro when-unfocused (name &rest forms) 90(defmacro when-unfocused (name &rest forms)
106 "Define a function NAME, executing FORMS, that fires when Emacs 91 "Define a function NAME, executing FORMS, that fires when Emacs
107is unfocused." 92is unfocused."
@@ -123,6 +108,22 @@ is unfocused."
123 ,@body) 108 ,@body)
124 (message "%s... Done." ,message))) 109 (message "%s... Done." ,message)))
125 110
111(defmacro with-eval-after-loads (files &rest body)
112 "Execute BODY after FILES are loaded.
113This macro simplifies `with-eval-after-load' for multiple nested
114features."
115 (declare (indent 1) (debug (form def-body)))
116 (waterfall-list 'with-eval-after-load files body))
117
118(defun waterfall-list (car list rest)
119 "Cons CAR with each element in LIST in a waterfall fashion, end with REST.
120For use with the `with-eval-after-loads' function."
121 (cond ((atom list) `(,car ',list ,@rest))
122 ((= 1 (length list)) `(,car ',(car list) ,@rest))
123 (t
124 `(,car ',(car list)
125 ,(waterfall-list car (cdr list) rest)))))
126
126 127
127;;; Comment-or-uncomment-sexp 128;;; Comment-or-uncomment-sexp
128;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html 129;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html