help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Adding to a submenu under the HTML menu


From: François Gannaz
Subject: Re: Adding to a submenu under the HTML menu
Date: Sun, 29 Jan 2006 00:57:59 +0100
User-agent: Mutt/1.5.11

Le sam 28 jan 06:03, ken a écrit :
> >
> > So you could try in a *scratch buffer* :
> >   (html-helper-add-tag
> >     '(entity "\C-c%"   "ç" "C cédille" ("ç")))
> >   (html-helper-rebuild-menu)
> > After evaluating, it should appear automatically in the HTML menu.
>
> Marvelous!  Works perfect.  Thanks very much, François.

Je vous en prie ^_^

> > If its's OK, put it in your .emacs, for example in a
> > html-helper-load-hook. For more details and examples, have a look at
> > html-helper-mode.el.
>
> Makes sense....  I've done that before, but with only one function, like
>
> (add-hook 'html-helper-mode-hook 'turn-on-auto-fill)
>
> I found and adapted some code, but my block of several entries shows up
> in the menu multiple times-- more than enough times to make the submenu
> extend from the top of the screen to the bottom.
>
> (add-hook 'html-helper-mode-hook
> ;  (function
> (quote
>    (lambda ()
>      (html-helper-add-tag
>       '(entity "\C-c%"   "ç" "C cédille" ("ç")))
>      (html-helper-add-tag
>       '(entity "\C-cD"   "‡" "double dagger (‡)" ("‡")))
>  [...]
>      (html-helper-rebuild-menu))))
>
> The problem, I'm fairly certain has to do with the placement of
> (html-helper-rebuild-menu) and I've tried putting it in different
> places, even within a separate "(add-hook 'html-helper-mode-hook
> 'html-helper-rebuild-menu)" but none gave satisfactory results.  I could
> be missing some syntax-- perhaps some quoting?--, but I really have no
> idea what it might be.

In fact the problem is that you used the wrong hook. I you read above
carefully, you'll find that I suggested to use html-helper-load-hook.
Yet you used html-helper-mode-hook. A load-hook is evaluated once (when
the file is loaded) whereas a mode-hook might be evaluated several times
(in fact, each time you enter the mode).

So you should write something like:
(defun my-html-load-hook ()
  (mapcar                         ; just to avoid repeating hh-add-tag
   'html-helper-add-tag
   '(
     (entity "\C-c%"   "ç" "C cédille" ("ç"))
     (entity "\C-cD"   "‡" "double dagger (‡)" ("‡"))
     ;; and so on
     ))
  (html-helper-rebuild-menu))
(add-hook 'html-helper-load-hook 'my-html-load-hook)

Hope it helps.
--
François Gannaz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]