unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14015: Feature request: highlight partial matches in Info's index-search
@ 2013-03-21 17:24 Eli Zaretskii
  2013-03-21 22:31 ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2013-03-21 17:24 UTC (permalink / raw)
  To: 14015

When 'i foo RET' yields a partial match, e.g., finding "foobar" in the
index, the stand-alone Info reader "highlights" the part that matched,
like this:

   Found FOObar in Some Node. (`,' tries to find next.)

(The stand-alone reader is a text-mode program, so it changes the
letter-case to emphasize the part that matched.)

It would be nice if Emacs did something similar, although it is
probably better to use colors if available.  (We could also use bold
or italic, but at least bold might cause annoying movement of the mode
line, to allow for slightly larger font.)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14015: Feature request: highlight partial matches in Info's index-search
  2013-03-21 17:24 bug#14015: Feature request: highlight partial matches in Info's index-search Eli Zaretskii
@ 2013-03-21 22:31 ` Juri Linkov
  2013-03-22  1:29   ` Stefan Monnier
  2013-03-22 10:08   ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Juri Linkov @ 2013-03-21 22:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14015

> When 'i foo RET' yields a partial match, e.g., finding "foobar" in the
> index, the stand-alone Info reader "highlights" the part that matched,
> like this:
>
>    Found FOObar in Some Node. (`,' tries to find next.)
>
> (The stand-alone reader is a text-mode program, so it changes the
> letter-case to emphasize the part that matched.)
>
> It would be nice if Emacs did something similar, although it is
> probably better to use colors if available.

info-look.el uses the following face to highlight found matches
in the Info reader:

  (defcustom info-lookup-highlight-face 'match
    "Face for highlighting looked up help items.
  Setting this variable to nil disables highlighting."
    :group 'info-lookup :type 'face)

Adding a similar face option to highlight the text matched by `Info-index'
will change the output of `Info-virtual-index' and `info-apropos'
to look exactly the same like as output of `occur' that is good
for consistency of the UI.  This is in addition to highlighting
the matches in the each area that you asked for:

=== modified file 'lisp/info.el'
--- lisp/info.el	2013-03-20 23:04:40 +0000
+++ lisp/info.el	2013-03-21 22:30:34 +0000
@@ -158,6 +158,13 @@ (defface info-header-node
   "Face for Info nodes in a node header."
   :group 'info)
 
+(defcustom Info-index-match-face 'match
+  "Face used by \\[Info-index] to show the text that matches.
+If the value is nil, don't highlight the matching portions specially."
+  :type 'face
+  :group 'info
+  :version "24.4")
+
 ;; This is a defcustom largely so that we can get the benefit
 ;; of custom-initialize-delay.  Perhaps it would work to make it a
 ;; defvar and explicitly give it a standard-value property, and
@@ -3295,12 +3302,14 @@ (defun Info-index (topic)
 	      (progn
 		(goto-char (point-min))
 		(while (re-search-forward pattern nil t)
-		  (push (list (match-string-no-properties 1)
-			      (match-string-no-properties 2)
-			      Info-current-node
-			      (string-to-number (concat "0"
-							(match-string 3))))
-			matches))
+		  (let ((entry (match-string-no-properties 1))
+			(nodename (match-string-no-properties 2))
+			(line (string-to-number (concat "0" (match-string 3)))))
+		    (when (and Info-index-match-face
+			       (string-match (regexp-quote topic) entry))
+		      (add-text-properties (match-beginning 0) (match-end 0)
+					   `(face ,Info-index-match-face) entry))
+		    (push (list entry nodename Info-current-node line) matches)))
 		(setq nodes (cdr nodes) node (car nodes)))
 	    (Info-goto-node node))
 	  (or matches
@@ -3559,12 +3568,15 @@ (defun Info-apropos-matches (string)
                         (progn
                           (goto-char (point-min))
                           (while (re-search-forward pattern nil t)
-			    (setq matches
-				  (cons (list manual
-					      (match-string-no-properties 1)
-					      (match-string-no-properties 2)
-					      (match-string-no-properties 3))
-					matches)))
+			    (let ((entry (match-string-no-properties 1))
+				  (nodename (match-string-no-properties 2))
+				  (line (match-string-no-properties 3)))
+			      (when (and Info-index-match-face
+					 (string-match (regexp-quote string) entry))
+				(add-text-properties (match-beginning 0) (match-end 0)
+						     `(face ,Info-index-match-face) entry))
+			      (setq matches (cons (list manual entry nodename line)
+						  matches))))
                           (setq nodes (cdr nodes) node (car nodes)))
                       (Info-goto-node node))))
 	    (error






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14015: Feature request: highlight partial matches in Info's index-search
  2013-03-21 22:31 ` Juri Linkov
@ 2013-03-22  1:29   ` Stefan Monnier
  2013-03-23  0:40     ` Juri Linkov
  2013-03-22 10:08   ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-03-22  1:29 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 14015

> +(defcustom Info-index-match-face 'match
> +  "Face used by \\[Info-index] to show the text that matches.
> +If the value is nil, don't highlight the matching portions specially."
> +  :type 'face
> +  :group 'info
> +  :version "24.4")

Nowadays, we usually prefer to define a new face that inherits from
`match'.


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14015: Feature request: highlight partial matches in Info's index-search
  2013-03-21 22:31 ` Juri Linkov
  2013-03-22  1:29   ` Stefan Monnier
@ 2013-03-22 10:08   ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2013-03-22 10:08 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 14015

> From: Juri Linkov <juri@jurta.org>
> Cc: 14015@debbugs.gnu.org
> Date: Fri, 22 Mar 2013 00:31:56 +0200
> 
> >    Found FOObar in Some Node. (`,' tries to find next.)
> >
> > (The stand-alone reader is a text-mode program, so it changes the
> > letter-case to emphasize the part that matched.)
> >
> > It would be nice if Emacs did something similar, although it is
> > probably better to use colors if available.
> 
> info-look.el uses the following face to highlight found matches
> in the Info reader:
> 
>   (defcustom info-lookup-highlight-face 'match
>     "Face for highlighting looked up help items.
>   Setting this variable to nil disables highlighting."
>     :group 'info-lookup :type 'face)
> 
> Adding a similar face option to highlight the text matched by `Info-index'
> will change the output of `Info-virtual-index' and `info-apropos'
> to look exactly the same like as output of `occur' that is good
> for consistency of the UI.  This is in addition to highlighting
> the matches in the each area that you asked for:

Thanks, I like the result very much.

I think it warrants a NEWS entry.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14015: Feature request: highlight partial matches in Info's index-search
  2013-03-22  1:29   ` Stefan Monnier
@ 2013-03-23  0:40     ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2013-03-23  0:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14015-done

>> +(defcustom Info-index-match-face 'match
>> +  "Face used by \\[Info-index] to show the text that matches.
>> +If the value is nil, don't highlight the matching portions specially."
>> +  :type 'face
>> +  :group 'info
>> +  :version "24.4")
>
> Nowadays, we usually prefer to define a new face that inherits from
> `match'.

I installed with defface that inherits from `match' instead of using defcustom.
All other Info faces are defined with defface too, so a new defface will be
consistent with other Info faces.

However, a new face `list-matching-lines-prefix-face' that I proposed
in bug#14017 is better to define with defcustom for consistency with other
occur-related faces `list-matching-lines-buffer-name-face' and
`list-matching-lines-face' that are defined with defcustom:

  (defcustom list-matching-lines-face 'match
    "Face used by \\[list-matching-lines] to show the text that matches.
  If the value is nil, don't highlight the matching portions specially."
    :type 'face
    :group 'matching)

  (defcustom list-matching-lines-buffer-name-face 'underline
    "Face used by \\[list-matching-lines] to show the names of buffers.
  If the value is nil, don't highlight the buffer names specially."
    :type 'face
    :group 'matching)

I'm not sure whether they should be turned info defface as well
because this will also require converting more related faces to defface,
e.g. grep faces:

  (defvar grep-match-face	'match
    "Face name to use for grep matches.")

  (defvar grep-context-face 'shadow
    "Face name to use for grep context lines.")

And even after adding deffaces for them these old variables should still remain
for backward compatibility with definitions like:

  (defcustom list-matching-lines-face 'occur-match

  (defvar grep-match-face 'grep-match





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-23  0:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-21 17:24 bug#14015: Feature request: highlight partial matches in Info's index-search Eli Zaretskii
2013-03-21 22:31 ` Juri Linkov
2013-03-22  1:29   ` Stefan Monnier
2013-03-23  0:40     ` Juri Linkov
2013-03-22 10:08   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).