Subject: bug#14645: Keep highlighting face foreground

From: Juri Linkov <[email-masked]>
Date: Wed, 19 Jun 2013 02:31:43 +0300

Another place where `add-face-text-property' could help is for the
recently added face `info-index-match'.  Currently it looks very ugly
when the `info-index-match' face is added in the middle of a link
that breaks its continuity.  A test case is: `C-h r I match RET'.

This is because `Info-index' adds the `info-index-match' face to the
strings of the found index entries.  Later `Info-virtual-index-find-node'
inserts strings to the Info buffer.  And finally `Info-fontify-node'
puts the `font-lock-face' property with `info-xref' on links.
The `face info-index-match' takes precedence over `font-lock-face info-xref'.

This patch uses `add-face-text-property' to merge the `info-index-match'
face with the `info-xref' face.  I think it's not a problem that
it will use the text property `face' instead of `font-lock-face'
since more strategically advantageous direction of the development
for the Info reader would be to move from font-lock-mode to more
browser-like design like in eww.

However, the problem is that usually a highlighting feature puts
a highlighting face on the already fontified string, but this code
reverses the order and first it highlights matches and later puts
more regular text properties on it (so this reversal requires the non-nil
APPEND arg of `add-face-text-property').  Unfortunately, I have no better idea.

=== modified file 'lisp/info.el'
--- lisp/info.el	2013-05-27 22:42:11 +0000
+++ lisp/info.el	2013-06-18 22:57:07 +0000
@@ -4874,9 +4894,8 @@ (defun Info-fontify-node ()
 			       "mouse-2: go to this node")
 		  'mouse-face 'highlight)))
 	      (when (or not-fontified-p fontify-visited-p)
-		(put-text-property
+		(add-face-text-property
 		 (match-beginning 1) (match-end 1)
-                 'font-lock-face
                  ;; Display visited menu items in a different face
                  (if (and Info-fontify-visited-nodes
                           (save-match-data
@@ -4905,7 +4924,7 @@ (defun Info-fontify-node ()
 						  (caar hl))))
 				    (setq res (car hl) hl nil)
 				  (setq hl (cdr hl))))
-                              res))) 'info-xref-visited 'info-xref)))
+                              res))) 'info-xref-visited 'info-xref) 'append))
 	      (when (and not-fontified-p
 			 (memq Info-hide-note-references '(t hide))
 			 (not (Info-index-node)))