From: Jim Porter Date: Wed, 23 Jul 2025 05:24:15 +0000 (-0700) Subject: Handle Eshell prompts where stickiness properties are 't' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=677b5270f15b6b29cc979cb3cd09e81ee896e704;p=emacs.git Handle Eshell prompts where stickiness properties are 't' Previously, this signaled an error, breaking the prompt (bug#79059). * lisp/eshell/em-prompt.el (eshell--append-text-property): Don't append to non-list property values. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test/field-properties/merge-stickiness): Adapt test. (cherry picked from commit 0d752f15b86dd3e5329a3f6d4a92e9870a6b8437) --- diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 7dbacc01f5d..7e2a9ed02c8 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -123,13 +123,16 @@ arriving, or after." "Append to a text property from START to END. PROP is the text property to append to, and VALUE is the list of property values to append. OBJECT is the object to propertize, as with -`put-text-property' (which see)." - (let (next) +`put-text-property' (which see). + +If PROP's value is not a list at any position between START and END, +this function leaves its value at those positions unchanged." + (let (next old-value) (while (< start end) - (setq next (next-single-property-change start prop object end)) - (put-text-property start next prop - (append (get-text-property start prop object) value) - object) + (setq next (next-single-property-change start prop object end) + old-value (get-text-property start prop object)) + (when (listp old-value) + (put-text-property start next prop (append old-value value) object)) (setq start next)))) (defun eshell-emit-prompt () diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 73cd6b14478..ed2cd02a516 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -91,8 +91,10 @@ This tests the case when `eshell-highlight-prompt' is nil." "Check that stickiness properties are properly merged on Eshell prompts." (let ((eshell-prompt-function (lambda () - (concat (propertize (eshell/pwd) 'front-sticky '(front)) - (propertize "$ " 'rear-nonsticky '(rear)))))) + (concat (propertize (eshell/pwd) + 'front-sticky '(front) 'rear-nonsticky t) + (propertize "$ " + 'front-sticky t 'rear-nonsticky '(rear)))))) (with-temp-eshell (eshell-insert-command "echo hello") (let ((last-prompt (field-string (1- eshell-last-input-start)))) @@ -105,13 +107,13 @@ This tests the case when `eshell-highlight-prompt' is nil." 'field 'prompt 'font-lock-face 'eshell-prompt 'front-sticky '(front read-only font-lock-face field) - 'rear-nonsticky '(read-only font-lock-face field)) + 'rear-nonsticky t) (propertize "$ " 'read-only t 'field 'prompt 'font-lock-face 'eshell-prompt - 'front-sticky '(read-only font-lock-face field) + 'front-sticky t 'rear-nonsticky '(rear read-only font-lock-face field))))))))) (ert-deftest em-prompt-test/after-failure ()