Cleaned up focus-next-thing' and focus-prev-thing'

This commit is contained in:
Lars Tveito 2015-05-24 17:47:39 +02:00
parent 6b9620a73d
commit ef5f7fc892

View File

@ -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.