From c0f0555a6b9f3818f29e6394db0b45d6d5675edf Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Wed, 23 Mar 2022 18:14:20 +0100 Subject: [PATCH] Don't move to bob/eob if wrapping enabled and no matches Closes #67. --- hl-todo.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hl-todo.el b/hl-todo.el index ea9345d..4f03d47 100644 --- a/hl-todo.el +++ b/hl-todo.el @@ -296,9 +296,12 @@ A negative argument means move backward that many keywords." (user-error "No more matches"))))) (cl-decf arg)) (when (> arg 0) - (goto-char (point-min)) - (let ((hl-todo-wrap-movement nil)) - (hl-todo-next arg))))) + (let ((pos (save-excursion + (goto-char (point-min)) + (let ((hl-todo-wrap-movement nil)) + (hl-todo-next arg)) + (point)))) + (goto-char pos))))) ;;;###autoload (defun hl-todo-previous (arg) @@ -320,9 +323,12 @@ A negative argument means move forward that many keywords." (goto-char (match-end 0)) (cl-decf arg)) (when (> arg 0) - (goto-char (point-max)) - (let ((hl-todo-wrap-movement nil)) - (hl-todo-previous arg))))) + (let ((pos (save-excursion + (goto-char (point-max)) + (let ((hl-todo-wrap-movement nil)) + (hl-todo-previous arg)) + (point)))) + (goto-char pos))))) ;;;###autoload (defun hl-todo-occur ()