unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Collecting completion candidates from multiple files
@ 2022-01-12 20:48 Daniele Nicolodi
  2022-01-12 23:19 ` Daniel Martín
  0 siblings, 1 reply; 8+ messages in thread
From: Daniele Nicolodi @ 2022-01-12 20:48 UTC (permalink / raw)
  To: Emacs developers

Hello,

is there a standard facility and/or user interface to collect completion 
candidates from multiple files composing a project?

I'm developing a mode for a language that has an "include" facility and 
I would like to support collecting completion candidates from the 
definitions contained in all the files that compose a project, 
independently of whether the current buffer has an explicit "include" 
directive or not.

Thank you.

Cheers,
Dan



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

* Re: Collecting completion candidates from multiple files
  2022-01-12 20:48 Collecting completion candidates from multiple files Daniele Nicolodi
@ 2022-01-12 23:19 ` Daniel Martín
  2022-01-13  8:53   ` Daniele Nicolodi
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Martín @ 2022-01-12 23:19 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: Emacs developers

Daniele Nicolodi <daniele@grinta.net> writes:

> Hello,
>
> is there a standard facility and/or user interface to collect
> completion candidates from multiple files composing a project?
>
> I'm developing a mode for a language that has an "include" facility
> and I would like to support collecting completion candidates from the 
> definitions contained in all the files that compose a project,
> independently of whether the current buffer has an explicit "include" 
> directive or not.

The standard facility provided by Emacs is based on the hook
completion-at-point-functions, that each major mode can customize to
provide appropriate completion on the text in Emacs buffers.

Eval the following form in Emacs to read more about the completion API:

(info "(elisp) Completion in Buffers")



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

* Re: Collecting completion candidates from multiple files
  2022-01-12 23:19 ` Daniel Martín
@ 2022-01-13  8:53   ` Daniele Nicolodi
  2022-01-13 14:19     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Daniele Nicolodi @ 2022-01-13  8:53 UTC (permalink / raw)
  To: Daniel Martín; +Cc: Emacs developers

On 13/01/2022 00:19, Daniel Martín wrote:
> Daniele Nicolodi <daniele@grinta.net> writes:
> 
>> Hello,
>>
>> is there a standard facility and/or user interface to collect
>> completion candidates from multiple files composing a project?
>>
>> I'm developing a mode for a language that has an "include" facility
>> and I would like to support collecting completion candidates from the
>> definitions contained in all the files that compose a project,
>> independently of whether the current buffer has an explicit "include"
>> directive or not.
> 
> The standard facility provided by Emacs is based on the hook
> completion-at-point-functions, that each major mode can customize to
> provide appropriate completion on the text in Emacs buffers.

Hello Martin,

thank you for your response, I know how to implement completion. What 
I'm inquiring about is how to implement the collection of completion 
candidates from multiple buffers. I can implement this in my mode, 
however I'm wondering if Emacs already has a facility for this kind of 
things.

Cheers,
Dan



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

* Re: Collecting completion candidates from multiple files
  2022-01-13  8:53   ` Daniele Nicolodi
@ 2022-01-13 14:19     ` Stefan Monnier
  2022-01-13 14:47       ` xenodasein--- via Emacs development discussions.
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2022-01-13 14:19 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: Daniel Martín, Emacs developers

> What I'm inquiring about is how to implement the collection of
> completion candidates from multiple buffers.

It's a rather vague question.  Usually completion data either comes from
Emacs itself (e.g. lists of commands, or elements of a hash-table, ...),
or from a buffer, or from external info (e.g. files or subprocesses) but
rarely from several buffers.  This said, I'm not sure what kind of
difficulty you're facing nor what kind of help you expect to find from
other examples.  It'd likely depend a lot on what the actual collection
work looks like.

If you're thinking of completion data along the lines of `imenu` but not
limited to the current buffer/file, then I suspect you're not looking
for "multiple buffers" but "multiple files", in which case examples may
be Eglot and CEDET?


        Stefan




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

* Re: Collecting completion candidates from multiple files
  2022-01-13 14:19     ` Stefan Monnier
@ 2022-01-13 14:47       ` xenodasein--- via Emacs development discussions.
  2022-01-13 15:14         ` Daniel Martín
  0 siblings, 1 reply; 8+ messages in thread
From: xenodasein--- via Emacs development discussions. @ 2022-01-13 14:47 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel



>> What I'm inquiring about is how to implement the collection of
>> completion candidates from multiple buffers.
>>
>
> It's a rather vague question.  Usually completion data either comes from
> Emacs itself (e.g. lists of commands, or elements of a hash-table, ...),
> or from a buffer, or from external info (e.g. files or subprocesses) but
> rarely from several buffers.  This said, I'm not sure what kind of
> difficulty you're facing nor what kind of help you expect to find from
> other examples.  It'd likely depend a lot on what the actual collection
> work looks like.
>
> If you're thinking of completion data along the lines of `imenu` but not
> limited to the current buffer/file, then I suspect you're not looking
> for "multiple buffers" but "multiple files", in which case examples may
> be Eglot and CEDET?
>
>
>  Stefan
>

I wondered about this also; is there built-in completion functionality that
can collect all words or symbols from existing buffers of the same mode, or
all existing buffers?




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

* Re: Collecting completion candidates from multiple files
  2022-01-13 14:47       ` xenodasein--- via Emacs development discussions.
@ 2022-01-13 15:14         ` Daniel Martín
  2022-01-13 15:32           ` xenodasein--- via Emacs development discussions.
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Martín @ 2022-01-13 15:14 UTC (permalink / raw)
  To: xenodasein--- via Emacs development discussions.; +Cc: monnier, xenodasein

xenodasein--- via "Emacs development discussions." <emacs-devel@gnu.org>
writes:

>
> I wondered about this also; is there built-in completion functionality that
> can collect all words or symbols from existing buffers of the same mode, or
> all existing buffers?

M-x find-library RET dabbrev RET

This built-in library provides hooks like
dabbrev-select-buffers-function.  Packages can customize it to return a
custom list of buffers.  For example, a mode for a programming language
that supports includes could implement a custom function that returns
buffers created from parsing includes recursively (something like Vim's
CTRL-P/CTRL-N, if I'm not mistaken).



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

* Re: Collecting completion candidates from multiple files
  2022-01-13 15:14         ` Daniel Martín
@ 2022-01-13 15:32           ` xenodasein--- via Emacs development discussions.
  2022-01-13 17:37             ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: xenodasein--- via Emacs development discussions. @ 2022-01-13 15:32 UTC (permalink / raw)
  To: mardani29; +Cc: emacs-devel



>> I wondered about this also; is there built-in completion functionality that
>> can collect all words or symbols from existing buffers of the same mode, or
>> all existing buffers?
>>
>
> M-x find-library RET dabbrev RET
>
> This built-in library provides hooks like
> dabbrev-select-buffers-function.  Packages can customize it to return a
> custom list of buffers.  For example, a mode for a programming language
> that supports includes could implement a custom function that returns
> buffers created from parsing includes recursively (something like Vim's
> CTRL-P/CTRL-N, if I'm not mistaken).
>

AFAICT it doesn't have a way to connect to completion-at-point by default?
Maybe this would be a good feature to have.




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

* Re: Collecting completion candidates from multiple files
  2022-01-13 15:32           ` xenodasein--- via Emacs development discussions.
@ 2022-01-13 17:37             ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2022-01-13 17:37 UTC (permalink / raw)
  To: xenodasein--- via Emacs development discussions.; +Cc: mardani29, xenodasein

> AFAICT it doesn't have a way to connect to completion-at-point by default?
> Maybe this would be a good feature to have.

See http://elpa.gnu.org/packages/cape.html


        Stefan




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

end of thread, other threads:[~2022-01-13 17:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 20:48 Collecting completion candidates from multiple files Daniele Nicolodi
2022-01-12 23:19 ` Daniel Martín
2022-01-13  8:53   ` Daniele Nicolodi
2022-01-13 14:19     ` Stefan Monnier
2022-01-13 14:47       ` xenodasein--- via Emacs development discussions.
2022-01-13 15:14         ` Daniel Martín
2022-01-13 15:32           ` xenodasein--- via Emacs development discussions.
2022-01-13 17:37             ` Stefan Monnier

Code repositories for project(s) associated with this 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).