all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Make company-backends buffer-local?
@ 2018-03-04  7:47 Jefferson Carpenter
  2018-03-04 15:55 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jefferson Carpenter @ 2018-03-04  7:47 UTC (permalink / raw)
  To: emacs-devel

First post to this list -- sorry if this is either not a good suggestion 
at all, not right format, or too irrelevant.

The company-backends variable is currently a global variable.  The 
backend that serves completions is the first one that returns a prefix 
for the location at point.

Are there any barriers to making company-backends a buffer-local 
variable?  I don't see any drawbacks - it would take a pretty small 
amount of extra memory to create a copy for each buffer.  The advantages 
include:

1: You can specify backends mode by mode.  I at least feel this makes 
far more sense philosophically.

2: Would fix a possible issue where a backend at the beginning of the 
list is actually for a different file type - maybe for a similar 
language, say Java vs C++ - however still happens to return a prefix, 
and subsequently doesn't return any of the right completions.

3 (extremely minor): Might speed up completions for backends that were 
at the end of the list, since each mode can be programmed with a 
specific list of backends.

TY,
Jefferson Carpenter



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

* Re: Make company-backends buffer-local?
  2018-03-04  7:47 Make company-backends buffer-local? Jefferson Carpenter
@ 2018-03-04 15:55 ` Stefan Monnier
  2018-03-04 16:25 ` Clément Pit-Claudel
  2018-03-04 19:26 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2018-03-04 15:55 UTC (permalink / raw)
  To: emacs-devel

> Are there any barriers to making company-backends a buffer-local variable?

If you write your backend as a completion-at-point-function (which is
recommended whenever possible since that lets it work not just in
company), then it's already the case, since the normal way to specify
such a backend is via

    (add-hook 'completion-at-point-functions #'my-backend-function nil t)


-- Stefan




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

* Re: Make company-backends buffer-local?
  2018-03-04  7:47 Make company-backends buffer-local? Jefferson Carpenter
  2018-03-04 15:55 ` Stefan Monnier
@ 2018-03-04 16:25 ` Clément Pit-Claudel
  2018-03-04 19:26 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Clément Pit-Claudel @ 2018-03-04 16:25 UTC (permalink / raw)
  To: emacs-devel

On 2018-03-04 02:47, Jefferson Carpenter wrote:
> The company-backends variable is currently a global variable.  The
> backend that serves completions is the first one that returns a
> prefix for the location at point.

Most of the modes I write use setq-local to change that variable; is there a further advantage to be gained from making it buffer-local by default?

Clément.





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

* Re: Make company-backends buffer-local?
  2018-03-04  7:47 Make company-backends buffer-local? Jefferson Carpenter
  2018-03-04 15:55 ` Stefan Monnier
  2018-03-04 16:25 ` Clément Pit-Claudel
@ 2018-03-04 19:26 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2018-03-04 19:26 UTC (permalink / raw)
  To: Jefferson Carpenter, emacs-devel

On 3/4/18 9:47 AM, Jefferson Carpenter wrote:
> First post to this list -- sorry if this is either not a good suggestion 
> at all, not right format, or too irrelevant.
> 
> The company-backends variable is currently a global variable.  The 
> backend that serves completions is the first one that returns a prefix 
> for the location at point.
> 
> Are there any barriers to making company-backends a buffer-local 
> variable?  I don't see any drawbacks - it would take a pretty small 
> amount of extra memory to create a copy for each buffer.
You can do this in your own init script. Performance benefits are 
negligible, but you can organize your backends this way.



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

end of thread, other threads:[~2018-03-04 19:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-04  7:47 Make company-backends buffer-local? Jefferson Carpenter
2018-03-04 15:55 ` Stefan Monnier
2018-03-04 16:25 ` Clément Pit-Claudel
2018-03-04 19:26 ` Dmitry Gutov

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.