all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Removing menu from menu bar
@ 2008-06-05 16:00 Stephen Berman
  2008-06-05 16:49 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Berman @ 2008-06-05 16:00 UTC (permalink / raw)
  To: help-gnu-emacs

Is it possible to remove menues from the menu bar that a mode defines,
without modifying the source code, but rather using a hook, advice, or
some other device that doesn't touch the source?  For example, if
xyz-mode defines menues xyz1 and xyz2, can I replace them by a menu xyz
without altering the source code?  I'm particularly interested in the
case where the mode defines the menues using easymenu.el.  I'd be
grateful for any suggestions, code snippets, etc.

Steve Berman





^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Removing menu from menu bar
  2008-06-05 16:00 Stephen Berman
@ 2008-06-05 16:49 ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2008-06-05 16:49 UTC (permalink / raw)
  To: 'Stephen Berman', help-gnu-emacs

> Is it possible to remove menues from the menu bar that a mode defines,
> without modifying the source code, but rather using a hook, advice, or
> some other device that doesn't touch the source?  For example, if
> xyz-mode defines menues xyz1 and xyz2, can I replace them by 
> a menu xyz
> without altering the source code?  I'm particularly interested in the
> case where the mode defines the menues using easymenu.el.  I'd be
> grateful for any suggestions, code snippets, etc.

Depends on what you mean by "altering the source code". You will need to use
Emacs Lisp to do what you want, but you could do that using M-:.

Defining (which includes removing and redefining) menus is a form of key
binding. Just as you can remove a key binding by binding the key to nil, so you
can remove a menu.

(define-key some-parent-menu [some-menu] nil)
or
(global-unset-key [menu-bar some-menu])

For example, this gets rid of the Dired mode Subdir menu:

(define-key dired-mode-map [menu-bar subdir] nil)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Removing menu from menu bar
@ 2008-06-05 17:19 martin rudalics
  2008-06-05 18:50 ` Stephen Berman
  0 siblings, 1 reply; 4+ messages in thread
From: martin rudalics @ 2008-06-05 17:19 UTC (permalink / raw)
  To: stephen.berman; +Cc: help-gnu-emacs

You can do something like

(define-key emacs-lisp-mode-map [menu-bar emacs-lisp] nil)

but be aware that modes might also use `menu-bar-update-hook'.  In my
.emacs I have

(global-set-key [menu-bar buffer] nil)
(remove-hook 'menu-bar-update-hook 'menu-bar-update-buffers)

because I don't want a buffer menu.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Removing menu from menu bar
  2008-06-05 17:19 Removing menu from menu bar martin rudalics
@ 2008-06-05 18:50 ` Stephen Berman
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2008-06-05 18:50 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks, Drew and Martin.  I had actually tried using define-key before
posting (because that is what the elisp manual suggests) and it didn't
work.  This was with a menu defined using easymenu.el, so I thought
maybe something was different with that library.  But of course, in fact
it does work, and I'm not sure any more what I did wrong (maybe I had
simply failed to put the undefining statements on the mode hook, though
I thought I had tried that).  Anyway, thanks again for the quick and
helpful responses!

Steve Berman





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-05 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-05 17:19 Removing menu from menu bar martin rudalics
2008-06-05 18:50 ` Stephen Berman
  -- strict thread matches above, loose matches on Subject: below --
2008-06-05 16:00 Stephen Berman
2008-06-05 16:49 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.