larsbrinkhoff / forth-mode

Wants to be the SLIME of Forth
GNU General Public License v3.0
61 stars 17 forks source link

Add support for symbol completion #3

Closed lokedhs closed 8 years ago

lokedhs commented 8 years ago

To implement symbol completion, set the variable completion-at-point-functions to a list of completion functions (usually only one):

(setq-local completion-at-point-functions '(forth-mode-expand-symbol))

The behaviour of the symbol expansion function is described in the documentation for the variable completion-at-point-functions.

larsbrinkhoff commented 8 years ago

Elisp ref: https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion-in-Buffers.html

completion-at-point-functions docstring: https://docstrings.github.io/sym/completion-at-point-functions.html

larsbrinkhoff commented 8 years ago

Just jotting down some notes.

In general, there are two ways to figure out information about Forth programs:

In this case, the imenu thingy already has a good idea about all definitions in a buffer, so maybe use that?

I already have a function forth-words which returns a list of strings: all known definitions in an interactive Forth session. Of course, Forth can't know about symbols unless the file has been loaded.

lokedhs commented 8 years ago

The imenu parser will only parse files which are actively being processed (for example, as the result of the file being opened in a buffer, or when navigating to it using speedbar). It can't really be used to enumerate all files in a project.

larsbrinkhoff commented 8 years ago

Sure, I had no expectations it would search other files.

larsbrinkhoff commented 8 years ago

Added symbol comletion in cc267b4.