From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Question about the initials completion-style Date: Thu, 22 Jul 2010 19:27:55 +0200 Message-ID: <201007221927.56302.tassilo@member.fsf.org> References: <201007151800.48336.tassilo@member.fsf.org> <201007221710.00706.tassilo@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1279819694 15704 80.91.229.12 (22 Jul 2010 17:28:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 22 Jul 2010 17:28:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 22 19:28:09 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ObzZ3-00054K-9j for ged-emacs-devel@m.gmane.org; Thu, 22 Jul 2010 19:28:09 +0200 Original-Received: from localhost ([127.0.0.1]:39781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObzZ2-0006mV-4C for ged-emacs-devel@m.gmane.org; Thu, 22 Jul 2010 13:28:08 -0400 Original-Received: from [140.186.70.92] (port=58247 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObzYu-0006lF-BG for emacs-devel@gnu.org; Thu, 22 Jul 2010 13:28:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObzYt-0004Pv-9I for emacs-devel@gnu.org; Thu, 22 Jul 2010 13:28:00 -0400 Original-Received: from out1.smtp.messagingengine.com ([66.111.4.25]:47333) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObzYt-0004Ph-4s for emacs-devel@gnu.org; Thu, 22 Jul 2010 13:27:59 -0400 Original-Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 5BB1816F50F; Thu, 22 Jul 2010 13:27:58 -0400 (EDT) Original-Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 22 Jul 2010 13:27:58 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:subject:date:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:message-id; s=smtpout; bh=px1bRwhHCxkLuaYUMnA772nDM50=; b=FMdn6No0x0bnnSs1/q7nV4vhq4NJqIh4AWC1sdXmGlZfCkPXVNplZhSVIayYjx0iffRho/XCgg2LaJ5QUrvEPFLtDBk9/4bKsDqigyfJre3/vOnt2/49CJxif4p1OX6mHZJ02XhYa5T9rStzRpFAjp5J+8DBWuix5LgSfPpzV70= X-Sasl-enc: ZxFwV16tNxzEsbrSwXWxDRFgFk41466xA19GEUBxlUiJ 1279819678 Original-Received: from thinkpad.localnet (dslb-084-061-104-211.pools.arcor-ip.net [84.61.104.211]) by mail.messagingengine.com (Postfix) with ESMTPSA id 16A134933A; Thu, 22 Jul 2010 13:27:58 -0400 (EDT) User-Agent: KMail/1.13.5 (Linux/2.6.35-rc5-git6; KDE/4.4.5; x86_64; ; ) In-Reply-To: <201007221710.00706.tassilo@member.fsf.org> X-Face: `TY6r/ws=N5uqO1E`M=Sups<}n%T[E^o_?MJj List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:127646 Archived-At: 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