Skip to content

Commit

Permalink
Merge pull request #25 from Fuco1/fix/point-jumping-after-narrow
Browse files Browse the repository at this point in the history
fix: preserve point before widening and re-narrowing
  • Loading branch information
fgeller authored Feb 17, 2023
2 parents b9bb6e4 + 7c4bf1e commit ad788d7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions highlight-thing.el
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,16 @@ functionality."

(defun highlight-thing-buffer-do (buf regex)
(with-current-buffer buf
(save-restriction
(widen)
(cond ((highlight-thing-should-narrow-to-defun-p)
(narrow-to-defun))
((highlight-thing-should-narrow-to-region-p)
(let ((bounds (highlight-thing-narrow-bounds)))
(narrow-to-region (car bounds) (cdr bounds)))))
(highlight-thing-call-highlight-regexp regex)
(when highlight-thing-exclude-thing-under-point (highlight-thing-remove-overlays-at-point regex)))))
(save-excursion
(save-restriction
(widen)
(cond ((highlight-thing-should-narrow-to-defun-p)
(narrow-to-defun))
((highlight-thing-should-narrow-to-region-p)
(let ((bounds (highlight-thing-narrow-bounds)))
(narrow-to-region (car bounds) (cdr bounds)))))
(highlight-thing-call-highlight-regexp regex)
(when highlight-thing-exclude-thing-under-point (highlight-thing-remove-overlays-at-point regex))))))

(defun highlight-thing-call-highlight-regexp (regex)
(unless (string= "" regex)
Expand Down

0 comments on commit ad788d7

Please sign in to comment.