Path: utzoo!utgpu!watmath!watcgl!kim From: kim@watsup.waterloo.edu (T. Kim Nguyen) Newsgroups: gnu.emacs Subject: weird bug with hooks Message-ID: Date: 27 Oct 89 04:08:40 GMT Sender: daemon@watcgl.waterloo.edu Distribution: gnu Organization: PAMI Group, U. of Waterloo, Ontario Lines: 29 I was trying to make emacs load up a file of TeX functions only the first time tex-mode or latex-mode came up, using the latex-mode-hook and the tex-mode-hook variables. The code below (in my .emacs) didn't work (tex-stuff was never loaded, and the local-set-key didn't work): (defvar latex-nifties-loaded nil) (defun kim-latex-mode-hook () (if (not latex-nifties-loaded) (progn (load "tex-stuff") (setq latex-nifties-loaded t))) (local-set-key "\C-c\C-i" 'LaTeX-insert-begin-end)) (setq latex-mode-hook 'kim-latex-mode-hook) (setq tex-mode-hook 'kim-latex-mode-hook) Only when I replaced the defun'd function with a straight lambda function did the hooks run: (setq latex-mode-hook '(lambda () (if (not latex-nifties-loaded) (progn (load "tex-stuff") (setq latex-nifties-loaded t))) (local-set-key "\C-c\C-i" 'LaTeX-insert-begin-end))) Any ideas? Thanks! -- T. Kim Nguyen kim@watsup.waterloo.{edu|cdn} kim@watsup.uwaterloo.ca {uunet|utzoo|utai|decvax}watmath!watsup!kim Systems Design Engineering -- University of Waterloo, Ontario, Canada