diff options
| author | Stefan Monnier | 2000-11-09 23:51:59 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-11-09 23:51:59 +0000 |
| commit | eed083e697727e45cdbb5765be9cbca82f1ef413 (patch) | |
| tree | d6d3b4b8ae4618d5e9f53b2967c9c03faef18d21 | |
| parent | bd02b8e072bc5b67494ee146e652cfb5b411976a (diff) | |
| download | emacs-eed083e697727e45cdbb5765be9cbca82f1ef413.tar.gz emacs-eed083e697727e45cdbb5765be9cbca82f1ef413.zip | |
(easy-mmode-define-navigation):
Allow `next' to jump to after the end of the last match.
| -rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 00a941c81b9..e3c82e445de 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el | |||
| @@ -519,7 +519,7 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards." | |||
| 519 | (defmacro easy-mmode-define-navigation (base re &optional name endfun) | 519 | (defmacro easy-mmode-define-navigation (base re &optional name endfun) |
| 520 | "Define BASE-next and BASE-prev to navigate in the buffer. | 520 | "Define BASE-next and BASE-prev to navigate in the buffer. |
| 521 | RE determines the places the commands should move point to. | 521 | RE determines the places the commands should move point to. |
| 522 | NAME should describe the entities matched by RE and is used to build | 522 | NAME should describe the entities matched by RE. It is used to build |
| 523 | the docstrings of the two functions. | 523 | the docstrings of the two functions. |
| 524 | BASE-next also tries to make sure that the whole entry is visible by | 524 | BASE-next also tries to make sure that the whole entry is visible by |
| 525 | searching for its end (by calling ENDFUN if provided or by looking for | 525 | searching for its end (by calling ENDFUN if provided or by looking for |
| @@ -538,16 +538,18 @@ ENDFUN should return the end position (with or without moving point)." | |||
| 538 | (unless count (setq count 1)) | 538 | (unless count (setq count 1)) |
| 539 | (if (< count 0) (,prev-sym (- count)) | 539 | (if (< count 0) (,prev-sym (- count)) |
| 540 | (if (looking-at ,re) (incf count)) | 540 | (if (looking-at ,re) (incf count)) |
| 541 | (unless (re-search-forward ,re nil t count) | 541 | (if (not (re-search-forward ,re nil t count)) |
| 542 | (error ,(format "No next %s" name))) | 542 | (if (looking-at ,re) |
| 543 | (goto-char (match-beginning 0)) | 543 | (goto-char (or ,(if endfun `(,endfun)) (point-max))) |
| 544 | (when (eq (current-buffer) (window-buffer (selected-window))) | 544 | (error ,(format "No next %s" name))) |
| 545 | (let ((endpt (or (save-excursion | 545 | (goto-char (match-beginning 0)) |
| 546 | ,(if endfun `(,endfun) | 546 | (when (eq (current-buffer) (window-buffer (selected-window))) |
| 547 | `(re-search-forward ,re nil t 2))) | 547 | (let ((endpt (or (save-excursion |
| 548 | (point-max)))) | 548 | ,(if endfun `(,endfun) |
| 549 | (unless (<= endpt (window-end)) | 549 | `(re-search-forward ,re nil t 2))) |
| 550 | (recenter '(0))))))) | 550 | (point-max)))) |
| 551 | (unless (pos-visible-in-window-p endpt nil t) | ||
| 552 | (recenter '(0)))))))) | ||
| 551 | (defun ,prev-sym (&optional count) | 553 | (defun ,prev-sym (&optional count) |
| 552 | ,(format "Go to the previous COUNT'th %s" (or name base-name)) | 554 | ,(format "Go to the previous COUNT'th %s" (or name base-name)) |
| 553 | (interactive) | 555 | (interactive) |