all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* making change of tool-bar entry persistent
@ 2010-05-23 14:11 Stefan Vollmar
  2010-05-25  6:23 ` Kevin Rodgers
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Vollmar @ 2010-05-23 14:11 UTC (permalink / raw)
  To: Help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

Hallo,

I want to re-define what happends when an exising toolbar icon is pressed. In the Emacs documentation I found an example similar to this:

(define-key 
  global-map 
  [tool-bar new-file]
  '(menu-item "New Buffer" my-new-buffer
			  :image (image :type xpm :file "new.xpm")))

Executing this code in Emacs 23.2 this will indeed show the desired effect - but only for about 2 seconds: the tool-bar is then automatically redrawn and behaves as before. How can I modify an existing toolbar so that the change is persistent?

Many thanks in advance.
Warm regards,
 Stefan
-- 
Dr. Stefan Vollmar, Dipl.-Phys.
Head of IT group
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213  FAX +49-221-4726-298
Tel.: +49-221-478-5713  Mobile: 0160-93874279
Email: vollmar@nf.mpg.de   http://www.nf.mpg.de







[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4409 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: making change of tool-bar entry persistent
  2010-05-23 14:11 making change of tool-bar entry persistent Stefan Vollmar
@ 2010-05-25  6:23 ` Kevin Rodgers
  2010-05-25 22:53   ` Stefan Vollmar
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2010-05-25  6:23 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Vollmar wrote:
> Hallo,
> 
> I want to re-define what happends when an exising toolbar icon is
> pressed. In the Emacs documentation I found an example similar to
> this:
> 
> (define-key 
>   global-map 
>   [tool-bar new-file]
>   '(menu-item "New Buffer" my-new-buffer
> 			  :image (image :type xpm :file "new.xpm")))
> 
 > Executing this code in Emacs 23.2 this will indeed show the desired
 > effect - but only for about 2 seconds: the tool-bar is then
 > automatically redrawn and behaves as before. How can I modify an
 > existing toolbar so that the change is persistent?

  -- Variable: tool-bar-map
      By default, the global map binds `[tool-bar]' as follows:
           (global-set-key [tool-bar]
           		'(menu-item "tool bar" ignore
           			    :filter (lambda (ignore) tool-bar-map)))
      Thus the tool bar map is derived dynamically from the value of
      variable `tool-bar-map' and you should normally adjust the default
      (global) tool bar by changing that map.  Major modes may replace
      the global bar completely by making `tool-bar-map' buffer-local
      and set to a keymap containing only the desired items.  Info mode
      provides an example.

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: making change of tool-bar entry persistent
  2010-05-25  6:23 ` Kevin Rodgers
@ 2010-05-25 22:53   ` Stefan Vollmar
  2010-05-26 12:37     ` Joel J. Adamson
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Vollmar @ 2010-05-25 22:53 UTC (permalink / raw)
  To: Kevin Rodgers; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2366 bytes --]

Dear Kevin,

On 25.05.2010, at 08:23, Kevin Rodgers wrote:

> Stefan Vollmar wrote:
>> Hallo,
>> I want to re-define what happends when an exising toolbar icon is
>> pressed. In the Emacs documentation I found an example similar to
>> this:
>> (define-key   global-map   [tool-bar new-file]
>>  '(menu-item "New Buffer" my-new-buffer
>> 			  :image (image :type xpm :file "new.xpm")))
> > Executing this code in Emacs 23.2 this will indeed show the desired
> > effect - but only for about 2 seconds: the tool-bar is then
> > automatically redrawn and behaves as before. How can I modify an
> > existing toolbar so that the change is persistent?
> 
> -- Variable: tool-bar-map
>     By default, the global map binds `[tool-bar]' as follows:
>          (global-set-key [tool-bar]
>          		'(menu-item "tool bar" ignore
>          			    :filter (lambda (ignore) tool-bar-map)))
>     Thus the tool bar map is derived dynamically from the value of
>     variable `tool-bar-map' and you should normally adjust the default
>     (global) tool bar by changing that map.  Major modes may replace
>     the global bar completely by making `tool-bar-map' buffer-local
>     and set to a keymap containing only the desired items.  Info mode
>     provides an example.


I looked up how changing the toolbar is done in info.el and was able to solve my problem with this code:

(defvar my-tool-bar-map tool-bar-map)
(define-key my-tool-bar-map [new-file] 
  '(menu-item "New Document (Org)" my-new-buffer
			  :image (image :type xpm :file "new.xpm")))
(set (make-local-variable 'tool-bar-map) my-tool-bar-map)

The "New File" icon (left-most in Emacs 23.2) will now use my own function (a wrapper for Kevin Rodger's switch-to-new-untitled-buffer code, thanks!), which is

(defun my-new-buffer ()
  "creates an empty new 'untitled' buffer"			
  (interactive)
  (put 'buffer-offer-save 'permanent-local t)
  (let ((default-major-mode 'org-mode)) 
	(switch-to-new-untitled-buffer)))

Thanks again, Kevin!

Warm regards,
 Stefan
-- 
Dr. Stefan Vollmar, Dipl.-Phys.
Head of IT group
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213  FAX +49-221-4726-298
Tel.: +49-221-478-5713  Mobile: 0160-93874279
Email: vollmar@nf.mpg.de   http://www.nf.mpg.de







[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4409 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: making change of tool-bar entry persistent
  2010-05-25 22:53   ` Stefan Vollmar
@ 2010-05-26 12:37     ` Joel J. Adamson
  2010-05-26 19:35       ` Stefan Vollmar
  0 siblings, 1 reply; 5+ messages in thread
From: Joel J. Adamson @ 2010-05-26 12:37 UTC (permalink / raw)
  To: Stefan Vollmar; +Cc: help-gnu-emacs, Kevin Rodgers

[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]

Stefan Vollmar <vollmar@nf.mpg.de> wrote:

> Dear Kevin,
> 
> On 25.05.2010, at 08:23, Kevin Rodgers wrote:
> 
> > Stefan Vollmar wrote:
> >> Hallo,
> >> I want to re-define what happends when an exising toolbar icon is
> >> pressed. In the Emacs documentation I found an example similar to
> >> this:
> >> (define-key   global-map   [tool-bar new-file]
> >>  '(menu-item "New Buffer" my-new-buffer
> >> 			  :image (image :type xpm :file "new.xpm")))
> > > Executing this code in Emacs 23.2 this will indeed show the desired
> > > effect - but only for about 2 seconds: the tool-bar is then
> > > automatically redrawn and behaves as before. How can I modify an
> > > existing toolbar so that the change is persistent?
> > 
> > -- Variable: tool-bar-map
> >     By default, the global map binds `[tool-bar]' as follows:
> >          (global-set-key [tool-bar]
> >          		'(menu-item "tool bar" ignore
> >          			    :filter (lambda (ignore) tool-bar-map)))
> >     Thus the tool bar map is derived dynamically from the value of
> >     variable `tool-bar-map' and you should normally adjust the default
> >     (global) tool bar by changing that map.  Major modes may replace
> >     the global bar completely by making `tool-bar-map' buffer-local
> >     and set to a keymap containing only the desired items.  Info mode
> >     provides an example.
> 
> 
> I looked up how changing the toolbar is done in info.el and was able
> to solve my problem with this code:

I was able to get my "Make Button" working with this --- the only
question is how to get it into the spot I want it: right before the Help
button.

Can anybody direct me to the documentation for this?

Thanks,

Joel

-- 
Joel J. Adamson
Servedio Lab
University of North Carolina at Chapel Hill

FSF Member #8164
http://www.unc.edu/~adamsonj

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: making change of tool-bar entry persistent
  2010-05-26 12:37     ` Joel J. Adamson
@ 2010-05-26 19:35       ` Stefan Vollmar
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Vollmar @ 2010-05-26 19:35 UTC (permalink / raw)
  To: Joel J. Adamson; +Cc: help-gnu-emacs, Kevin Rodgers

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

Dear Joel,

On 26.05.2010, at 14:37, Joel J. Adamson wrote:
[...]

> I was able to get my "Make Button" working with this --- the only
> question is how to get it into the spot I want it: right before the Help
> button.
> 
> Can anybody direct me to the documentation for this?



C-h k yields <tool-bar> <customize> for the button ("customize") just left to Help. 

With define-key-after, you can now insert your new toolbar entry between [customize] and [help] like this

(defvar my-tool-bar-map tool-bar-map)
(define-key-after my-tool-bar-map [my-new-tool-id]
  '(menu-item "My New Tool" my-new-tool-function
   :image (image :type xpm :file "my-new-tool-icon.xpm"))
  'customize)
(set (make-local-variable 'tool-bar-map) my-tool-bar-map)

This seems to work fine in Aquamacs 2.a (Mac) and with Emacs 23.2 on Windows.

Warm regards,
 Stefan
-- 
Dr. Stefan Vollmar, Dipl.-Phys.
Head of IT group
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213  FAX +49-221-4726-298
Tel.: +49-221-478-5713  Mobile: 0160-93874279
Email: vollmar@nf.mpg.de   http://www.nf.mpg.de







[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4409 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-26 19:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-23 14:11 making change of tool-bar entry persistent Stefan Vollmar
2010-05-25  6:23 ` Kevin Rodgers
2010-05-25 22:53   ` Stefan Vollmar
2010-05-26 12:37     ` Joel J. Adamson
2010-05-26 19:35       ` Stefan Vollmar

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.