Provide our own implementation of paragraph navigation in Eshell
This lets us finally obsolete 'eshell-prompt-regexp', making it simpler for users to customize their prompts. * lisp/eshell/em-prompt.el (eshell-prompt-function): Update docstring. (eshell-prompt-regexp): Make obsolete. (eshell-prompt-initialize): Remove 'eshell-prompt-regexp' code. (eshell-prompt-mode-map): Remap paragraph navigation commands to... (eshell-forward-paragraph, eshell-backward-paragraph): ... these new commands.
This commit is contained in:
parent
5a430f90c1
commit
6ae2b74ed2
1 changed files with 21 additions and 16 deletions
|
@ -51,21 +51,15 @@ as is common with most shells."
|
|||
(lambda ()
|
||||
(concat (abbreviate-file-name (eshell/pwd))
|
||||
(if (= (file-user-uid) 0) " # " " $ ")))
|
||||
"A function that returns the Eshell prompt string.
|
||||
Make sure to update `eshell-prompt-regexp' so that it will match your
|
||||
prompt."
|
||||
"A function that returns the Eshell prompt string."
|
||||
:type 'function
|
||||
:group 'eshell-prompt)
|
||||
|
||||
(defcustom eshell-prompt-regexp "^[^#$\n]* [#$] "
|
||||
"A regexp which fully matches your Eshell prompt.
|
||||
This is useful for navigating by paragraph using \
|
||||
\\[forward-paragraph] and \\[backward-paragraph].
|
||||
|
||||
If this variable is changed, all Eshell buffers must be exited
|
||||
and re-entered for it to take effect."
|
||||
"A regexp which fully matches your Eshell prompt."
|
||||
:type 'regexp
|
||||
:group 'eshell-prompt)
|
||||
(make-obsolete-variable 'eshell-prompt-regexp nil "30.1")
|
||||
|
||||
(defcustom eshell-highlight-prompt t
|
||||
"If non-nil, Eshell should highlight the prompt."
|
||||
|
@ -98,8 +92,10 @@ arriving, or after."
|
|||
:group 'eshell-prompt)
|
||||
|
||||
(defvar-keymap eshell-prompt-mode-map
|
||||
"C-c C-n" #'eshell-next-prompt
|
||||
"C-c C-p" #'eshell-previous-prompt)
|
||||
"C-c C-n" #'eshell-next-prompt
|
||||
"C-c C-p" #'eshell-previous-prompt
|
||||
"<remap> <forward-paragraph>" #'eshell-forward-paragraph
|
||||
"<remap> <backward-paragraph>" #'eshell-backward-paragraph)
|
||||
|
||||
(defvar-keymap eshell-prompt-repeat-map
|
||||
:doc "Keymap to repeat eshell-prompt key sequences. Used in `repeat-mode'."
|
||||
|
@ -119,11 +115,6 @@ arriving, or after."
|
|||
"Initialize the prompting code."
|
||||
(unless eshell-non-interactive-p
|
||||
(add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t)
|
||||
|
||||
(make-local-variable 'eshell-prompt-regexp)
|
||||
(if eshell-prompt-regexp
|
||||
(setq-local paragraph-start eshell-prompt-regexp))
|
||||
|
||||
(eshell-prompt-mode)))
|
||||
|
||||
(defun eshell-emit-prompt ()
|
||||
|
@ -172,6 +163,20 @@ negative, find the Nth next match."
|
|||
(interactive (eshell-regexp-arg "Backward input matching (regexp): "))
|
||||
(eshell-forward-matching-input regexp (- arg)))
|
||||
|
||||
(defun eshell-forward-paragraph (&optional n)
|
||||
"Move to the beginning of the Nth next prompt in the buffer.
|
||||
Like `forward-paragraph', but navigates using fields."
|
||||
(interactive "p")
|
||||
(eshell-next-prompt n)
|
||||
(goto-char (field-beginning (point) t)))
|
||||
|
||||
(defun eshell-backward-paragraph (&optional n)
|
||||
"Move to the beginning of the Nth previous prompt in the buffer.
|
||||
Like `backward-paragraph', but navigates using fields."
|
||||
(interactive "p")
|
||||
(eshell-previous-prompt n)
|
||||
(goto-char (field-beginning (point) t)))
|
||||
|
||||
(defun eshell-next-prompt (&optional n)
|
||||
"Move to end of Nth next prompt in the buffer."
|
||||
(interactive "p")
|
||||
|
|
Loading…
Add table
Reference in a new issue