emacs中的工具栏按钮是如何工作的?

emacs中的工具栏按钮是如何工作的?,emacs,elisp,emacs24,dot-emacs,Emacs,Elisp,Emacs24,Dot Emacs,我在emacs中添加工具栏按钮时遇到问题。 我可以使用eval buffer运行它,但不能使用.emacs。当我用eval buffer添加它时,我的按钮会在滚动后离开我的工具栏 ;;; Code: (defun omar-hotel () "another nonce menu function" (interactive) (message "hotel, motel, holiday inn")) (define-key-after global-map [tool-b

我在emacs中添加工具栏按钮时遇到问题。 我可以使用eval buffer运行它,但不能使用.emacs。当我用eval buffer添加它时,我的按钮会在滚动后离开我的工具栏

;;; Code: 
(defun omar-hotel ()
  "another nonce menu function"
  (interactive)
  (message "hotel, motel, holiday inn"))


 (define-key-after global-map [tool-bar omar-button]
          '(menu-item "Hotel" omar-hotel
              :image (image :type xpm :file "/usr/share/emacs/23.4/etc/images/jump-to.xpm")
              :help "OMG Omar!"
              ))
我也试着添加这样的钩子,但这不起作用

(add-hook 'after-init-hook
      (lambda ()
        (define-key-after global-map [tool-bar omar-button]
          '(menu-item "Hotel" omar-hotel
              :image (image :type xpm :file "/usr/share/emacs/23.4/etc/images/jump-to.xpm")
              :help "OMG Omar!"
              ))
))

您好,我发现了一个添加工具栏按钮拼写的简单解决方案是/usr/share/emacs/23.4/etc/images中的图像/

(defun omar-hotel ()
 "another nonce menu function"
 (interactive)
 (message "hotel, motel, holiday inn"))

(tool-bar-add-item "spell" 'omar-hotel
           'omar-hotel
           :help   "Run fonction omar-hotel")