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

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

Re: Adding an entry to the menu bar


From: Kevin Rodgers
Subject: Re: Adding an entry to the menu bar
Date: Thu, 20 Jul 2006 16:53:40 -0600
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

Tim Allen wrote:
I'm trying to add an entry to the Buffers menu bar (for creating a new
scratch). My attempt below works OK when adding to the Files menu, but
changing "files" to "buffers" does not insert the new menu option:

(define-key global-map
  [menu-bar files create-scratch]
  '("New buffer" . create-scratch-buffer))


I think this may be because the contents of the Buffers menu is created "on-the-fly", as it needs to list the actual buffers present. Can anyone help with this?

Right (plus the key is actually [menu-bar buffer], not [menu-bar
buffers]).

menu-bar-update-buffers is the function where this happens, so you could
try invoking your code like this:

(defadvice menu-bar-update-buffers (after create-scratch activate)
  "Add a \"New buffer\" entry to the \"Buffers\" menu."
  (define-key (current-global-map) [menu-bar buffer create-scratch]
    '("New buffer" . create-scratch-buffer)))

--
Kevin





reply via email to

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