home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / help-lucid-emacs / text0329.txt < prev    next >
Encoding:
Text File  |  1993-07-14  |  2.4 KB  |  59 lines

  1. In <Pine.3.05.9305091938.C13279-a100000@ella> polcher@lmd.ens.fr (Jan Polcher) writes:
  2.  
  3.  
  4. >Hi,
  5.  
  6. >I have just written menus for a few major modes.
  7. >When a file of a new mode is loaded the menubar changes. But when I switch
  8. >back to the old file the menubar does not go back to the old one. Is that
  9. >normal or have I made a mistake.
  10.  
  11. >Is there a way of changing this behavior and having menubars which adapt
  12. >to the file being edited? Or at least have a menu with which one can
  13. >switch from one menubar to the other.
  14.  
  15. >Thanks for any help.
  16.  
  17. That's the normal behavior; there is a hook run when a major mode is
  18. installed, but none when it is de-installed.  I believe that GnuEmacs
  19. v19 contains after-hooks, but I haven't seen it myself.
  20.  
  21. I've done something like what you describe with a Lisp Function menu
  22. which is sensitive to the current mode. Basically, you have to install a
  23. hook function in activate-menubar-hook to check the current buffer's
  24. mode & modify the meny accordingly:
  25.  
  26. (defun sensitize-lisp-menu-hook ()
  27.   "Enable or disable menu items for evaluation of lisp in buffer.
  28. Enable if buffer is in emacs-lisp-mode or interactive-lisp-mode, disable
  29. otherwise."
  30.   (if (or (eq major-mode 'emacs-lisp-mode)
  31.           (eq major-mode 'lisp-interaction-mode))
  32.       (progn
  33.         (enable-menu-item '("Lisp" "Eval Defun"))
  34.         (enable-menu-item '("Lisp" "Eval Region"))
  35.         (enable-menu-item '("Lisp" "Eval Buffer")))
  36.     (disable-menu-item '("Lisp" "Eval Defun"))
  37.     (disable-menu-item '("Lisp" "Eval Region"))
  38.     (disable-menu-item '("Lisp" "Eval Buffer")))
  39.   nil)
  40.  
  41. (add-hook 'activate-menubar-hook 'sensitize-lisp-menu-hook)
  42. (set-menubar-dirty-flag)
  43.  
  44. -----------------------------------------------------------------------------
  45. "The end cause ... is too often handed off as an afterthought to harried
  46. interface designers who follow programmers around with virtual brooms
  47. and pails." - Brenda Laurel in "Computers as Theatre"
  48. -----------------------------------------------------------------------------
  49. Bruce Cohen, Servio Corporation                  |   email:  cohenb@slc.com
  50. 14908 NW Greenbrier Pkwy, #100                   |   phone: (503)690-3602
  51. Beaverton, OR 97006
  52.  
  53. -- 
  54. -----------------------------------------------------------------------------
  55. "The end cause ... is too often handed off as an afterthought to harried
  56. interface designers who follow programmers around with virtual brooms
  57. and pails." - Brenda Laurel in "Computers as Theatre"
  58.  
  59.