bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14645: Keep highlighting face foreground


From: Juri Linkov
Subject: bug#14645: Keep highlighting face foreground
Date: Tue, 18 Jun 2013 01:55:12 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

Now that we have a new function `add-face-text-property' it would be
very useful for features that add faces with a different background
to highlight matches.  For instance, `occur' uses `add-text-properties'
to add the `match' face, but currently it removes foreground colors
from the text copied from the fontified buffer.

`add-face-text-property' can help to keep the original foreground colors
in the text copied from fontified buffers.  And if someone still wants
to always use the black foreground, this is easy to do by customizing
the `match' face and explicitly selecting a foreground color.

=== modified file 'lisp/replace.el'
--- lisp/replace.el     2013-06-13 22:08:45 +0000
+++ lisp/replace.el     2013-06-17 22:51:03 +0000
@@ -1442,13 +1460,12 @@ (defun occur-engine (regexp buffers out-
                        (setq matches (1+ matches))
                        (add-text-properties
                         (match-beginning 0) (match-end 0)
-                        (append
-                         `(occur-match t)
-                         (when match-face
-                           ;; Use `face' rather than `font-lock-face' here
-                           ;; so as to override faces copied from the buffer.
-                           `(face ,match-face)))
-                        curstring)
+                        '(occur-match t) curstring)
+                       (when match-face
+                         ;; Add `match-face' to faces copied from the buffer.
+                         (add-face-text-property
+                          (match-beginning 0) (match-end 0)
+                          match-face nil curstring))
                        (setq start (match-end 0))))
                    ;; Generate the string to insert for this match
                    (let* ((match-prefix






reply via email to

[Prev in Thread] Current Thread [Next in Thread]