From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TomSW Newsgroups: gmane.emacs.help Subject: Re: HOWTO add new menu item to the beggining of the menu Date: Wed, 24 Jun 2009 06:08:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <848295c4-9504-4222-a574-ddbcb8657d46@l32g2000vba.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1245855105 22880 80.91.229.12 (24 Jun 2009 14:51:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Jun 2009 14:51:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 24 16:51:38 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MJTp3-0000VR-HY for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Jun 2009 16:51:37 +0200 Original-Received: from localhost ([127.0.0.1]:41062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJTp2-00024V-R7 for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Jun 2009 10:51:36 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!l32g2000vba.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-NNTP-Posting-Host: 84.193.192.199 Original-X-Trace: posting.google.com 1245848902 2355 127.0.0.1 (24 Jun 2009 13:08:22 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 24 Jun 2009 13:08:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l32g2000vba.googlegroups.com; posting-host=84.193.192.199; posting-account=gXCEPAoAAACaHNwa63AHlGuSCIcCahgr User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:170260 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65480 Archived-At: On Jun 23, 4:46 pm, Michal 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