summary refs log tree commit diff stats
path: root/lisp/acdw.el
diff options
context:
space:
mode:
authorCase Duckworth2022-01-06 18:04:18 -0600
committerCase Duckworth2022-01-06 18:04:18 -0600
commit1aa0df763136f38255416a2c3c3f2dd0d4c5327d (patch)
tree4fe8574334c85d8c402703c7429496708d755fc4 /lisp/acdw.el
parentFixup +defvar to be in line with defvar (diff)
parentAdd /POKE stub command (diff)
downloademacs-1aa0df763136f38255416a2c3c3f2dd0d4c5327d.tar.gz
emacs-1aa0df763136f38255416a2c3c3f2dd0d4c5327d.zip
Merge branch 'main' of https://tildegit.org/acdw/emacs
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r--lisp/acdw.el61
1 files changed, 60 insertions, 1 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 71905d2..8b9c7b9 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -44,7 +44,6 @@ the filesystem, unless INHIBIT-MKDIR is non-nil."
44 (make-directory (file-name-directory file-name) :parents)) 44 (make-directory (file-name-directory file-name) :parents))
45 file-name)))) 45 file-name))))
46 46
47
48(defun +suppress-messages (oldfn &rest args) ; from pkal 47(defun +suppress-messages (oldfn &rest args) ; from pkal
49 "Advice wrapper for suppressing `message'. 48 "Advice wrapper for suppressing `message'.
50OLDFN is the wrapped function, that is passed the arguments 49OLDFN is the wrapped function, that is passed the arguments
@@ -126,5 +125,65 @@ I keep forgetting how they differ."
126 (declare (doc-string 3)) 125 (declare (doc-string 3))
127 `(setq ,var ,value)) 126 `(setq ,var ,value))
128 127
128(defmacro +with-message (message &rest body)
129 "Execute BODY, with MESSAGE.
130If body executes without errors, MESSAGE...Done will be displayed."
131 ;; ^ TODO
132 `(prog1 (progn (message ,(concat message "..."))
133 ,@body)
134 (message ,(concat message "...Done."))))
135
136(defun +mapc-some-buffers (func &optional predicate)
137 "Perform FUNC on all buffers satisfied by PREDICATE.
138By default, act on all buffers.
139
140PREDICATE is a function called with one argument, the current
141buffer. FUNC is called with no arguments. Both are called
142within a `with-current-buffer' form."
143 (let ((pred (or predicate t)))
144 (dolist (buf (buffer-list))
145 (with-current-buffer buf
146 (when (funcall pred buf)
147 (funcall func))))))
148
149;; https://github.com/cstby/emacs.d/blob/main/init.el#L67
150(defun +clean-empty-lines (&optional begin end)
151 "Remove duplicate empty lines from BEGIN to END.
152Called interactively, this function acts on the region, if
153active, or else the entire buffer."
154 (interactive "*r")
155 (unless (region-active-p)
156 (setq begin (point-min)
157 end (save-excursion
158 (goto-char (point-max))
159 (skip-chars-backward "\n[:space:]")
160 (point))))
161 (save-excursion
162 (save-restriction
163 (narrow-to-region begin end)
164 (goto-char (point-min))
165 (while (re-search-forward "\n\n\n+" nil :move)
166 (replace-match "\n\n"))
167 ;; Insert a newline at the end.
168 (goto-char (point-max))
169 (unless (= (line-beginning-position) (line-end-position))
170 (insert "\n")))))
171
172(defun +open-paragraph ()
173 "Open a paragraph after paragraph at point.
174A paragraph is defined as continguous non-empty lines of text
175surrounded by empty lines, so opening a paragraph means to make
176three blank lines, then place the point on the second one."
177 (interactive "*")
178 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode)
179 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because
180 ;; that's weird with org, and I'm guessing other modes too.
181 (while (not (looking-at "^$"))
182 (forward-line 1))
183 (newline)
184 (delete-blank-lines)
185 (newline 2)
186 (previous-line)))
187
129(provide 'acdw) 188(provide 'acdw)
130;;; acdw.el ends here 189;;; acdw.el ends here