all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: TomSW <tom.weissmann@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs 23, adding 2 buttons/icons to beginning of toolbar. howto?
Date: Wed, 24 Jun 2009 12:02:56 -0700 (PDT)	[thread overview]
Message-ID: <7bee096c-01bb-46bd-bd9a-f9561b6a5461@n4g2000vba.googlegroups.com> (raw)
In-Reply-To: m2eit9n3fr.fsf@tenbit.pl

On Jun 24, 3:53 pm, Michal <rabbi...@tenbit.pl> 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


  reply	other threads:[~2009-06-24 19:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-24 13:53 emacs 23, adding 2 buttons/icons to beginning of toolbar. howto? Michal
2009-06-24 19:02 ` TomSW [this message]
2009-06-25 10:09   ` Michal
2009-06-25 13:48     ` TomSW
2009-06-25 16:16       ` Michal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bee096c-01bb-46bd-bd9a-f9561b6a5461@n4g2000vba.googlegroups.com \
    --to=tom.weissmann@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.