Here is the PR on auto-completion. A few explanations:
The file extract_gams_symbols.sh extracts all GAMS commands from the file syntaxdata.h installed in GAMS. We have to run it once in a while if there are new GAMS commands. GAMS Studio directly imports syntaxdata.h, but I don't think we can do that, so I decided to parse it and extract the relevant info. extract_gams_symbols.sh creates a bunch of text files in the main folder (you may want to move them elsewhere to clean the folder). The most important one is gams_commands.txt which contains all the commands. It is created by concatenating all the other text files. I have kept the text files with the different types of commands (declaration, options, dollar commands, ...) because they could be useful to improve other aspect of gams-mode.
Since the font-locking in gams-mode is based on matching GAMS commands, it would be better to include all GAMS commands so that the font-locking is always good. This could be done by importing some of the provided text files instead of hard coding in gams-mode.el the list of commands.
You will see that the changes in gams-mode.el are very small.
I have introduced a new custom variable: gams-completion-case. It controls the case. It follows GAMS Studio options: default to CamelCase and possible to use UPPERCASE or lowercase.
It is necessary to set the variable completion-ignore-case to true because this allows auto-completion to work even if you type everything in lower case.
Everything is done by the function gams-completion-at-point which is linked to the builtin variable completion-at-point-functions.
The only thing related to company is the following line. It defines the proper backends to use in GAMS mode: company-files for completing file names, company-yasnippet for completing snippets, company-dabbrev-code for completion based on the content of the buffer (the -code version is important because company-dabbrev returns everything in lower case), and finally company-capf for using completion-at-point of emacs where I have put all the commands.
Someone using company will see the auto-completion automatically appearing (before that it worked only on symbols).
I am not sure what it would do for an auto-complete user. My guess is if the user is not using gams-ac, it should now get auto-completion automatically. For gams-ac users, it should not change anything.
For someone not using company or auto-complete, he will now have access to the standard emacs completion-at-point (C-M-i).
Remember that most was done with ChatGPT help, so it may be possible to do something simpler.
Here is the PR on auto-completion. A few explanations:
syntaxdata.h
installed in GAMS. We have to run it once in a while if there are new GAMS commands. GAMS Studio directly importssyntaxdata.h
, but I don't think we can do that, so I decided to parse it and extract the relevant info.extract_gams_symbols.sh
creates a bunch of text files in the main folder (you may want to move them elsewhere to clean the folder). The most important one is gams_commands.txt which contains all the commands. It is created by concatenating all the other text files. I have kept the text files with the different types of commands (declaration, options, dollar commands, ...) because they could be useful to improve other aspect of gams-mode.gams-mode.el
the list of commands.gams-mode.el
are very small.gams-completion-case
. It controls the case. It follows GAMS Studio options: default to CamelCase and possible to use UPPERCASE or lowercase.completion-ignore-case
to true because this allows auto-completion to work even if you type everything in lower case.gams-completion-at-point
which is linked to the builtin variablecompletion-at-point-functions
.company-files
for completing file names,company-yasnippet
for completing snippets,company-dabbrev-code
for completion based on the content of the buffer (the-code
version is important becausecompany-dabbrev
returns everything in lower case), and finallycompany-capf
for using completion-at-point of emacs where I have put all the commands.From a user perspective:
Remember that most was done with ChatGPT help, so it may be possible to do something simpler.