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)) (progn (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
(remove-hook 'post-command-hook 'focus-move-focus t))) (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) (defun focus-next-thing (&optional n)
"Moves the point to the middle of the Nth next thing." "Moves the point to the middle of the Nth next thing."
(interactive "p") (interactive "p")
(forward-thing (focus-get-thing) (+ 1 n)) (let ((current-bounds (focus-bounds))
(let ((bounds (focus-bounds))) (thing (focus-get-thing)))
(when bounds (forward-thing thing n)
(goto-char (/ (+ (car bounds) (cdr bounds)) 2)) (when (equal current-bounds (focus-bounds))
(recenter nil)))) (forward-thing thing (signum n)))
(focus-goto-thing (focus-bounds))))
(defun focus-prev-thing (&optional n) (defun focus-prev-thing (&optional n)
"Moves the point to the middle of the Nth previous thing." "Moves the point to the middle of the Nth previous thing."
(interactive "p") (interactive "p")
(focus-next-thing (- (+ 2 n)))) (focus-next-thing (- n)))
(defun focus-read-only-hide-cursor (&optional buffer) (defun focus-read-only-hide-cursor (&optional buffer)
"Hide the cursor. "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." when `focus-read-only-mode' is activated."
(with-current-buffer (or buffer (current-buffer)) (with-current-buffer (or buffer (current-buffer))
(when (and focus-read-only-mode (not (null focus-read-only-blink-timer))) (when (and focus-read-only-mode (not (null focus-read-only-blink-timer)))
(setq focus-read-only-blink-timer nil) (setq focus-read-only-blink-timer nil)
(setq cursor-type nil)))) (setq cursor-type nil))))
(defun focus-read-only-cursor-blink () (defun focus-read-only-cursor-blink ()
"Make the cursor visible for `focus-read-only-blink-seconds'. "Make the cursor visible for `focus-read-only-blink-seconds'.