如何在emacs中添加工具栏按钮?

如何在emacs中添加工具栏按钮?,emacs,elisp,toolbar,emacs24,dot-emacs,Emacs,Elisp,Toolbar,Emacs24,Dot Emacs,我试图在工具栏中添加一个按钮,但这不起作用。 如何做到这一点,我在EmacsWiki上查了一下,什么也没找到。 我使用了Emacs24.3.1。 将显示toolsbar,但不显示我的新项目 我可以使用eval buffer运行它,但不能使用my.emacs或找到其他解决方案来解决这个问题。 当我用eval buffer添加它时,我的按钮会在滚动后离开我的工具栏 (defun omar-hotel () "another nonce menu function" (interactive)

我试图在工具栏中添加一个按钮,但这不起作用。 如何做到这一点,我在EmacsWiki上查了一下,什么也没找到。 我使用了Emacs24.3.1。 将显示toolsbar,但不显示我的新项目


我可以使用eval buffer运行它,但不能使用my.emacs或找到其他解决方案来解决这个问题。 当我用eval buffer添加它时,我的按钮会在滚动后离开我的工具栏

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

(define-key global-map [tool-bar omar-button]
'(menu-item "Hotel" omar-hotel
   :image (image :type xpm :file "/usr/share/emacs/24.3/etc/images/jump-to.xpm")
   )
)

您的代码可以工作,但需要在工具栏激活后执行它

如果您像这样将代码添加到.emacs,您的问题应该消失了:

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

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

尝试将菜单项中的
omar hotel
更改为
[omar hotel]
。在从init文件调用此代码之前,请确保启用了
工具栏模式
。但我试着和你看到的是一样的东西:它在评估时有效,而不是从
.emacs
中。试着在菜单项中将omar hotel更改为[omar hotel]。那不行。我在我的.emacs中添加了你的代码。我在定义函数后检查是否有错误,但与工具栏没有任何关系。