[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Newbie: Help with elisp, please

Brad Camroux <bgcamroux@shaw.ca> wrote:

> Okay... what you've given me should help a lot.  One thing I don't 
> really understand, though, is hooks.  How do I know that, when I use 
> (add-hook ....) that it will run once I enter LaTeX-mode?  The GNU 


  Each major mode should have a mode hook named modename-mode-hook. The
  major mode command should run that hook, with run-hooks, as the very
  last thing it does. See section 23.6 Hooks.

> Emacs Manual and the Emacs Lisp Reference Guide don't really explain 
> this in any detail.  Oh yeah... and in the above code snippet, you 

That you didn't find the information doesn't mean it is not there...

> have the function (?) do-LaTeX.  Do I define these functions before I 
> define the function brad-setup-LaTeX-keybindings?  I'm thinking yes.

The order in the source file shouldn't matter because when Emacs

  (add-hook 'LaTeX-mode-hook 'brad-setup-LaTeX-keybindings)

add-hook will store the symbol in the hook but doesn't need to access
the symbol's function definition. That the symbol has a function cell
(i.e., there actually exists a function named
brad-setup-LaTeX-keybindings) is only relevant when the hook is
executed. By that time, obviously, the called function must have been

> Finally, do I have to put all this in my .emacs file, or can I put it 
> in a .el file in some other directory as long as that dir is in my 
> load-path?

You can put it in your .emacs.el. You can also put it in another file
that is in your load-path and load it with (load "file") from .emacs.el.
You can also put it in the load-path, have it (provide 'brad-foobar) and
have .emacs.el (require 'brad-foobar)...


Reply to: