From: Tassilo Horn <tassilo@member.fsf.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Question about the initials completion-style
Date: Thu, 22 Jul 2010 19:27:55 +0200 [thread overview]
Message-ID: <201007221927.56302.tassilo@member.fsf.org> (raw)
In-Reply-To: <201007221710.00706.tassilo@member.fsf.org>
On Thursday 22 July 2010 17:10:00 Tassilo Horn wrote:
Hi Stefan,
> > There is no such feature, no. Feel free to code it up,
>
> It looks to me that I could copy the `completion-pcm-all-completions'
> function and add a FILTER for deleting the entries consisting of too
> many words to the call to `completion-pcm--find-all-completions'. I'll
> try that as soon as I find some time...
Ok, here's a proof-of-concept which seems to do what I want. It lacks
some good name, relies on dynamic scoping, and is probably not the best
or even a good way to implement that feature.
--8<---------------cut here---------------start------------->8---
(defun completion-pcm--no-lengthening-filter (comps)
(when comps
(delq nil
(mapcar
(lambda (str)
(if (= (count ?- str) cnt) str nil))
comps))))
(defun completion-pcm-all-completions-no-lengthening (string table pred point)
(destructuring-bind (pattern all &optional prefix suffix)
(let ((cnt (count ?- string)))
(completion-pcm--find-all-completions
string table pred point
'completion-pcm--no-lengthening-filter))
(when all
(nconc (completion-pcm--hilit-commonality pattern all)
(length prefix)))))
(add-to-list 'completion-styles-alist
'(partial-completion-no-lengthening
completion-pcm-try-completion
completion-pcm-all-completions-no-lengthening
"Like the partial-completion style, but don't
complete x-y to things with more word separators (like
xoo-yee-foo)."))
;; Use it!!!
(setq completion-styles '(basic initials partial-completion-no-lengthening))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
next prev parent reply other threads:[~2010-07-22 17:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-15 16:00 Question about the initials completion-style Tassilo Horn
2010-07-22 14:38 ` Stefan Monnier
2010-07-22 15:10 ` Tassilo Horn
2010-07-22 17:27 ` Tassilo Horn [this message]
2010-07-22 22:44 ` Stefan Monnier
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=201007221927.56302.tassilo@member.fsf.org \
--to=tassilo@member.fsf.org \
--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.