emacs-devel
[Top][All Lists]
Advanced

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

Re: making a toolbar button globaly available


From: Stefan Monnier
Subject: Re: making a toolbar button globaly available
Date: Tue, 20 Jan 2009 00:04:13 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> I've tried these two aproaches, none seem to work.
> Is it a bug or just me?

> (define-minor-mode pocketcompletion-mode
>        "Toggle pocketcompletion mode"
>       ;; The initial value.
>       :init-value nil
>       ;; The indicator for the mode line.
>       :lighter " pocketcompletion"
>       ;; The minor mode bindings.
>       :group 'pocketcompletion
>       :global t
>       :keymap
>       '(([tool-bar pocketcompletion] . 
>          (menu-item "pocketcompletion" pocketcompletion
>                   :image (image :type xpm :file "zoom-in.xpm"))))
>       (message "pocketcompletion minor body %s" pocketcompletion-mode)
>       ;(pocketcompletion-enable-toolbar-button);2nd aproach, uncomment
>       ;       this and comment out :keymap

>       )


> (defun pocketcompletion-enable-toolbar-button ()
>   (define-key global-map [tool-bar pocketcompletion]
>    '(menu-item "pocketcompletion" pocketcompletion
>                :image (image :type xpm :file "zoom-in.xpm")))
>   )

The problem is that whenever you lookup [tool-bar] in global-map (and
such a lookup takes place to find the map into which to add the
pocketcompletion element), you receive a new keymap, built fresh by
tool-bar-make-keymap.

So you want to manipulate tool-bar-map directly.
Note that tool-bar-map is buffer-local, so you won't be able to add
elements truly globally.  For that you'll need to advise
tool-bar-make-keymap :-(


        Stefan




reply via email to

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