(easy-mmode-define-navigation):
Allow `next' to jump to after the end of the last match.
This commit is contained in:
parent
bd02b8e072
commit
eed083e697
1 changed files with 13 additions and 11 deletions
|
@ -519,7 +519,7 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards."
|
||||||
(defmacro easy-mmode-define-navigation (base re &optional name endfun)
|
(defmacro easy-mmode-define-navigation (base re &optional name endfun)
|
||||||
"Define BASE-next and BASE-prev to navigate in the buffer.
|
"Define BASE-next and BASE-prev to navigate in the buffer.
|
||||||
RE determines the places the commands should move point to.
|
RE determines the places the commands should move point to.
|
||||||
NAME should describe the entities matched by RE and is used to build
|
NAME should describe the entities matched by RE. It is used to build
|
||||||
the docstrings of the two functions.
|
the docstrings of the two functions.
|
||||||
BASE-next also tries to make sure that the whole entry is visible by
|
BASE-next also tries to make sure that the whole entry is visible by
|
||||||
searching for its end (by calling ENDFUN if provided or by looking for
|
searching for its end (by calling ENDFUN if provided or by looking for
|
||||||
|
@ -538,7 +538,9 @@ ENDFUN should return the end position (with or without moving point)."
|
||||||
(unless count (setq count 1))
|
(unless count (setq count 1))
|
||||||
(if (< count 0) (,prev-sym (- count))
|
(if (< count 0) (,prev-sym (- count))
|
||||||
(if (looking-at ,re) (incf count))
|
(if (looking-at ,re) (incf count))
|
||||||
(unless (re-search-forward ,re nil t count)
|
(if (not (re-search-forward ,re nil t count))
|
||||||
|
(if (looking-at ,re)
|
||||||
|
(goto-char (or ,(if endfun `(,endfun)) (point-max)))
|
||||||
(error ,(format "No next %s" name)))
|
(error ,(format "No next %s" name)))
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
(when (eq (current-buffer) (window-buffer (selected-window)))
|
(when (eq (current-buffer) (window-buffer (selected-window)))
|
||||||
|
@ -546,8 +548,8 @@ ENDFUN should return the end position (with or without moving point)."
|
||||||
,(if endfun `(,endfun)
|
,(if endfun `(,endfun)
|
||||||
`(re-search-forward ,re nil t 2)))
|
`(re-search-forward ,re nil t 2)))
|
||||||
(point-max))))
|
(point-max))))
|
||||||
(unless (<= endpt (window-end))
|
(unless (pos-visible-in-window-p endpt nil t)
|
||||||
(recenter '(0)))))))
|
(recenter '(0))))))))
|
||||||
(defun ,prev-sym (&optional count)
|
(defun ,prev-sym (&optional count)
|
||||||
,(format "Go to the previous COUNT'th %s" (or name base-name))
|
,(format "Go to the previous COUNT'th %s" (or name base-name))
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue