emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/focus ef5f7fc892 45/82: Cleaned up `focus-next-thing' and


From: ELPA Syncer
Subject: [nongnu] elpa/focus ef5f7fc892 45/82: Cleaned up `focus-next-thing' and `focus-prev-thing'
Date: Tue, 6 Sep 2022 04:58:57 -0400 (EDT)

branch: elpa/focus
commit ef5f7fc892f47c83812cdc3f7970991c260f7176
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>

    Cleaned up `focus-next-thing' and `focus-prev-thing'
---
 focus.el | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/focus.el b/focus.el
index 31e4b2b53c..daae08220d 100644
--- a/focus.el
+++ b/focus.el
@@ -162,19 +162,26 @@ deleted, and `focus-move-focus' is removed from 
`post-command-hook'."
   (progn (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
          (remove-hook 'post-command-hook 'focus-move-focus t)))
 
+(defun focus-goto-thing (bounds)
+  "Move point to the middle of BOUNDS."
+  (when bounds
+    (goto-char (/ (+ (car bounds) (cdr bounds)) 2))
+    (recenter nil)))
+
 (defun focus-next-thing (&optional n)
   "Moves the point to the middle of the Nth next thing."
   (interactive "p")
-  (forward-thing (focus-get-thing) (+ 1 n))
-  (let ((bounds (focus-bounds)))
-    (when bounds
-      (goto-char (/ (+ (car bounds) (cdr bounds)) 2))
-      (recenter nil))))
+  (let ((current-bounds (focus-bounds))
+        (thing (focus-get-thing)))
+    (forward-thing thing n)
+    (when (equal current-bounds (focus-bounds))
+      (forward-thing thing (signum n)))
+    (focus-goto-thing (focus-bounds))))
 
 (defun focus-prev-thing (&optional n)
   "Moves the point to the middle of the Nth previous thing."
   (interactive "p")
-  (focus-next-thing (- (+ 2 n))))
+  (focus-next-thing (- n)))
 
 (defun focus-read-only-hide-cursor (&optional buffer)
   "Hide the cursor.
@@ -182,8 +189,8 @@ This function is triggered by the 
`focus-read-only-blink-timer',
 when `focus-read-only-mode' is activated."
   (with-current-buffer (or buffer (current-buffer))
     (when (and focus-read-only-mode (not (null focus-read-only-blink-timer)))
-        (setq focus-read-only-blink-timer nil)
-        (setq cursor-type nil))))
+      (setq focus-read-only-blink-timer nil)
+      (setq cursor-type nil))))
 
 (defun focus-read-only-cursor-blink ()
   "Make the cursor visible for `focus-read-only-blink-seconds'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]