all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: emacs-devel@gnu.org
Subject: Re: completion discrepancy between default completion and helm/ivy completions
Date: Mon, 14 Nov 2016 09:20:29 -0500	[thread overview]
Message-ID: <jwvd1hynoc6.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <m2vavqxkk1.fsf@polytechnique.org> (Alan Schmitt's message of "Mon, 14 Nov 2016 14:22:54 +0100")

> (when (and org-contacts-enable-completion
> 	   (boundp 'completion-at-point-functions))
>   (add-hook 'message-mode-hook 'org-contacts-setup-completion-at-point))

> which does

> (defun org-contacts-setup-completion-at-point ()
>   "Add `org-contacts-message-complete-function' as a new function
> to complete the thing at point."
>   (add-to-list 'completion-at-point-functions
> 	       'org-contacts-message-complete-function))

[ Side point: `add-to-list` is wrong, it should be `add-hook` (tho with
  additional "nil 'local" arguments, to only add to the buffer-local
  part of the hook).  ]

> That function basically checks if this is a place where completion
> should happen (To field, for instance), then calls all the
> org-contacts-complete-functions until one succeeds. One such function is
> org-contacts-complete-group that, in some case, returns a function
> taking unused arguments and returning the completion as a string. To
> summarize, is it okay for a function in completion-at-point-functions to
> return such a function?

The docstring of `completion-at-point-functions` says:

    Each function on this hook is called in turn without any argument and
    should return either nil, meaning it is not applicable at point,
    or a function of no arguments to perform completion (discouraged),
    or a list of the form (START END COLLECTION . PROPS), where:
    [...]

So, yes, it's acceptable (tho discouraged) to return a function, but this
function should then *perform the completion* (rather than just return
a string).

> I guess I should try to return something of the form (start end
> collection . props) instead, with collection being a singleton…

Why a singleton?  The driving design should be: return a `collection`
which is valid for any text between `start` and `end`.

Because `collection` will be matched against the text between `start`
and `end` anyway (and the UI may decide to match it against other text
as well, e.g. to provide other completion styles than just prefix
completion).


        Stefan



      reply	other threads:[~2016-11-14 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 11:22 completion discrepancy between default completion and helm/ivy completions Alan Schmitt
2016-11-10 20:35 ` Stefan Monnier
2016-11-13 13:05   ` Alan Schmitt
2016-11-13 15:38     ` Stefan Monnier
2016-11-14 13:22       ` Alan Schmitt
2016-11-14 14:20         ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd1hynoc6.fsf-monnier+Inbox@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=alan.schmitt@polytechnique.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.