From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lele Gaifax Newsgroups: gmane.emacs.help Subject: Re: Tweak company completions order Date: Fri, 04 Dec 2015 13:43:35 +0100 Organization: Nautilus Entertainments Message-ID: <87vb8es7t4.fsf@metapensiero.it> References: <87bna7p4cu.fsf@metapensiero.it> <566102AC.6010705@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1449233187 31789 80.91.229.3 (4 Dec 2015 12:46:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Dec 2015 12:46:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 04 13:46:19 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a4pjS-0001qJ-1Q for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Dec 2015 13:45:02 +0100 Original-Received: from localhost ([::1]:40389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4pjR-0002X5-Ac for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Dec 2015 07:45:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4pjG-0002Wx-3a for help-gnu-emacs@gnu.org; Fri, 04 Dec 2015 07:44:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4pjC-00009z-Rn for help-gnu-emacs@gnu.org; Fri, 04 Dec 2015 07:44:50 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:39306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4pjC-00009b-L8 for help-gnu-emacs@gnu.org; Fri, 04 Dec 2015 07:44:46 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a4pim-00013Z-QX for help-gnu-emacs@gnu.org; Fri, 04 Dec 2015 13:44:22 +0100 Original-Received: from 151.62.136.60 ([151.62.136.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Dec 2015 13:44:20 +0100 Original-Received: from lele by 151.62.136.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Dec 2015 13:44:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 25 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 151.62.136.60 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:bughkNkQcbA7s2Yd8+zRKfBuwZI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108298 Archived-At: Thank you Dmitry! For the record, this is what I've come up: (defun esk/company-sort-preferring-exact-or-same-case (candidates) (let ((exact nil) (sameprefix nil) (others nil) (plen (length company-prefix))) (mapc (lambda (candidate) (if (equal company-prefix candidate) (push candidate exact) (if (equal company-prefix (substring candidate 0 plen)) (push candidate sameprefix) (push candidate others)))) candidates) (append exact sameprefix others))) (add-to-list 'company-transformers #'esk/company-sort-preferring-exact-or-same-case) ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.