diff options
| author | Jim Porter | 2024-11-07 10:08:33 -0800 |
|---|---|---|
| committer | Jim Porter | 2024-11-14 09:19:31 -0800 |
| commit | df288d2e4148e6e72f21752a510f98536e7705ac (patch) | |
| tree | 33b272e891ecababf896a7b0da46b640146ded8f /lisp/eshell | |
| parent | e30c83e166634e8cdfc9577b982deb7cc2619067 (diff) | |
| download | emacs-df288d2e4148e6e72f21752a510f98536e7705ac.tar.gz emacs-df288d2e4148e6e72f21752a510f98536e7705ac.zip | |
Don't clobber stickiness text properties when printing Eshell prompt
* lisp/eshell/em-prompt.el (eshell--append-text-property): New
function...
(eshell-emit-prompt): ... use it.
* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test/field-properties/merge-stickiness): New test.
(em-prompt-test/field-properties, em-prompt-test/after-failure): Reorder
stickiness values (bug#74230).
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-prompt.el | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index de62b5c7d97..37970ac0ba5 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el | |||
| @@ -119,6 +119,19 @@ arriving, or after." | |||
| 119 | (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t) | 119 | (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t) |
| 120 | (eshell-prompt-mode))) | 120 | (eshell-prompt-mode))) |
| 121 | 121 | ||
| 122 | (defun eshell--append-text-property (start end prop value &optional object) | ||
| 123 | "Append to a text property from START to END. | ||
| 124 | PROP is the text property to append to, and VALUE is the list of | ||
| 125 | property values to append. OBJECT is the object to propertize, as with | ||
| 126 | `put-text-property' (which see)." | ||
| 127 | (let (next) | ||
| 128 | (while (< start end) | ||
| 129 | (setq next (next-single-property-change start prop object end)) | ||
| 130 | (put-text-property start next prop | ||
| 131 | (append (get-text-property start prop object) value) | ||
| 132 | object) | ||
| 133 | (setq start next)))) | ||
| 134 | |||
| 122 | (defun eshell-emit-prompt () | 135 | (defun eshell-emit-prompt () |
| 123 | "Emit a prompt if eshell is being used interactively." | 136 | "Emit a prompt if eshell is being used interactively." |
| 124 | (when (boundp 'ansi-color-context-region) | 137 | (when (boundp 'ansi-color-context-region) |
| @@ -126,19 +139,16 @@ arriving, or after." | |||
| 126 | (run-hooks 'eshell-before-prompt-hook) | 139 | (run-hooks 'eshell-before-prompt-hook) |
| 127 | (if (not eshell-prompt-function) | 140 | (if (not eshell-prompt-function) |
| 128 | (set-marker eshell-last-output-end (point)) | 141 | (set-marker eshell-last-output-end (point)) |
| 129 | (let ((prompt (funcall eshell-prompt-function))) | 142 | (let* ((prompt (funcall eshell-prompt-function)) |
| 130 | (add-text-properties | 143 | (len (length prompt)) |
| 131 | 0 (length prompt) | 144 | (sticky-props '(field))) |
| 132 | (if eshell-highlight-prompt | 145 | (put-text-property 0 len 'field 'prompt prompt) |
| 133 | '( read-only t | 146 | (when eshell-highlight-prompt |
| 134 | field prompt | 147 | (add-text-properties |
| 135 | font-lock-face eshell-prompt | 148 | 0 len '(read-only t font-lock-face eshell-prompt) prompt) |
| 136 | front-sticky (read-only field font-lock-face) | 149 | (setq sticky-props `(read-only font-lock-face . ,sticky-props))) |
| 137 | rear-nonsticky (read-only field font-lock-face)) | 150 | (eshell--append-text-property 0 len 'front-sticky sticky-props prompt) |
| 138 | '( field prompt | 151 | (eshell--append-text-property 0 len 'rear-nonsticky sticky-props prompt) |
| 139 | front-sticky (field) | ||
| 140 | rear-nonsticky (field))) | ||
| 141 | prompt) | ||
| 142 | (eshell-interactive-filter nil prompt))) | 152 | (eshell-interactive-filter nil prompt))) |
| 143 | (run-hooks 'eshell-after-prompt-hook)) | 153 | (run-hooks 'eshell-after-prompt-hook)) |
| 144 | 154 | ||