diff options
| author | Wolfgang Jenkner | 2015-03-27 02:54:39 +0100 |
|---|---|---|
| committer | Wolfgang Jenkner | 2015-03-27 03:47:08 +0100 |
| commit | 792d44b3c31d2a682607ab8b79ae7d26b7402f41 (patch) | |
| tree | dacaaf290f706944a8585d7932cf23cacbca24fc /lisp | |
| parent | 1d02107dab6f844a7c537bb5e98aff4e5f061246 (diff) | |
| download | emacs-792d44b3c31d2a682607ab8b79ae7d26b7402f41.tar.gz emacs-792d44b3c31d2a682607ab8b79ae7d26b7402f41.zip | |
Preserve face text properties in comint prompt.
Fixes: debbugs:20084
* lisp/font-lock.el (font-lock--remove-face-from-text-property): New
function. Adapted from the previously commented out
remove-single-text-property.
Remove previously unused and commented out auxiliary function
remove-text-property and obsolete comment.
* lisp/comint.el (comint-output-filter): Use it to remove
comint-highlight-prompt.
(comint-snapshot-last-prompt, comint-output-filter): Use
font-lock-prepend-text-property for comint-highlight-prompt.
* test/automated/textprop-tests.el: New file.
(textprop-tests-font-lock--remove-face-from-text-property): New test.
Thus, the original face text property of a prompt "candidate" (the
last line of an output chunk not ending with a newline) is
preserved. This amends the fix for bug#14744.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/comint.el | 21 | ||||
| -rw-r--r-- | lisp/font-lock.el | 58 |
3 files changed, 53 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0cc7bc6f702..b2d431c62cf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2015-03-27 Wolfgang Jenkner <wjenkner@inode.at> | ||
| 2 | |||
| 3 | * font-lock.el (font-lock--remove-face-from-text-property): New | ||
| 4 | function. Adapted from the previously commented out | ||
| 5 | remove-single-text-property. | ||
| 6 | Remove previously unused and commented out auxiliary function | ||
| 7 | remove-text-property and obsolete comment. | ||
| 8 | * comint.el (comint-output-filter): Use it to remove | ||
| 9 | comint-highlight-prompt. | ||
| 10 | (comint-snapshot-last-prompt, comint-output-filter): Use | ||
| 11 | font-lock-prepend-text-property for comint-highlight-prompt. | ||
| 12 | (Bug#20084) | ||
| 13 | |||
| 1 | 2015-03-26 Daniel Colascione <dancol@dancol.org> | 14 | 2015-03-26 Daniel Colascione <dancol@dancol.org> |
| 2 | * progmodes/python.el | 15 | * progmodes/python.el |
| 3 | (python-indent-guess-indent-offset-verbose): New defcustom. | 16 | (python-indent-guess-indent-offset-verbose): New defcustom. |
diff --git a/lisp/comint.el b/lisp/comint.el index b6944da355c..31649ff31ca 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1930,10 +1930,10 @@ the start, the cdr to the end of the last prompt recognized.") | |||
| 1930 | Freezes the `font-lock-face' text property in place." | 1930 | Freezes the `font-lock-face' text property in place." |
| 1931 | (when comint-last-prompt | 1931 | (when comint-last-prompt |
| 1932 | (with-silent-modifications | 1932 | (with-silent-modifications |
| 1933 | (add-text-properties | 1933 | (font-lock-prepend-text-property |
| 1934 | (car comint-last-prompt) | 1934 | (car comint-last-prompt) |
| 1935 | (cdr comint-last-prompt) | 1935 | (cdr comint-last-prompt) |
| 1936 | '(font-lock-face comint-highlight-prompt))) | 1936 | 'font-lock-face 'comint-highlight-prompt)) |
| 1937 | ;; Reset comint-last-prompt so later on comint-output-filter does | 1937 | ;; Reset comint-last-prompt so later on comint-output-filter does |
| 1938 | ;; not remove the font-lock-face text property of the previous | 1938 | ;; not remove the font-lock-face text property of the previous |
| 1939 | ;; (this) prompt. | 1939 | ;; (this) prompt. |
| @@ -2084,14 +2084,19 @@ Make backspaces delete the previous character." | |||
| 2084 | (add-text-properties prompt-start (point) | 2084 | (add-text-properties prompt-start (point) |
| 2085 | '(read-only t front-sticky (read-only))))) | 2085 | '(read-only t front-sticky (read-only))))) |
| 2086 | (when comint-last-prompt | 2086 | (when comint-last-prompt |
| 2087 | (remove-text-properties (car comint-last-prompt) | 2087 | (with-silent-modifications |
| 2088 | (cdr comint-last-prompt) | 2088 | (font-lock--remove-face-from-text-property |
| 2089 | '(font-lock-face))) | 2089 | (car comint-last-prompt) |
| 2090 | (cdr comint-last-prompt) | ||
| 2091 | 'font-lock-face | ||
| 2092 | 'comint-highlight-prompt))) | ||
| 2090 | (setq comint-last-prompt | 2093 | (setq comint-last-prompt |
| 2091 | (cons (copy-marker prompt-start) (point-marker))) | 2094 | (cons (copy-marker prompt-start) (point-marker))) |
| 2092 | (add-text-properties prompt-start (point) | 2095 | (with-silent-modifications |
| 2093 | '(rear-nonsticky t | 2096 | (font-lock-prepend-text-property prompt-start (point) |
| 2094 | font-lock-face comint-highlight-prompt))) | 2097 | 'font-lock-face |
| 2098 | 'comint-highlight-prompt) | ||
| 2099 | (add-text-properties prompt-start (point) '(rear-nonsticky t)))) | ||
| 2095 | (goto-char saved-point))))))) | 2100 | (goto-char saved-point))))))) |
| 2096 | 2101 | ||
| 2097 | (defun comint-preinput-scroll-to-bottom () | 2102 | (defun comint-preinput-scroll-to-bottom () |
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 1838a0f02b4..6c8392bc090 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -1418,37 +1418,33 @@ Optional argument OBJECT is the string or buffer containing the text." | |||
| 1418 | (put-text-property start next prop value object) | 1418 | (put-text-property start next prop value object) |
| 1419 | (setq start (text-property-any next end prop nil object))))) | 1419 | (setq start (text-property-any next end prop nil object))))) |
| 1420 | 1420 | ||
| 1421 | ;; For completeness: this is to `remove-text-properties' as `put-text-property' | 1421 | (defun font-lock--remove-face-from-text-property (start |
| 1422 | ;; is to `add-text-properties', etc. | 1422 | end |
| 1423 | ;;(defun remove-text-property (start end property &optional object) | 1423 | prop value &optional object) |
| 1424 | ;; "Remove a property from text from START to END. | 1424 | "Remove a specific property value from text from START to END. |
| 1425 | ;;Argument PROPERTY is the property to remove. | 1425 | Arguments PROP and VALUE specify the property and value to remove. The |
| 1426 | ;;Optional argument OBJECT is the string or buffer containing the text. | 1426 | resulting property values are not `eq' to VALUE nor lists containing VALUE. |
| 1427 | ;;Return t if the property was actually removed, nil otherwise." | 1427 | Optional argument OBJECT is the string or buffer containing the text." |
| 1428 | ;; (remove-text-properties start end (list property) object)) | 1428 | (let ((start (text-property-not-all start end prop nil object)) next prev) |
| 1429 | 1429 | (while start | |
| 1430 | ;; For consistency: maybe this should be called `remove-single-property' like | 1430 | (setq next (next-single-property-change start prop object end) |
| 1431 | ;; `next-single-property-change' (not `next-single-text-property-change'), etc. | 1431 | prev (get-text-property start prop object)) |
| 1432 | ;;(defun remove-single-text-property (start end prop value &optional object) | 1432 | (cond ((or (atom prev) |
| 1433 | ;; "Remove a specific property value from text from START to END. | 1433 | (keywordp (car prev)) |
| 1434 | ;;Arguments PROP and VALUE specify the property and value to remove. The | 1434 | (eq (car prev) 'foreground-color) |
| 1435 | ;;resulting property values are not equal to VALUE nor lists containing VALUE. | 1435 | (eq (car prev) 'background-color)) |
| 1436 | ;;Optional argument OBJECT is the string or buffer containing the text." | 1436 | (when (eq value prev) |
| 1437 | ;; (let ((start (text-property-not-all start end prop nil object)) next prev) | 1437 | (remove-list-of-text-properties start next (list prop) object))) |
| 1438 | ;; (while start | 1438 | ((memq value prev) ;Assume prev is not dotted. |
| 1439 | ;; (setq next (next-single-property-change start prop object end) | 1439 | (let ((new (remq value prev))) |
| 1440 | ;; prev (get-text-property start prop object)) | 1440 | (cond ((null new) |
| 1441 | ;; (cond ((and (symbolp prev) (eq value prev)) | 1441 | (remove-list-of-text-properties start next (list prop) |
| 1442 | ;; (remove-text-property start next prop object)) | 1442 | object)) |
| 1443 | ;; ((and (listp prev) (memq value prev)) | 1443 | ((= (length new) 1) |
| 1444 | ;; (let ((new (delq value prev))) | 1444 | (put-text-property start next prop (car new) object)) |
| 1445 | ;; (cond ((null new) | 1445 | (t |
| 1446 | ;; (remove-text-property start next prop object)) | 1446 | (put-text-property start next prop new object)))))) |
| 1447 | ;; ((= (length new) 1) | 1447 | (setq start (text-property-not-all next end prop nil object))))) |
| 1448 | ;; (put-text-property start next prop (car new) object)) | ||
| 1449 | ;; (t | ||
| 1450 | ;; (put-text-property start next prop new object)))))) | ||
| 1451 | ;; (setq start (text-property-not-all next end prop nil object))))) | ||
| 1452 | 1448 | ||
| 1453 | ;;; End of Additional text property functions. | 1449 | ;;; End of Additional text property functions. |
| 1454 | 1450 | ||