3

a own sty file is not parsed to find commands, it means they can not use with C-c C-m

I use the following .emacs

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(require 'tex-site)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-save-query nil)
(setq TeX-PDF-mode t) 
(set-default-coding-systems 'utf-8-unix)

This is a test sty file (test.sty)

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{test}
  [2013/03/19 v0.01 LaTeX package for my own purpose]
\newcommand{\mysecondtest}{My second test}

And this is my MWE

\documentclass{article}
\usepackage{test}
\newcommand{\myfirsttest}{My first test}
\begin{document}
\myfirsttest{}
\end{document}

With C-c C-m I can use only myfirsttest, but not mysecondtest. What can I do, to use the own commands with auctex? I use auctex 11.87 and emacs23 23.4+1-4 on Debian Linux.

Thanks for helpful hints

  • 2
    You need to run TeX-auto-generate on your .sty file to extract the information. – Andrew Swann Mar 19 '13 at 13:01
  • 1
    Is there a file test.el in a subdirectory called save? If not, is one created if you edit and save test.sty? If so, do you still have the same problem? – Charles Stewart Mar 19 '13 at 13:02
  • is there a way, to automatic run TeX-auto-generate if the .sty file was changed? – Micha Mar 19 '13 at 13:26
  • Is it possible, to include with auctex not only the command (defined with \newcommand), but instead of it the entire block (it means "My first test" instead of \myfirsttest{}? – Micha Mar 19 '13 at 13:32
  • 3
    @Micha: To your first question, left to its own devices, Auctex generates its style files every time you edit and save a .tex or .sty file. TeX-auto-generate will force this to happen even if you do not edit anything, and there are ways to make this happen every time Auctex looks into a directory. To your second question: I'm not quite sure what you are after, but maybe you should raise that as a new question. – Charles Stewart Mar 19 '13 at 15:19
2

The issue is that the algorithm that Auctex applies to generate style files, which it uses to characterise the commands available via C-c C-m, can fail to see that a command has been generated.

Left to its own devices, Auctex generates its style files every time you edit and save a .tex or .sty file. TeX-auto-generate will force this to happen even if you do not edit anything, and there are ways to make this happen every time Auctex looks into a directory.

(Hoisted from comment, per Joseph's request)

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.