]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle Eshell prompts where stickiness properties are 't'
authorJim Porter <jporterbugs@gmail.com>
Wed, 23 Jul 2025 05:24:15 +0000 (22:24 -0700)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Jul 2025 08:12:35 +0000 (10:12 +0200)
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)

lisp/eshell/em-prompt.el
test/lisp/eshell/em-prompt-tests.el

index 7dbacc01f5da06fee992d208f823554fa284c165..7e2a9ed02c83a21279b448d829f00b5110e4aa71 100644 (file)
@@ -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 ()
index 73cd6b144784bcd5ac8f43e2e43bc80bf0f893af..ed2cd02a516c8434b4604c6c90e0f3dd5d0f0a0c 100644 (file)
@@ -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 ()