[OS X Emacs] Wiki code not working: Symbol's function definition is void: guess-TeX-master

Win Treese treese at acm.org
Sat Sep 10 21:36:38 EDT 2011


On Sep 10, 2011, at 3:24 PM, Marius Hofert wrote:

> Dear all,
> 
> I put in the following code from http://www.emacswiki.org/emacs/AUCTeX#toc17 into my Preferences.el:
> 
> (setq TeX-master (guess-TeX-master (buffer-file-name)))
> (defun guess-TeX-master (filename)
>      "Guess the master file for FILENAME from currently open .tex files."
>      (let ((candidate nil)
>            (filename (file-name-nondirectory filename)))
>        (save-excursion
>          (dolist (buffer (buffer-list))
>            (with-current-buffer buffer
>              (let ((name (buffer-name))
>                    (file buffer-file-name))
>                (if (and file (string-match "\\.tex$" file))
>                    (progn
>                      (goto-char (point-min))
>                      (if (re-search-forward (concat "\\\\input{" filename "}") nil t)
>                          (setq candidate file))
>                      (if (re-search-forward (concat "\\\\include{" (file-name-sans-extension filename) "}") nil t)
>                          (setq candidate file))))))))
>        (if candidate
>            (message "TeX master document: %s" (file-name-nondirectory candidate)))
>        candidate))
> 
> When opening Aquamacs, I obtain:
> 
> An error has occurred while loading `~/Library/Preferences/Aquamacs Emacs/Preferences.el (or .elc)':
> Symbol's function definition is void: guess-TeX-master
> 
> What is wrong with the code on the wiki page?

Marius,

My guess is that this example calls guess-TeX-master before it is defined.

To fix this, move the first line:
	(setq TeX-master (guess-TeX-master (buffer-file-name)))
to the end of the code snippet.

Best regards,

Win Treese
treese at acm.org




More information about the MacOSX-Emacs mailing list