Greg Minshall | 28 Apr 20:48
Picon
Favicon

q? on manual (hooks)

Bill,

i'm working on learning how to customize.  (a little knowledge...)

in the manual, you give an example of using folder-mode-hook.  you have
something like:
----
     (defvar my-mh-init-done nil
       "Non-`nil' when one-time MH-E settings made.")
     (defun my-mh-folder-mode-hook ()
...
             (setq my-mh-init-done t))))
     (add-hook 'mh-folder-mode-hook 'my-mh-folder-mode-hook)
----
to make sure the hook is only run once.

i'm curious why not use remove-hook inside my-mh-folder-mode-hook to
remove itself as a hook?  i would think that would be more efficient
(you wouldn't even call my-mh-folder-mode-hook after the first time
folder mode runs).  but, i suspect the intricacies of
emacs/emacs-lisp/mh-e may be responsible.

cheers, Greg

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
(Continue reading)

Bill Wohler | 19 May 07:02
Picon
Picon

Re: q? on manual (hooks)

Greg Minshall <minshall <at> acm.org> wrote:

> i'm working on learning how to customize.  (a little knowledge...)
> 
> in the manual, you give an example of using folder-mode-hook.  you have
> something like:
> ----
>      (defvar my-mh-init-done nil
>        "Non-`nil' when one-time MH-E settings made.")
>      (defun my-mh-folder-mode-hook ()
> ...
>              (setq my-mh-init-done t))))
>      (add-hook 'mh-folder-mode-hook 'my-mh-folder-mode-hook)
> ----
> to make sure the hook is only run once.
> 
> i'm curious why not use remove-hook inside my-mh-folder-mode-hook to
> remove itself as a hook?  i would think that would be more efficient
> (you wouldn't even call my-mh-folder-mode-hook after the first time
> folder mode runs).  but, i suspect the intricacies of
> emacs/emacs-lisp/mh-e may be responsible.

That would work in this case. However, I wouldn't do that for several
reasons.

You might want to do other things outside of the condition in the hook,
or you might later want to add something to the hook and simply
re-evaluate the function to have it work for the next folder without
having to re-add it to the hook.

(Continue reading)

Greg Minshall | 19 May 23:06
Picon
Favicon

Re: q? on manual (hooks)

Bill,

thanks for the lesson.  i hadn't realized that customization was a
("the accepted"?) way of adding hooks, and i can see how that would
confuse things.

Greg

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane