summaryrefslogtreecommitdiff
path: root/lisp/eshell/em-prompt.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell/em-prompt.el')
-rw-r--r--lisp/eshell/em-prompt.el33
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 76dd13ff842..a1a91e7d634 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -1,6 +1,6 @@
;;; em-prompt.el --- command prompts -*- lexical-binding:t -*-
-;; Copyright (C) 1999-2017 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
@@ -48,10 +48,9 @@ as is common with most shells."
(autoload 'eshell/pwd "em-dirs")
(defcustom eshell-prompt-function
- (function
- (lambda ()
- (concat (abbreviate-file-name (eshell/pwd))
- (if (= (user-uid) 0) " # " " $ "))))
+ (lambda ()
+ (concat (abbreviate-file-name (eshell/pwd))
+ (if (= (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."
@@ -80,7 +79,6 @@ re-entered for it to take effect."
For highlighting other kinds of strings -- similar to shell mode's
behavior -- simply use an output filer which changes text properties."
:group 'eshell-prompt)
-(define-obsolete-face-alias 'eshell-prompt-face 'eshell-prompt "22.1")
(defcustom eshell-before-prompt-hook nil
"A list of functions to call before outputting the prompt."
@@ -98,22 +96,29 @@ arriving, or after."
:options '(eshell-show-maximum-output)
:group 'eshell-prompt)
+(defvar-keymap eshell-prompt-mode-map
+ "C-c C-n" #'eshell-next-prompt
+ "C-c C-p" #'eshell-previous-prompt)
+
;;; Functions:
-(defun eshell-prompt-initialize ()
+(define-minor-mode eshell-prompt-mode
+ "Minor mode for eshell-prompt module.
+
+\\{eshell-prompt-mode-map}"
+ :keymap eshell-prompt-mode-map)
+
+(defun eshell-prompt-initialize () ;Called from `eshell-mode' via intern-soft!
"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
- (set (make-local-variable 'paragraph-start) eshell-prompt-regexp))
-
- (set (make-local-variable 'eshell-skip-prompt-function)
- 'eshell-skip-prompt)
+ (setq-local paragraph-start eshell-prompt-regexp))
- (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt)
- (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt)))
+ (setq-local eshell-skip-prompt-function #'eshell-skip-prompt)
+ (eshell-prompt-mode)))
(defun eshell-emit-prompt ()
"Emit a prompt if eshell is being used interactively."
@@ -178,7 +183,7 @@ See `eshell-prompt-regexp'."
"Move to end of Nth previous prompt in the buffer.
See `eshell-prompt-regexp'."
(interactive "p")
- (beginning-of-line) ; Don't count prompt on current line.
+ (forward-line 0) ; Don't count prompt on current line.
(eshell-next-prompt (- n)))
(defun eshell-skip-prompt ()