From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'. Date: Sun, 05 May 2013 01:59:59 +0400 Message-ID: <87vc6yz9r4.fsf@yandex.ru> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1367704821 412 80.91.229.3 (4 May 2013 22:00:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 May 2013 22:00:21 +0000 (UTC) Cc: emacs-devel@gnu.org To: monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 05 00:00:20 2013 Return-path: Envelope-to: ged-emacs-devel@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 1UYkV8-0006b7-4P for ged-emacs-devel@m.gmane.org; Sun, 05 May 2013 00:00:18 +0200 Original-Received: from localhost ([::1]:59465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYkV7-0007gC-DS for ged-emacs-devel@m.gmane.org; Sat, 04 May 2013 18:00:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYkV0-0007ez-Kz for emacs-devel@gnu.org; Sat, 04 May 2013 18:00:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYkUw-0007OO-0v for emacs-devel@gnu.org; Sat, 04 May 2013 18:00:10 -0400 Original-Received: from mail-lb0-f174.google.com ([209.85.217.174]:56660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYkUv-0007Ng-Pi for emacs-devel@gnu.org; Sat, 04 May 2013 18:00:05 -0400 Original-Received: by mail-lb0-f174.google.com with SMTP id r10so2470280lbi.19 for ; Sat, 04 May 2013 15:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-antivirus :x-antivirus-status; bh=x9zi6k+71HhhOWbhAZfvPS8o7/8GKGTOgEE1I3jn+P0=; b=g0hMJ193xRnHNTyglXcZQmfG1gNZBAWOvJNFMD2lnU5ZfZZ4CwKxK1qef0MJi913cr 24M+08OjvZ2HCtv5K+V+oaub79N8EA/ubEBPTth+h0+coyykjnhiDC/E6sRqZXmZv8zX 4HYP4a+guOutQBISOj2bF4Bmekdo8i5W0ve4dDcK3uuKdf9dxdatlOEwJ5VGTOFXluNw O/snv4O37IubPUdg8gbqqXdiEmFAVhLw+lVySqEmGfKN0/FShVe5JERpoGbxh3U8ixrV sl9JKoUsxHBkWE7AiaN1tAublc5Dj8Fu6axQLQhjTwZ7kni4AsoKnLOOiHecbXzdfJ+Y gABg== X-Received: by 10.112.138.228 with SMTP id qt4mr5915036lbb.106.1367704804437; Sat, 04 May 2013 15:00:04 -0700 (PDT) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id lb9sm6453236lab.9.2013.05.04.15.00.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 May 2013 15:00:03 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sat, 27 Apr 2013 09:48:47 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Antivirus: avast! (VPS 130504-1, 04.05.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.174 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159300 Archived-At: Hi Stefan, > ------------------------------------------------------------ > revno: 395 > committer: Stefan Monnier > branch nick: elpa > timestamp: Sat 2013-04-27 09:48:47 -0400 > message: > ;; (defun company-my-backend (command &optional arg &rest ignored) > -;; (case command > -;; (prefix (when (looking-back "foo\\>") > +;; (pcase command > +;; (`prefix (when (looking-back "foo\\>") > ;; (match-string 0))) > -;; (candidates (list "foobar" "foobaz" "foobarbaz")) > -;; (meta (format "This value is named %s" arg)))) > +;; (`candidates (list "foobar" "foobaz" "foobarbaz")) > +;; (`meta (format "This value is named %s" arg)))) Like the header in company.el says, we still try to support Emacs 22 and 23. `pcase' was only added in 23.3, I believe. > +(defun company-capf (command &optional arg &rest _args) ... > + (duplicates nil) ;Don't bother. > + (no-cache t) ;FIXME: Improve! > + (meta nil) ;FIXME: Return one-line docstring for `arg'. > + (doc-buffer nil) ;FIXME: Return help buffer for `arg'. > + (location nil) ;FIXME: Return (BUF . POS) or (FILE . LINENB) of > `arg'. > + (init nil) ;Don't bother: plenty of other ways to initialize > the code. a) There's no need to return nils explicitly, other backends don't. b) Who are these FIXMEs for? I guess `meta' can be implemented by calling `:annotation-function' (don't know if it's appropriate), but `doc-buffer' and `location' don't have anything corresponding in `completion-extra-properties'. > + (require-match nil) ;This should be a property of the > front-end! Should it really? A smart back-end could determine if we're typing a function call, or typing the name for a new function, and at least override it to `never' in the latter case. Returning `t' might indeed never be appropriate for a back-end, and some front-ends could want to have a say in this, but I'd rather see them in practice first. > +(defvar company-backend) > + This variable is declared about ~30 lines below that. Is it appropriate to have both declarations in the same file? > Example: > \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)" > + ;; FIXME: Shouldn't `company-begin-with-marker' be removed and replaced > + ;; by a lexical variable? It probably should, but, again, lexical-binding is not available in Emacs < 24. ATM I'm only using it to improve some logic that uses `boundp' in `company-elisp'.