summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-28 17:25:16 -0600
committerCase Duckworth2022-01-28 17:25:16 -0600
commit702502bbdd83619abd1f11c2ff76eea1bd1d9cb2 (patch)
treea328137c6d70cfefdd3bbd265f4114fc0c9f5e82 /lisp
parentDon't pad region (diff)
downloademacs-702502bbdd83619abd1f11c2ff76eea1bd1d9cb2.tar.gz
emacs-702502bbdd83619abd1f11c2ff76eea1bd1d9cb2.zip
Allow +open-paragraph to open a paragraph above
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el28
1 files changed, 23 insertions, 5 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index d805a10..c2f9767 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -131,19 +131,24 @@ active, or else the entire buffer."
131 (= (line-beginning-position) (line-end-position))) 131 (= (line-beginning-position) (line-end-position)))
132 (insert "\n"))))) 132 (insert "\n")))))
133 133
134(defun +open-paragraph () 134(defun +open-paragraph (&optional arg)
135 "Open a paragraph after paragraph at point. 135 "Open a paragraph after paragraph at point.
136A paragraph is defined as continguous non-empty lines of text 136A paragraph is defined as continguous non-empty lines of text
137surrounded by empty lines, so opening a paragraph means to make 137surrounded by empty lines, so opening a paragraph means to make
138three blank lines, then place the point on the second one." 138three blank lines, then place the point on the second one.
139 (interactive "*") 139
140Called with prefix ARG, open a paragraph before point."
141 ;; TODO: Take an integer as ARG, allowing for skipping paragraphs up and down.
142 (interactive "*P")
143 ;; TODO: add `+open-paragraph-ignore-modes'
140 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode) 144 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode)
141 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because 145 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because
142 ;; that's weird with org, and I'm guessing other modes too. 146 ;; that's weird with org, and I'm guessing other modes too.
147 (unless (looking-at "^$") (forward-line (if arg -1 +1)))
143 (while (and (not (looking-at "^$")) 148 (while (and (not (looking-at "^$"))
144 (< (point) (point-max))) 149 (= 0 (forward-line (if arg -1 +1)))))
145 (forward-line 1))
146 (newline) 150 (newline)
151 (when arg (newline) (forward-line -2))
147 (delete-blank-lines) 152 (delete-blank-lines)
148 (newline 2) 153 (newline 2)
149 (previous-line))) 154 (previous-line)))
@@ -241,5 +246,18 @@ UNIT can be one of :kb, :mb, :gb, :tb, :pb, :eb, :zb, :yb; :kib, :mib, :gib,
241 nil 246 nil
242 `((,keyword-regexp 1 'font-lock-todo-face prepend))))) 247 `((,keyword-regexp 1 'font-lock-todo-face prepend)))))
243 248
249;; I don't use this much but I always forget the exact implementation, so this
250;; is more to remember than anything else.
251(defmacro setc (&rest vars-and-vals)
252 "Set VARS-AND-VALS by customizing them or using set-default.
253Use like `setq'."
254 `(progn ,@(cl-loop for (var val) on vars-and-vals by #'cddr
255 if (null val) return (user-error "Not enough arguments")
256 collecting `(funcall (or (get ',var 'custom-get)
257 #'set-default)
258 ',var ',val)
259 into ret
260 finally return ret)))
261
244(provide 'acdw) 262(provide 'acdw)
245;;; acdw.el ends here 263;;; acdw.el ends here