[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about the initials completion-style
From: |
Tassilo Horn |
Subject: |
Re: Question about the initials completion-style |
Date: |
Thu, 22 Jul 2010 19:27:55 +0200 |
User-agent: |
KMail/1.13.5 (Linux/2.6.35-rc5-git6; KDE/4.4.5; x86_64; ; ) |
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