all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: 'Emacs-Devel' <emacs-devel@gnu.org>
Subject: RE: something between try-completion and test-completion?
Date: Wed, 6 Feb 2008 13:19:46 -0800	[thread overview]
Message-ID: <006e01c86906$003235f0$9eb22382@us.oracle.com> (raw)
In-Reply-To: <jwvwsphdhhi.fsf-monnier+emacs@gnu.org>

> > I'd be interested in a function similar to both `try-completion' and
> > `test-completion', but which would just test whether its 
> > STRING arg can be completed against its COLLECTION arg,
> > respecting its PREDICATE arg.
> 
> > It would be like `test-completion', in that as soon as some 
> > match is found it would return non-nil, not bothering to test
> > the other completions and calculate the common prefix.
> 
> > It would be like `try-completion', in that it would test 
> > whether the STRING is a prefix of some COLLECTION element,
> > not whether STRING is itself one of the COLLECTION elements.
> 
> > The idea is to have a quick version of `try-completion' for 
> > situations where the common prefix of all matches is not needed,
> > and all you want is an indication of whether the STRING could be
> > completed.
> 
> > Any other interest in this? Any chance this will become available?
> 
> Could you give us some sample situation where there'd be an actual
> benefit (as in measurable performance difference) between 
> try-completion and the function you're looking for?

No. I can't compare performance for a non-existent implementation. ;-)

If there are lots of completions for STRING, and there is a common prefix,
then `try-completion' will do extra work to find all the completions and
calculate that common prefix.

The point is that that extra work is, well, extra - not useful in this
context. What the performance difference would be by avoiding that
computation I can't predict.

But you can see that that work is not necessary, and you can imagine that,
in the case of many, many completions with a common prefix, that wasted time
could be important. How many completions would make it noticeable? And
noticeable in what contexts? I don't know (or care).

> PS: Maybe you can hack it up by hand:
> 
>   (defun try-completion-p (string collection &optional predicate)
>     (lexical-let ((predicate predicate))
>       (catch 'tcp-found
>         (try-completion string collection
>                         (lambda (x)
>                           (if (funcall predicate)
>                               (throw 'tcp-found t))))
>         nil)))

That does nothing in the (more typical) case where predicate is nil.

But that's the idea - have a function `try-completion-p' (or
`any-completions-p') that would stop as soon as it found one match (and not
just with PREDICATE).






  reply	other threads:[~2008-02-06 21:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 17:16 something between try-completion and test-completion? Drew Adams
2008-02-06 19:19 ` Stefan Monnier
2008-02-06 21:19   ` Drew Adams [this message]
2008-02-06 22:12     ` Stefan Monnier
2008-02-07  3:36     ` Richard Stallman

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='006e01c86906$003235f0$9eb22382@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.