I performed several google searches on the internet to find a solution for tool-bar item. I tried this code without resulting. Nothing happens. I also tried with Emacs default interface (the same of the newly installed program). The results were the same when I used my settings.

Below is the code that does not work even with the Emacs default settings.

(add-hook 'after-init-hook
          (lambda ()
            (define-key global-map [tool-bar hilite-button]
              '(menu-item "hilite" my-hilite-fun
                          :image (image :type xpm 
                                        :file "/home/alexandre/emacs-lisp-macros/shell.xpm")))))
(tool-bar-add-item "hilite" 'my-hilite-fun
                   :help "my hilite function")

Then I discarded this text and used the model below. This .emacs code section works well. The icon appears on the toolbar and works properly.

(define-key-after global-map [tool-bar hilite-button]
  '(menu-item "eval" akx-highlight-emacs-lisp
              :image (image :type xpm :file "/home/alexandre/emacs-lisp-macros/shell.xpm")
              :enable 1
              :help "akx-highlight-emacs-lisp"))

However, the icon disappears during the edition of the document, or even after a buffer change.

To get it back it's necessary M-x eval-buffer .emacs, and this unwanted behavior occurs as before.

When closing the session and restarting it, the icon no longer appears in the toolbar. And I need to reload the .emacs buffer.

I have several questions here and in no one have found a solution. How to make the icons not disappear and stay saved for future sessions?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.