unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13609: 24.2.92; completion-list-insert-choice-function
@ 2013-02-02 16:24 Roland Winkler
  2013-02-03 13:51 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Winkler @ 2013-02-02 16:24 UTC (permalink / raw)
  To: 13609

The default value of completion-list-insert-choice-function
is completion--replace.  The `--' in the name of completion--replace
suggests to me that this is an internal function other code
should not rely on.  Yet isn't it a common scenario to bind
completion-list-insert-choice-function to a function which
calls completion--replace, plus it does something else?
(This is what bbdb-complete-mail does in BBDB v3.)

So I suggest to rename completion--replace to completion-replace
to make it clear that other code may use this function.
(Or solve this problem in some other way that other code may rely upon.)


In GNU Emacs 24.2.92.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1)
 of 2013-01-10 on regnitz
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
System Description:	Ubuntu 10.04.4 LTS





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#13609: 24.2.92; completion-list-insert-choice-function
  2013-02-02 16:24 bug#13609: 24.2.92; completion-list-insert-choice-function Roland Winkler
@ 2013-02-03 13:51 ` Stefan Monnier
  2013-02-03 15:46   ` Roland Winkler
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-02-03 13:51 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 13609

> So I suggest to rename completion--replace to completion-replace
> to make it clear that other code may use this function.

No, because some other package may already have changed
completion-list-insert-choice-function, so you should really read the
current value of completion-list-insert-choice-function, and then call
that (via `funcall') rather than hard-coding completion--replace.

> (Or solve this problem in some other way that other code may rely upon.)

As a matter of fact there's a new feature in trunk that does just that:
`add-function'.


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#13609: 24.2.92; completion-list-insert-choice-function
  2013-02-03 13:51 ` Stefan Monnier
@ 2013-02-03 15:46   ` Roland Winkler
  0 siblings, 0 replies; 3+ messages in thread
From: Roland Winkler @ 2013-02-03 15:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13609-done

On Sun Feb 3 2013 Stefan Monnier wrote:
> > So I suggest to rename completion--replace to completion-replace
> > to make it clear that other code may use this function.
> 
> No, because some other package may already have changed
> completion-list-insert-choice-function, so you should really read the
> current value of completion-list-insert-choice-function, and then call
> that (via `funcall') rather than hard-coding completion--replace.

Thank you, that makes sense, it solves my problem.

Possibly, such a strategy could even be mentioned in the docstring of
completion-list-insert-choice-function.  How about adding the
following sentences?

  If you want to bind this variable to a function calling the default
  value of this variable as part of its job, do not hard-code this value
  in your code as it may change in future versions of Emacs.
  Instead, read the current value of completion-list-insert-choice-function,
  then call that via `funcall'.

Of course, this is a generic issue with any foo-function variables
that come with a default.  Merely, I do not know where to put such
a more generic remark into the elisp manual so that you find it
when you need it.

> > (Or solve this problem in some other way that other code may rely upon.)
> 
> As a matter of fact there's a new feature in trunk that does just that:
> `add-function'.

Great, though I'll keep this for future versions of BBDB.  Right now
I want to keep BBDB 3 compatible with GNU Emacs 23 and 24.
(Sometimes this is hard when you have to ignore cool new stuff...)

Roland





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-03 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02 16:24 bug#13609: 24.2.92; completion-list-insert-choice-function Roland Winkler
2013-02-03 13:51 ` Stefan Monnier
2013-02-03 15:46   ` Roland Winkler

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).