The menubar of the mac port emacs can not be disabled.

I currently use (define-key global-map [menu-bar file] nil) (define-key global-map [menu-bar edit] nil) (define-key global-map [menu-bar options] nil) (define-key global-map [menu-bar buffer] nil) (define-key global-map [menu-bar tools] nil) (define-key global-map [menu-bar help-menu] nil) to remove items from the global map.

But I tried to use a loop to do so but failed (dolist (menu '(file edit options buffer tools help-menu)) (define-key global-map [menu-bar menu] nil))

I just get confused with the variable type of menu in [menubar menu]. I'm not sure whether it is a symbol or not. So any suggestion on this will be appreciated.

P.S. I'd like to get all the menubar items like from check-doc-minor-map rather than just the global-map. Can I achieve it? Or if there's some method to add hook to remove all the items before showing the menubar item, please let me know! Thanks!

  • 1
    Why not setting (define-key global-map [menu-bar] nil)? – Tobias Dec 1 '16 at 13:06
  • 1
    If you really want to iterate you have to use (vector 'menu-bar menu) instead of [menu-bar menu]. See the doc for Vectors: A vector, like a string or a number, is considered a constant for evaluation: the result of evaluating it is the same vector. This does not evaluate or even examine the elements of the vector. So menu is not evaluated in your loop code. – Tobias Dec 1 '16 at 13:14
  • @Tobias Thanks for your reply. I've tried that before but setting it to nil will cause error when some packages like helm or projectile or org trying to add menu item to default menu like Tools. In fact, setting each menu to nil still cause this error. I didn't know about vector in emacs-lisp before. Thanks for you information ! – stackunderflow Dec 1 '16 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.