Skip to content

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

@heavystrain

Description

@heavystrain

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions