Function: eshell-next-prompt

eshell-next-prompt is an interactive and byte-compiled function defined in em-prompt.el.gz.

Signature

(eshell-next-prompt &optional N)

Documentation

Move to end of Nth next prompt in the buffer.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-prompt.el.gz
(defun eshell-next-prompt (&optional n)
  "Move to end of Nth next prompt in the buffer."
  (interactive "p")
  (unless n (setq n 1))
  ;; First, move point to our starting position: the end of the
  ;; current prompt (aka the beginning of the input), if any.  (The
  ;; welcome message and output from commands don't count as having a
  ;; current prompt.)
  (pcase (get-text-property (point) 'field)
    ('command-output)
    ('prompt (goto-char (field-end)))
    (_ (when-let* ((match (text-property-search-backward 'field 'prompt t)))
         (goto-char (prop-match-end match)))))
  ;; Now, move forward/backward to our destination prompt.
  (if (natnump n)
      (while (and (> n 0)
                  (text-property-search-forward 'field 'prompt t))
        (setq n (1- n)))
    (let (match this-match)
      ;; Go to the beginning of the current prompt.
      (goto-char (field-beginning (point) t))
      (while (and (< n 0)
                  (setq this-match (text-property-search-backward
                                    'field 'prompt t)))
        (setq match this-match
              n (1+ n)))
      (when match
        (goto-char (prop-match-end match))))))