help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs 23, adding 2 buttons/icons to beginning of toolbar. howto?


From: Michal
Subject: Re: emacs 23, adding 2 buttons/icons to beginning of toolbar. howto?
Date: Thu, 25 Jun 2009 12:09:49 +0200
User-agent: mozilla news reader

TomSW <tom.weissmann@gmail.com> writes:
>
> Are your arrows in the toolbar at all, for gdb buffers? When I tried
> the toolbar completely changes...
>

for GDB buffer they do not appear. I mean something else.
Just put the breakpoint in let's say main.cpp and run Your application.
When it stops in main.cpp switch Your cursor to main.cpp. You will see
that "arrow" button appeared there. But ALSO the remaining part of
buttons is the same as for *gud-main* buffer. Number of these buttons is
different from those present in main.cpp just after opening main.cpp.
So my arrow buttons are moved. Their position is different depending on
I am in some *.cpp buffer that has just been "hit" by gdb or it
wasn't.


>
> 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


Thank You for Your code!

best regards,
Michal


reply via email to

[Prev in Thread] Current Thread [Next in Thread]