[OS X Emacs] Re: Wiki code not working: Symbol's function

Win Treese treese at acm.org
Mon Sep 12 15:47:41 EDT 2011

On Sep 12, 2011, at 11:14 AM, Hofert Jan Marius wrote:

> Dear David,
> thanks for helping.
> I tried this:
> (require 'tex-site)
> (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))
> (setq 'LaTeX-mode-hook
> 	'(lambda ()
> 		(setq TeX-master (guess-TeX-master (buffer-file-name)))))
> I obtained the same error as before:
> An error has occurred while loading `~/Library/Preferences/Aquamacs Emacs/Preferences.el (or .elc)':
> Wrong type argument: symbolp, (quote LaTeX-mode-hook)


A typo on my part. The code should be (towards the end):

(add-hook 'LaTeX-mode-hook
		'(lambda ()
			(setq TeX-master (guess-TeX-master (buffer-file-name)))))

add-hook is the proper thing to use, not setq. And setq doesn't like the quoted
symbol, but add-hook does.

I should test these things before replying!


 - Win

More information about the MacOSX-Emacs mailing list