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

How tool-bar button in emacs works?

我在 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!"
              ))
))

您好,我找到了一个添加工具栏按钮的简单解决方案 "spell" 是 /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")