Function: eshell-return-to-prompt

eshell-return-to-prompt is a byte-compiled function defined in em-hist.el.gz.

Signature

(eshell-return-to-prompt)

Documentation

Once a search string matches, insert it at the end and go there.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-hist.el.gz
(defun eshell-return-to-prompt ()
  "Once a search string matches, insert it at the end and go there."
  (setq isearch-other-end nil)
  (let ((found (eshell-test-imatch)) before)
    (while (and (not found)
		(setq before
		      (funcall (if isearch-forward
				   're-search-forward
				 're-search-backward)
			       isearch-string nil t)))
      (setq found (eshell-test-imatch)))
    (if (not found)
	(progn
	  (goto-char eshell-last-output-end)
	  (delete-region (point) (point-max)))
      (setq before (point))
      (let ((text (buffer-substring-no-properties
		   (point) (line-end-position)))
	    (orig (marker-position eshell-last-output-end)))
	(goto-char eshell-last-output-end)
	(delete-region (point) (point-max))
	(when (and text (> (length text) 0))
	  (insert text)
	  (put-text-property (1- (point)) (point)
			     'last-search-pos before)
	  (set-marker eshell-last-output-end orig)
	  (goto-char eshell-last-output-end))))))