summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--view-conf.el39
1 files changed, 39 insertions, 0 deletions
diff --git a/view-conf.el b/view-conf.el
index f5dcda9..b58e04d 100644
--- a/view-conf.el
+++ b/view-conf.el
@@ -330,6 +330,43 @@ If ARG is non-nil, do the same for Bluetooth."
(define-key global-map (vector 3 ?w) #'durand-wifi-or-bluetooth)
+;;; moving by paragraphs
+
+;;;###autoload
+(defun durand-scroll-next-paragraph (&optional arg)
+ "Scroll so that the next ARG paragraph is at the top."
+ (interactive "p")
+ (let ((forward-p (> arg 0))
+ pos)
+ (save-excursion
+ (goto-char (window-start))
+ (cond
+ (forward-p
+ (while (> arg 0)
+ (cond
+ ((re-search-forward "^\\s-*$" (line-end-position) t)
+ (forward-line 1)))
+ (while (not (re-search-forward "^\\s-*$" (line-end-position) t))
+ (forward-line 1))
+ (setq arg (1- arg))))
+ (t
+ (while (< arg 0)
+ (cond
+ ((re-search-forward "^\\s-*$" (line-end-position) t)
+ (forward-line -1)))
+ (while (not (re-search-forward "^\\s-*$" (line-end-position) t))
+ (forward-line -1))
+ (setq arg (1+ arg)))))
+ (setq pos (point)))
+ (set-window-start (selected-window) pos)))
+
+;;;###autoload
+(defun durand-scroll-prev-paragraph (&optional arg)
+ "Scroll so that the previous ARG paragraph is at the top."
+ (interactive "p")
+ (cond ((numberp arg)) ((setq arg 1)))
+ (durand-scroll-next-paragraph (- arg)))
+
;;; focus mode
;;;###autoload
@@ -338,6 +375,8 @@ If ARG is non-nil, do the same for Bluetooth."
(define-key durand-focus-map (vector ?\s-v) #'view-mode)
(define-key durand-focus-map (vector ?\s-x) #'durand-focus)
+(define-key durand-focus-map (vector ?f) #'durand-scroll-next-paragraph)
+(define-key durand-focus-map (vector ?b) #'durand-scroll-prev-paragraph)
;;;###autoload
(define-minor-mode durand-focus