* Substring matching for info index command
@ 2014-12-07 12:15 Tom
2014-12-07 14:06 ` Drew Adams
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Tom @ 2014-12-07 12:15 UTC (permalink / raw)
To: help-gnu-emacs
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Substring matching for info index command
2014-12-07 12:15 Substring matching for info index command Tom
@ 2014-12-07 14:06 ` Drew Adams
2014-12-07 14:16 ` Tom
2014-12-07 15:56 ` Eli Zaretskii
2014-12-07 16:02 ` Stefan Monnier
2 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2014-12-07 14:06 UTC (permalink / raw)
To: Tom, help-gnu-emacs
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Substring matching for info index command
2014-12-07 14:06 ` Drew Adams
@ 2014-12-07 14:16 ` Tom
2014-12-07 14:56 ` Drew Adams
0 siblings, 1 reply; 6+ messages in thread
From: Tom @ 2014-12-07 14:16 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams <at> oracle.com> writes:
>
> 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.
Thanks for your investigation, but why should info use
my input to gather completion candidates? It should
gather all candiates and pass them them to
completing-read, shouldn't it?
Isn't it a bug? Incosistent behavior with the
builtin completion-styles?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Substring matching for info index command
2014-12-07 14:16 ` Tom
@ 2014-12-07 14:56 ` Drew Adams
0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2014-12-07 14:56 UTC (permalink / raw)
To: Tom, help-gnu-emacs
> > 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.
>
> Thanks for your investigation, but why should info use
> my input to gather completion candidates?
I didn't say that it should. I said that it does.
Feel free to file a bug report: `M-x report-emacs-bug'.
> It should gather all candiates and pass them them to
> completing-read, shouldn't it?
> Isn't it a bug? Incosistent behavior with the
> builtin completion-styles?
My opinion? Yes. (And that's what Icicles does.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Substring matching for info index command
2014-12-07 12:15 Substring matching for info index command Tom
2014-12-07 14:06 ` Drew Adams
@ 2014-12-07 15:56 ` Eli Zaretskii
2014-12-07 16:02 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2014-12-07 15:56 UTC (permalink / raw)
To: help-gnu-emacs
> From: Tom <adatgyujto@gmail.com>
> Date: Sun, 7 Dec 2014 12:15:52 +0000 (UTC)
>
> 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.
info.el already does that: it first searches for the string at the
beginning of the index entries, and then anywhere inside the entries.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Substring matching for info index command
2014-12-07 12:15 Substring matching for info index command Tom
2014-12-07 14:06 ` Drew Adams
2014-12-07 15:56 ` Eli Zaretskii
@ 2014-12-07 16:02 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-12-07 16:02 UTC (permalink / raw)
To: help-gnu-emacs
> 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.
Info should setup a "completion category" so you could configure this
via `completion-category-overrides'. Please M-x report-emacs-bug.
> 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))
That affects the body of the function (i.e. the code that, given
a query, will look for the corresponding place in the index), whereas
you want to tweak the way the interactive-spec works.
You might like to try something like (guaranteed 100% untested):
(advice-add 'Info-index :before
(lambda (&rest _)
(interactive
(lambda (spec)
(let ((completion-styles '(substring)))
(advice-eval-interactive-spec spec))))
nil))
-- Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-07 16:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-07 12:15 Substring matching for info index command Tom
2014-12-07 14:06 ` Drew Adams
2014-12-07 14:16 ` Tom
2014-12-07 14:56 ` Drew Adams
2014-12-07 15:56 ` Eli Zaretskii
2014-12-07 16:02 ` Stefan Monnier
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.