Function: easy-mmode--prev

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

Signature

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

Documentation

Go to the COUNT'th previous 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
;;;
;;; easy-mmode-define-navigation
;;;

(defun easy-mmode--prev (re name count &optional endfun narrowfun)
  "Go to the COUNT'th previous 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--next re name (- count) endfun narrowfun)
    (let ((re-narrow (and narrowfun (prog1 (buffer-narrowed-p) (widen)))))
      ;; If point is inside a match for RE, move to its beginning like
      ;; `backward-sexp' and other movement commands.
      (when (and (not (zerop count))
                 (save-excursion
                   ;; Make sure we're out of the current match if any.
                   (goto-char (if (re-search-backward re nil t 1)
                                  (match-end 0) (point-min)))
                   (re-search-forward re nil t 1))
                 (< (match-beginning 0) (point) (match-end 0)))
        (goto-char (match-beginning 0))
        (setq count (1- count)))
      (unless (re-search-backward re nil t count)
        (user-error "No previous %s" name))
      (when re-narrow (funcall narrowfun)))))