From fe8985ae47234937fce348734dc1ec34a528acd7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 8 Feb 2022 20:59:33 -0600 Subject: Write +{forward,backward}-paragraph --- lisp/acdw.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 2b3cafc..99e5c1e 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -291,5 +291,25 @@ With optional ARG, kill all chat-related buffers first." )) (mapc #'call-interactively chat-functions)) +(defun +forward-paragraph (arg) + "Move forward ARG (simple) paragraphs. +A paragraph here is simply defined: it's a block of buffer that's +separated from others by two newlines." + (interactive "p") + (let ((direction (/ arg (abs arg)))) + (forward-line direction) + (while (not (or (bobp) + (eobp) + (= arg 0))) + (if (looking-at "^[ \f\t]*$") + (setq arg (- arg direction)) + (forward-line direction))))) + +(defun +backward-paragraph (arg) + "Move backward ARG (simple) paragraphs. +See `+forward-paragraph' for the behavior." + (interactive "p") + (+forward-paragraph (- arg))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81