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

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

RE: Substring matching for info index command


From: Drew Adams
Subject: RE: Substring matching for info index command
Date: Sun, 7 Dec 2014 06:06:15 -0800 (PST)

> I've never used the builtin completion-styles, because I
> use other completion packages, but I thought I give it a try
> and try substring matching for the info index command.
> 
> I added this advice to the command which wraps it in a
> let and sets completion-styles to substring:
> 
> (defadvice Info-index (around my-Info-index activate)
>   (let ((completion-styles '(substring)))
>     ad-do-it))
> 
> However, it has no effect, it still uses the prefix
> completion style. Why is that?

The reason is that `Info-index' uses your input not only
to match against the possible completions but also (and
first) to come up with (calculate/find) the possible
completions.

And when it uses your input to gather the possible
completions it simply searches the indexes of the manual
for your input, prefixed by `* '.

In other words, the problem is not with completion; it is
with the way `Info-index' gathers the completion candidates
from the indexes.  It does that by simply searching for
your input, as a prefix (prepended by `* ', which is what
is on the index-entry line in the index.

For example, in the Emacs manual, node `Command Index',
there is an entry that looks like this:

* ask-user-about-lock

When you type `user' as input, `Info-index' searches all
of the indexes for this regexp:

"
\\* +\\([^
]*\\(user\\)[^
]*\\):[         ]+\\([^
]*\\)\\.\\(?:[  
]*(line +\\([0-9]+\\))\\)?"

which is essentially a search for `* user'.

It is only after gathering all matches for this regexp,
across all indexes, that `Info-index' presents them to you,
providing completion (substring completion, in your case).

In sum, you would need to rewrite `Info-index' or heavily
advise it, to get it to DTRT.

Or you can just use Icicles.  `i user S-TAB' shows these
index-entry completion candidates for the Emacs manual:

--user
ange-ftp-default-user
apropos-user-option 
ask-user-about-lock
backup, and user-id
GDB User Interface layout 
load init file of another user
mail-user-agent
package-user-dir 
USER
user name for remote file access
user option 
user options, changing
user-full-name
user-mail-address 
user-mail-address <1>
user-mail-address, initialization 



reply via email to

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