unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why do apropos commands match only pairs of words in a word-list pattern?
@ 2015-05-09 19:16 Drew Adams
  2015-05-11  5:21 ` Nicolas Richard
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2015-05-09 19:16 UTC (permalink / raw)
  To: Emacs-Devel (emacs-devel@gnu.org)

If you type a list of words to match, instead of typing a regexp,
to a command such as `apropos', each word is not matched against
the candidates and then the intersection of those match sets
retained.

Instead of matching each word in the list you provide it, apropos
commands match each pair of words from the list.

For example, if you type `foo bar toto' then all matches of `foo'
& `bar' (in either order) are retained, plus all matches of `bar'
& `toto', plus all matches of `foo' & `toto'.  So for instance, a
candidate `some-bar-foo-thing' is retained, even though it does
not also match `toto' - it is enough that it matches both `foo'
and `bar'.

Why is this the design?  Wouldn't users more typically want *each*
of the words they type to be matched?

Is this perhaps only because the existing code before introducing
word-list patterns provided for using a regexp, and in order to
bolt word-list matching onto that existing code it was thought to
be easier to just come up with a single regexp to match, instead
of handling the word-list case as an intersection of separate
matches?

IOW, was this just an implementation decision, or is there some
more important reason for it, from a user point of view?

The behavior is documented, in (emacs)`Apropos', as follows:

 When you specify more than one word in the apropos pattern,
 a name must contain at least two of the words in order to match.

No reason given there as to why this would be behavior you might
want or expect.  And beyond that brief description, there is
only this comment in the apropos.el code:

 ;; We don't actually make a regexp matching all permutations.
 ;; Instead, for e.g. "a b c", we make a regexp matching
 ;; any combination of two or more words like this:
 ;; (a|b|c).*(a|b|c) which may give some false matches,
 ;; but as long as it also gives the right ones, that's ok.

That tells what happens, but not why this choice was made.

And the last line almost sounds like an apology, as if this
is not ideal but it is generally OK, since although extra
junk is included at least we don't missing any sought matches.

IOW, it sounds like, even though you really want only matches
of all three: `foo' & `bar' & `toto', we think it's OK if you
get additional, false positives such as `some-bar-foo-thing',
as long as you also get all true positives (such as
`a-bar-toto-foo-thing').

Is this the right behavior?  If so, why - what am I missing?



^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <<eb17cadb-6235-4c3f-919a-6ca8dcc1da6d@default>]

end of thread, other threads:[~2015-05-11 17:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-09 19:16 Why do apropos commands match only pairs of words in a word-list pattern? Drew Adams
2015-05-11  5:21 ` Nicolas Richard
2015-05-11 14:06   ` Drew Adams
2015-05-11 14:51     ` Nicolas Richard
2015-05-11 14:59     ` Eli Zaretskii
     [not found] <<eb17cadb-6235-4c3f-919a-6ca8dcc1da6d@default>
     [not found] ` <<87pp671ygs.fsf@yahoo.fr>
     [not found]   ` <<fb8ad237-c97f-4ec9-94b4-6937e4d01abc@default>
     [not found]     ` <<83lhgvma79.fsf@gnu.org>
2015-05-11 17:01       ` Drew Adams

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).