home *** CD-ROM | disk | FTP | other *** search
- In <Pine.3.05.9305091938.C13279-a100000@ella> polcher@lmd.ens.fr (Jan Polcher) writes:
-
-
- >Hi,
-
- >I have just written menus for a few major modes.
- >When a file of a new mode is loaded the menubar changes. But when I switch
- >back to the old file the menubar does not go back to the old one. Is that
- >normal or have I made a mistake.
-
- >Is there a way of changing this behavior and having menubars which adapt
- >to the file being edited? Or at least have a menu with which one can
- >switch from one menubar to the other.
-
- >Thanks for any help.
-
- That's the normal behavior; there is a hook run when a major mode is
- installed, but none when it is de-installed. I believe that GnuEmacs
- v19 contains after-hooks, but I haven't seen it myself.
-
- I've done something like what you describe with a Lisp Function menu
- which is sensitive to the current mode. Basically, you have to install a
- hook function in activate-menubar-hook to check the current buffer's
- mode & modify the meny accordingly:
-
- (defun sensitize-lisp-menu-hook ()
- "Enable or disable menu items for evaluation of lisp in buffer.
- Enable if buffer is in emacs-lisp-mode or interactive-lisp-mode, disable
- otherwise."
- (if (or (eq major-mode 'emacs-lisp-mode)
- (eq major-mode 'lisp-interaction-mode))
- (progn
- (enable-menu-item '("Lisp" "Eval Defun"))
- (enable-menu-item '("Lisp" "Eval Region"))
- (enable-menu-item '("Lisp" "Eval Buffer")))
- (disable-menu-item '("Lisp" "Eval Defun"))
- (disable-menu-item '("Lisp" "Eval Region"))
- (disable-menu-item '("Lisp" "Eval Buffer")))
- nil)
-
- (add-hook 'activate-menubar-hook 'sensitize-lisp-menu-hook)
- (set-menubar-dirty-flag)
-
- -----------------------------------------------------------------------------
- "The end cause ... is too often handed off as an afterthought to harried
- interface designers who follow programmers around with virtual brooms
- and pails." - Brenda Laurel in "Computers as Theatre"
- -----------------------------------------------------------------------------
- Bruce Cohen, Servio Corporation | email: cohenb@slc.com
- 14908 NW Greenbrier Pkwy, #100 | phone: (503)690-3602
- Beaverton, OR 97006
-
- --
- -----------------------------------------------------------------------------
- "The end cause ... is too often handed off as an afterthought to harried
- interface designers who follow programmers around with virtual brooms
- and pails." - Brenda Laurel in "Computers as Theatre"
-
-