diff options
Diffstat (limited to 'eshell-conf.el')
| -rw-r--r-- | eshell-conf.el | 92 |
1 files changed, 71 insertions, 21 deletions
diff --git a/eshell-conf.el b/eshell-conf.el index c8c2605..216b003 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -95,6 +95,7 @@ (remove-hook 'eshell-post-command-hook #'eshell-current-command-stop t) (remove-hook 'eshell-mode-hook #'eshell-current-command-time-track)) +;; This is for GNU Emacs 30.2.50 of 2026-05-05 ;;;###autoload (defun durand-eshell-emit-prompt () "Emit a prompt if eshell is being used interactively. @@ -105,29 +106,75 @@ Add a time information at the beginning. -- Modified by Durand." (if (not eshell-prompt-function) (set-marker eshell-last-output-end (point)) (let ((prompt (funcall eshell-prompt-function))) - (and eshell-highlight-prompt - (add-text-properties 0 (length prompt) - '(read-only t - font-lock-face eshell-prompt - front-sticky (font-lock-face read-only) - rear-nonsticky (font-lock-face read-only)) - prompt)) - (eshell-interactive-print - (mapconcat #'identity - (delq - nil - (list - (cond ((> (length eshell-prompt-time-string) 0) - (propertize eshell-prompt-time-string - 'font-lock-face 'modus-themes-heading-1 - 'read-only t - 'front-sticky '(font-lock-face read-only) - 'rear-nonsticky '(font-lock-face read-only))) ) - prompt)) - " ")) + (add-text-properties + 0 (length prompt) + (if eshell-highlight-prompt + '( read-only t + field prompt + font-lock-face eshell-prompt + front-sticky (read-only field font-lock-face) + rear-nonsticky (read-only field font-lock-face)) + '( field prompt + front-sticky (field) + rear-nonsticky (field))) + prompt) + (eshell-interactive-filter + nil + (cond + ((not (string-empty-p eshell-prompt-time-string)) + (concat + (cond + (eshell-highlight-prompt + (propertize + (concat eshell-prompt-time-string (string 32)) + 'read-only t + 'field 'prompt + 'font-lock-face 'modus-themes-heading-1 + 'front-sticky '(read-only field font-lock-face) + 'rear-nonsticky '(read-only field font-lock-face))) + ((propertize + (concat eshell-prompt-time-string (string 32)) + 'field 'prompt + 'front-sticky '(field) + 'rear-nonsticky '(field)))) + prompt)) + (prompt))) (setq eshell-prompt-time-string ""))) (run-hooks 'eshell-after-prompt-hook)) +;; For Emacs 29 +;; (defun durand-eshell-emit-prompt () +;; "Emit a prompt if eshell is being used interactively. +;; Modified by Durand." +;; (when (boundp 'ansi-color-context-region) +;; (setq ansi-color-context-region nil)) +;; (run-hooks 'eshell-before-prompt-hook) +;; (if (not eshell-prompt-function) +;; (set-marker eshell-last-output-end (point)) +;; (let ((prompt (funcall eshell-prompt-function))) +;; (and eshell-highlight-prompt +;; (add-text-properties 0 (length prompt) +;; '(read-only t +;; font-lock-face eshell-prompt +;; front-sticky (font-lock-face read-only) +;; rear-nonsticky (font-lock-face read-only)) +;; prompt)) +;; (setq +;; prompt +;; (cond +;; ((not (string-empty-p eshell-prompt-time-string)) +;; (concat +;; (propertize +;; (concat eshell-prompt-time-string (string 32)) +;; 'read-only t +;; 'font-lock-face 'modus-themes-heading-1 +;; 'front-sticky '(font-lock-face read-only) +;; 'rear-nonsticky '(font-lock-face read-only)) +;; prompt)) +;; (prompt))) +;; (eshell-interactive-print prompt))) +;; (run-hooks 'eshell-after-prompt-hook)) + (advice-add #'eshell-emit-prompt :override #'durand-eshell-emit-prompt) ;;; Eshell sets the keymap in the major mode function @@ -179,7 +226,10 @@ Do NUM times `eshell-previous-prompt' before deleting." (interactive (list (cond ((null current-prefix-arg) 0) ((prefix-numeric-value current-prefix-arg))))) - (let ((inhibit-read-only t)) + ;; We have to set this to obtain the true line-beginning position, + ;; instead of the prompt start position. + (let ((inhibit-field-text-motion t) + (inhibit-read-only t)) (delete-region (point-min) (save-excursion |
