Function: easy-mmode--next

easy-mmode--next is a byte-compiled function defined in easy-mmode.el.gz.

Signature

(easy-mmode--next RE NAME COUNT &optional ENDFUN NARROWFUN)

Documentation

Go to the next COUNT'th occurrence of RE.

If none, error with NAME.

ENDFUN and NARROWFUN are treated like in easy-mmode-define-navigation.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/easy-mmode.el.gz
(defun easy-mmode--next (re name count &optional endfun narrowfun)
  "Go to the next COUNT'th occurrence of RE.

If none, error with NAME.

ENDFUN and NARROWFUN are treated like in `easy-mmode-define-navigation'."
  (unless count (setq count 1))
  (if (< count 0) (easy-mmode--prev re name (- count) endfun narrowfun)
    (if (looking-at re) (setq count (1+ count)))
    (let ((re-narrow (and narrowfun (prog1 (buffer-narrowed-p) (widen)))))
      (if (not (re-search-forward re nil t count))
          (if (looking-at re)
              (goto-char (or (if endfun (funcall endfun)) (point-max)))
            (user-error "No next %s" name))
        (goto-char (match-beginning 0))
        (when (and (eq (current-buffer) (window-buffer))
                   (called-interactively-p 'interactive))
          (let ((endpt (or (save-excursion
                             (if endfun (funcall endfun)
                               (re-search-forward re nil t 2)))
                           (point-max))))
            (unless (pos-visible-in-window-p endpt nil t)
              (let ((ws (window-start)))
                (recenter '(0))
                (if (< (window-start) ws)
                    ;; recenter scrolled in the wrong direction!
                    (set-window-start nil ws)))))))
      (when re-narrow (funcall narrowfun)))))