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: emacs 23, adding 2 buttons/icons to beginning of toolbar. howto? Date: Wed, 24 Jun 2009 12:02:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <7bee096c-01bb-46bd-bd9a-f9561b6a5461@n4g2000vba.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 1245872598 18080 80.91.229.12 (24 Jun 2009 19:43:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Jun 2009 19:43:18 +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 21:43:11 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 1MJYNA-0005RX-Qc for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Jun 2009 21:43:09 +0200 Original-Received: from localhost ([127.0.0.1]:39947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJYNA-0006P0-97 for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Jun 2009 15:43:08 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!n4g2000vba.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Original-NNTP-Posting-Host: 84.193.192.199 Original-X-Trace: posting.google.com 1245870176 9556 127.0.0.1 (24 Jun 2009 19:02:56 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 24 Jun 2009 19:02:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n4g2000vba.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:170268 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:65487 Archived-At: On Jun 24, 3:53 pm, Michal wrote: > It shortly turned out that when I run gdb, the length of toolbar changes > in c/c++ files "visited" by gdb. > When I am pressing my backward button on an on through let's say > non-gdb c/c++ files, I do not have to move mouse pointer because > position of my backward button does not change, but when next buffer > that is visited is gdb c/c++ one, then toolbar icons list is shorter > thus my backward button also gets moved and I have to move my mouse > pointer. Are your arrows in the toolbar at all, for gdb buffers? When I tried the toolbar completely changes... > I see solving this by adding my 2 icons/buttons to the beginning of the > toolbar list, but how to do this, and how to do this only for c/c++ > buffers also those visited by gdb? Tool bar items can be controlled by the variable tool-bar-map. By making it local to a buffer you can have different toolbars in different buffers, which is why it changes with gdb. The c modes use the global value - if you want to change it just for those modes, you have to make it buffer local in those modes... How about: ;; Create a specific tool bar map for C modes (defvar c-tool-bar-map (copy-keymap tool-bar-map)) ;; Create a map just to contain the extra items (let ((temp-map (make-sparse-keymap))) ;; add the items (dolist (spec '(("right-arrow" csearch-forward) ("left-arrow" csearch-backward))) (tool-bar-local-item (car spec) (cadr spec) (cadr spec) temp-map)) ;; now use easy-menu-add-item to tweak c-tool-bar-map ;; and gud-tool-bar-map (dolist (map (list c-tool-bar-map gud-tool-bar-map)) (let ((first-item (catch :first (map-keymap (lambda (key def) (throw :first key)) map)))) ;; (map-keymap (lambda (key defn) (easy-menu-add-item map nil (cons key defn) first- item)) temp-map)))) ;; tool-bar-map needs to be al ocal variable for c modes (dolist (hook '(c-mode-hook c++-mode-hook)) (add-hook hook (lambda () (unless (local-variable-p 'tool-bar-map) (set (make-local-variable 'tool-bar-map) c-tool-bar-map))) 'append)) regards, Tom SW