* HOWTO add new menu item to the beggining of the menu
@ 2009-06-23 14:46 Michal
2009-06-23 18:45 ` Xah Lee
2009-06-24 13:08 ` TomSW
0 siblings, 2 replies; 4+ messages in thread
From: Michal @ 2009-06-23 14:46 UTC (permalink / raw)
To: help-gnu-emacs
Hallo Group Readers!
I have NO problem adding new item to the end of the menu. For example:
(define-key c-mode-map [tool-bar csearch-forw]
`(menu-item "csearch forward" csearch-forward
:image (image :type xpm :file "/tmp/right-arrow.xpm")))
But how to add it to be the first element in a menu?
best regards!
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: HOWTO add new menu item to the beggining of the menu
2009-06-23 14:46 HOWTO add new menu item to the beggining of the menu Michal
@ 2009-06-23 18:45 ` Xah Lee
2009-06-24 11:48 ` Michal
2009-06-24 13:08 ` TomSW
1 sibling, 1 reply; 4+ messages in thread
From: Xah Lee @ 2009-06-23 18:45 UTC (permalink / raw)
To: help-gnu-emacs
On Jun 23, 7:46 am, Michal <rabbi...@tenbit.pl> wrote:
> Hallo Group Readers!
>
> I have NO problem adding new item to the end of the menu. For example:
>
> (define-key c-mode-map [tool-bar csearch-forw]
> `(menu-item "csearch forward" csearch-forward
> :image (image :type xpm :file "/tmp/right-arrow.xpm")))
>
> But how to add it to be the first element in a menu?
there's a define-key-after.
• Modifying-Menus.html#Modifying-Menus
http://xahlee.org/elisp/Modifying-Menus.html#Modifying-Menus
i vaguely recall there's also a define-key-before or similar, but
can't find it now.
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: HOWTO add new menu item to the beggining of the menu
2009-06-23 14:46 HOWTO add new menu item to the beggining of the menu Michal
2009-06-23 18:45 ` Xah Lee
@ 2009-06-24 13:08 ` TomSW
1 sibling, 0 replies; 4+ messages in thread
From: TomSW @ 2009-06-24 13:08 UTC (permalink / raw)
To: help-gnu-emacs
On Jun 23, 4:46 pm, Michal <rabbi...@tenbit.pl> wrote:
> Hallo Group Readers!
>
> I have NO problem adding new item to the end of the menu. For example:
>
> (define-key c-mode-map [tool-bar csearch-forw]
> `(menu-item "csearch forward" csearch-forward
> :image (image :type xpm :file "/tmp/right-arrow.xpm")))
>
> But how to add it to be the first element in a menu?
You're actually adding a toolbar icon, not a menu item: your code
doesn't affect the "C" menu, only the tool bar.
easy-menu-add-item lets you add an item before another one, but I
don't know a predefined way to find the first item in a menu. How
about:
(eval-after-load "cc-mode"
`(let* ((command-name "csearch forward")
(command 'csearch-forward)
(icon "right-arrow")
(c-menu-map (lookup-key c-mode-map [menu-bar C]))
(first-item (catch :first
(map-keymap (lambda (key def) (throw :first
key))
c-menu-map))))
;; add the menu item at the top
(easy-menu-add-item c-menu-map nil
`[,command-name ,command t]
first-item)
;; add it to the tool bar
(tool-bar-add-item-from-menu command icon c-mode-map)))
regards,
Tom SW
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-24 13:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-23 14:46 HOWTO add new menu item to the beggining of the menu Michal
2009-06-23 18:45 ` Xah Lee
2009-06-24 11:48 ` Michal
2009-06-24 13:08 ` TomSW
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.