unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "Emacs-Devel (emacs-devel@gnu.org)" <emacs-devel@gnu.org>
Subject: Why do apropos commands match only pairs of words in a word-list pattern?
Date: Sat, 9 May 2015 12:16:57 -0700 (PDT)	[thread overview]
Message-ID: <eb17cadb-6235-4c3f-919a-6ca8dcc1da6d@default> (raw)

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?



             reply	other threads:[~2015-05-09 19:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09 19:16 Drew Adams [this message]
2015-05-11  5:21 ` Why do apropos commands match only pairs of words in a word-list pattern? 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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=eb17cadb-6235-4c3f-919a-6ca8dcc1da6d@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@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 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).