Discussion:
[AUCTeX] Help with getting AUCTeX to parse my personal *.sty files for macros?
Brian Merchant
2018-01-14 23:44:38 UTC
Permalink
Hi all,

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)`:
https://tex.stackexchange.com/questions/103224/auctex-does-not-parse-own-sty-file

* other variables set based on suggestions given in this answer:
https://tex.stackexchange.com/a/47416/49339

* `(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?
g***@gmail.com
2018-01-15 06:07:47 UTC
Permalink
Hi Brian,

I'm also on Windows with AUCTeX 11.90.2 and Emacs 25.3.1.

I wonder if you're missing a quote and a slash in your TeX-macro-private. Can you try with

(setq TeX-macro-private (quote ("./" "c:/Users/LilMonkey/texmf/tex/latex/local/")))

or even better, set all those variables via customize?

Cheers,
J
Post by Brian Merchant
Hi all,
        (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"
            ))
* TeX-auto-generate should be running because of `(setq TeX-parse-self t)` and `(setq TeX-auto-save t)`: https://tex.stackexchange.com/questions/103224/auctex-does-not-parse-own-sty-file
* other variables set based on suggestions given in this answer: https://tex.stackexchange.com/a/47416/49339
* `(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?
Brian Merchant
2018-01-15 18:59:40 UTC
Permalink
Hi J,

I have AUCTeX 12.1.0 and Emacs 25.3.1, with spacemacs on top.

I tried out your suggestion (setq TeX-macro-private (quote ("./"
"c:/Users/LilMonkey/texmf/tex/latex/local/"))), but no luck :(

Can you explain what you mean by "set all those variables via customize"?
Do you mean using M-x customize? If yes, I tried that too, but with no
luck.

Might you have other suggestions?

Kind regards,
Brian
Post by g***@gmail.com
Hi Brian,
I'm also on Windows with AUCTeX 11.90.2 and Emacs 25.3.1.
I wonder if you're missing a quote and a slash in your TeX-macro-private. Can you try with
(setq TeX-macro-private (quote ("./" "c:/Users/LilMonkey/texmf/tex/
latex/local/")))
or even better, set all those variables via customize?
Cheers,
J
Post by Brian Merchant
Hi all,
I am on Windows. Here is the code I have in my `.emacs` file to enable
(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
Post by Brian Merchant
(setq TeX-auto-regexp-list t); https://tex.stackexchange.com/
questions/47385/adding-custom-macros-to-completion-list-with-auctex
Post by Brian Merchant
(setq TeX-auto-parse-length 999999)
(setq TeX-macro-private
(list
"./"
"C:/Users/LilMonkey/texmf/tex/latex/local"
))
* TeX-auto-generate should be running because of `(setq TeX-parse-self
t)` and `(setq TeX-auto-save t)`: https://tex.stackexchange.com/
questions/103224/auctex-does-not-parse-own-sty-file
https://tex.stackexchange.com/a/47416/49339
Post by Brian Merchant
* `(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
Post by Brian Merchant
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?
g***@gmail.com
2018-01-15 22:17:29 UTC
Permalink
Hi Brian,

The help for "TeX-parse-self" says "Parse file after loading it if no style hook is found for it". Is it possible that an old style file (.el) already exists for your file and therefore no reparsing is done? This happens to me from time to time.

Try typing

C-u C-c C-n

while you're visiting the file. This should remove old style hooks and reparse the file. Right after you type that, check the message log (buffer *Messages*, asterisks included) to see which style files the parser has loaded and from which directories.

Cheers,
J
Post by Brian Merchant
Hi J,
I have AUCTeX 12.1.0 and Emacs 25.3.1, with spacemacs on top.
I tried out your suggestion (setq TeX-macro-private (quote ("./" "c:/Users/LilMonkey/texmf/tex/latex/local/"))), but no luck :(
Can you explain what you mean by "set all those variables via customize"? Do you mean using M-x customize? If yes, I tried that too, but with no luck.
Might you have other suggestions?
Kind regards,
Brian
g***@gmail.com
2018-01-15 22:28:17 UTC
Permalink
PS: It's also good if you visit your own .sty files with Emacs, ensure that you're in LaTeX-mode, and issue a

C-u C-c C-n

there too, so their corresponding style (.el) files will be created.

Also, style .el files for your personal packages (.sty) sometimes need to be tweaked by hand to ensure the macros in them do what you want...

Cheers,
J
Post by g***@gmail.com
Hi Brian,
The help for "TeX-parse-self" says "Parse file after loading it if no style hook is found for it". Is it possible that an old style file (.el) already exists for your file and therefore no reparsing is done? This happens to me from time to time.
Try typing
C-u C-c C-n
while you're visiting the file. This should remove old style hooks and reparse the file. Right after you type that, check the message log (buffer *Messages*, asterisks included) to see which style files the parser has loaded and from which directories.
Cheers,
J
g***@gmail.com
2018-01-16 07:25:46 UTC
Permalink
Hi Brian, that's great. Happy AUCTeXing!
J
Hi J,
Generating the .el files for my own .sty files, and making sure they were in the write auto folder worked for me. See this question's answer for details: https://tex.stackexchange.com/questions/410393/how-to-properly-set-up-auctex-to-parse-macros-from-my-own-sty-files
Thank you very much for your help! Now I can finally get working, instead of fighting the editor :)
Kind regards,
Brian
Loading...