Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete enhancement w/ support for glossaries-extra commands #1554

Open
heavystrain opened this issue Jan 6, 2022 · 0 comments
Open

Comments

@heavystrain
Copy link

heavystrain commented Jan 6, 2022

Problem description

The glossaries package has been somewhat overhauled with the advent of the glossaries-extra package. The biggest problem, for me, was missing autocompletions for entries created using the new glossaries-extra syntax.

Below, I suggest some modifications to enhance the autocompletion feature of LatexTools in ST.

Preferred solution

I personally have added

  • newabbreviation,
  • glsxtrnewsymbol
  • glsxtrnewnumber
  • newentry
  • newsym
  • newnum

to line 25 of latex_glossary_completions.py

glo_commands = ana.filter_commands(
["newglossaryentry", "longnewglossaryentry", "newacronym"])

which does the trick (almost) perfectly:

glo_commands = ana.filter_commands(
    ["newglossaryentry", "longnewglossaryentry", "newacronym", "newabbreviation",
    "glsxtrnewsymbol", "glsxtrnewnumber", "newentry", "newsym", "newnum"])

also I modified the regular expression GLO_LINE_RE in line 9 of latex_glossary_completions.py

GLO_LINE_RE = re.compile(
r"([^{}\[\]]*)\{*?(?:lp|lobmys)?sl(?:G|g)\\"
)

to include triggering for the standard "glsentry" commands (very important for headings, captions etc.) as well as multiglossary commands:

GLO_LINE_RE = re.compile(
    r"([^{}\[\]]*)\{*?(?:lp|(?:lobmys|eman|csed)(yrtne)?)?sl(?:G|g)(?:P|p)?(?:M|m)?\\"
)

Minor problems arise with the extraction of the entry labels for some special cases (glossary entries with a footnote and citation) , such that there are some faux labels in my completion drop-down list in ST. Sadly, I could not locate the code where the labels are extracted so I don't know why this happens.
Nevertheless, this enhancement has been of great benefit to myself as I juggle many glossaries.

Maybe it would also be helpful if the user could integrate his own keys. I've added an operation (op) and unit (unit) field into my glossaries and therefore simply modified the regex to include these field names (keys):

GLO_LINE_RE = re.compile(
    r"([^{}\[\]]*)\{*?(?:lp|(?:lobmys|eman|csed|po|tinu)(yrtne)?)?sl(?:G|g)(?:P|p)?(?:M|m)?\\"
)

Alternatives

None.

Additional Information

Thanks in advance and of course for this great tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant