all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 14015@debbugs.gnu.org
Subject: bug#14015: Feature request: highlight partial matches in Info's index-search
Date: Fri, 22 Mar 2013 00:31:56 +0200	[thread overview]
Message-ID: <87a9pwidur.fsf@mail.jurta.org> (raw)
In-Reply-To: <83boaczmxb.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 21 Mar 2013 19:24:00 +0200")

> 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






  reply	other threads:[~2013-03-21 22:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-03-22  1:29   ` Stefan Monnier
2013-03-23  0:40     ` Juri Linkov
2013-03-22 10:08   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a9pwidur.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=14015@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.