]> code.delx.au - gnu-emacs/blobdiff - lisp/comint.el
Preserve face text properties in comint prompt.
[gnu-emacs] / lisp / comint.el
index 722a42d6af2bbbaf23b69212af359dc21aa56526..31649ff31cae140c2ee312e72a2e9422b45f8d83 100644 (file)
@@ -1930,10 +1930,10 @@ the start, the cdr to the end of the last prompt recognized.")
 Freezes the `font-lock-face' text property in place."
   (when comint-last-prompt
     (with-silent-modifications
-      (add-text-properties
+      (font-lock-prepend-text-property
        (car comint-last-prompt)
        (cdr comint-last-prompt)
-       '(font-lock-face comint-highlight-prompt)))
+       'font-lock-face 'comint-highlight-prompt))
     ;; Reset comint-last-prompt so later on comint-output-filter does
     ;; not remove the font-lock-face text property of the previous
     ;; (this) prompt.
@@ -2084,14 +2084,19 @@ Make backspaces delete the previous character."
                  (add-text-properties prompt-start (point)
                                       '(read-only t front-sticky (read-only)))))
              (when comint-last-prompt
-               (remove-text-properties (car comint-last-prompt)
-                                       (cdr comint-last-prompt)
-                                       '(font-lock-face)))
+               (with-silent-modifications
+                 (font-lock--remove-face-from-text-property
+                  (car comint-last-prompt)
+                  (cdr comint-last-prompt)
+                  'font-lock-face
+                  'comint-highlight-prompt)))
              (setq comint-last-prompt
                    (cons (copy-marker prompt-start) (point-marker)))
-             (add-text-properties prompt-start (point)
-                                  '(rear-nonsticky t
-                                    font-lock-face comint-highlight-prompt)))
+             (with-silent-modifications
+               (font-lock-prepend-text-property prompt-start (point)
+                                                'font-lock-face
+                                                'comint-highlight-prompt)
+               (add-text-properties prompt-start (point) '(rear-nonsticky t))))
            (goto-char saved-point)))))))
 
 (defun comint-preinput-scroll-to-bottom ()
@@ -2274,8 +2279,6 @@ a buffer local variable."
       ;; Use comint-prompt-regexp
       (save-excursion
        (beginning-of-line)
-       (unless (looking-at comint-prompt-regexp)
-         (re-search-backward comint-prompt-regexp nil t))
        (comint-skip-prompt)
        (point))
     ;; Use input fields.  Note that, unlike the behavior of
@@ -2285,7 +2288,10 @@ a buffer local variable."
     ;; if there are two fields on a line, then the first one is the
     ;; prompt, and the second one is an input field, and is front-sticky
     ;; (as input fields should be).
-    (constrain-to-field (field-beginning) (line-end-position))))
+    (constrain-to-field (if (eq (field-at-pos (point)) 'output)
+                            (line-beginning-position)
+                          (field-beginning))
+                        (line-end-position))))
 
 (defun comint-bol (&optional arg)
   "Go to the beginning of line, then skip past the prompt, if any.