[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding an entry to the menu bar
From: |
Tim Allen |
Subject: |
Re: Adding an entry to the menu bar |
Date: |
Fri, 21 Jul 2006 08:52:54 +0100 (BST) |
On Thu, 20 Jul 2006, Kevin Rodgers wrote:
> 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)))
>
>
Thanks Kevin, that was exactly what I needed.
Tim