[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support f
From: |
Dmitry Gutov |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) |
Hi Stefan,
> ------------------------------------------------------------
> revno: 395
> committer: Stefan Monnier <address@hidden>
> 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'.
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'.,
Dmitry Gutov <=
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Stefan Monnier, 2013/05/05
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Dmitry Gutov, 2013/05/05
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Stefan Monnier, 2013/05/05
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Dmitry Gutov, 2013/05/05
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Stefan Monnier, 2013/05/05
- Re: /srv/bzr/emacs/elpa r395: * company.el (company-capf): Add support for `sorted' and `post-completion'., Dmitry Gutov, 2013/05/09