all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Adding an entry to the menu bar
@ 2006-07-20 14:18 Tim Allen
  2006-07-20 22:53 ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Allen @ 2006-07-20 14:18 UTC (permalink / raw)


Hi

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?

Thanks  

Tim

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

* Re: Adding an entry to the menu bar
  2006-07-20 14:18 Adding an entry to the menu bar Tim Allen
@ 2006-07-20 22:53 ` Kevin Rodgers
  2006-07-21  7:52   ` Tim Allen
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2006-07-20 22:53 UTC (permalink / raw)


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

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

* Re: Adding an entry to the menu bar
  2006-07-20 22:53 ` Kevin Rodgers
@ 2006-07-21  7:52   ` Tim Allen
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Allen @ 2006-07-21  7:52 UTC (permalink / raw)
  Cc: help-gnu-emacs

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

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

end of thread, other threads:[~2006-07-21  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-20 14:18 Adding an entry to the menu bar Tim Allen
2006-07-20 22:53 ` Kevin Rodgers
2006-07-21  7:52   ` Tim Allen

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.