2

I am on Windows. Here is the code I have in my .emacs file to enable AUCTeX to recognize macros I have defined in my own style files:

(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t) ; Enable parse on save.
(setq-default TeX-master nil); https://www.gnu.org/software/auctex/manual/auctex.html
(setq TeX-auto-regexp-list t); https://tex.stackexchange.com/questions/47385/adding-custom-macros-to-completion-list-with-auctex
(setq TeX-auto-parse-length 999999)
(setq TeX-macro-private
      (list
        "./"
        "C:/Users/LilMonkey/texmf/tex/latex/local"))

Logic:

  • TeX-auto-generate should be running because of (setq TeX-parse-self t) and (setq TeX-auto-save t)

  • other variables set based on suggestions given in this answer

  • (setq-default TeX-master nil) based on AUCTeX manual's recommendation, but I don't actually see AUCTeX querying me for the master file; I have tried variations where this line is commented out, but no difference exists

Anyway, I still don't get auto-completion options for macros I have defined in my own *.sty files under C:/Users/LilMonkey/texmf/tex/latex/local. What should I do?

2

I think you misunderstand the way TeX-auto-generate is invoked:

  • TeX-auto-generate should be running because of (setq TeX-parse-self t) and (setq TeX-auto-save t)

    With these 2 variables set, AUCTeX only parses the current .tex file and its master or child files. It also parses the packages loaded via \usepackage and loads <package-name>.el if it finds one. AUCTeX doesn't recursively run TeX-auto-generate on packages for which it doesn't find a style file.

    Looking at the documentation, there is:

    Command: TeX-auto-generate TEX AUTO
    M-x TeX-auto-generate RET Generate style hook for TEX and store it in AUTO. If TEX is a directory, generate style hooks for all files in the directory.

    Try M-x TeX-auto-generate RET c:/Users/LilMonkey/texmf/tex/latex/local/ RET. The results should be then in the directory defined in TeX-auto-private. Note: Consider the parsed results as a starting point, you might have to touch them.

  • other variables set based on suggestions given in this answer

    I consider this line to be harmful:
    (setq TeX-auto-regexp-list t)

    Again from the documentation:

    Variable: TeX-auto-regexp-list

    List of regular expressions matching TeX macro definitions.

    The list has the following format ((REGEXP MATCH TABLE) …), that is, each entry is a list with three elements.

    REGEXP. Regular expression matching the macro we want to parse.

    MATCH. A number or list of numbers, each representing one parenthesized subexpression matched by REGEXP.

    TABLE. The symbol table to store the data. This can be a function, in which case the function is called with the argument MATCH. Use TeX-match-buffer to get match data. If it is not a function, it is presumed to be the name of a variable containing a list of match data. The matched data (a string if MATCH is a number, a list of strings if MATCH is a list of numbers) is put in front of the table.

    I suggest you don't touch this one as it has a sensible default (TeX-auto-full-regexp-list).

    The next line
    (setq TeX-auto-parse-length 999999)
    is also not necessary since you're repeating the default.

  • (setq-default TeX-master nil) based on AUCTeX manual's recommendation, but I don't actually see AUCTeX querying me for the master file

    AUCTeX will not ask if it finds TeX-master set in the local variables of your .tex file. Edit that entry manually and hit C-c C-n.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.