I have been trying to add a "Save as" button to the org mode toolbar.

Using the example from: https://stackoverflow.com/questions/20917411/how-to-add-item-to-toolbar-in-emacs#28326863

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

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

I looked at the manual at https://www.gnu.org/software/emacs/manual/html_node/elisp/Tool-Bar.html but do not understand it enough.

I have been able to show the "Save as" button in the toolbar but I do not understand the other parts of the code enough to be able to actually run the "Save as" command if this button is clicked.

I have tried to search for this and have not found any helpful examples.

Any help is appreciated.

2 Answers 2


If you want to add Menu Bar -> File -> Save As (which is bound to C-x C-w) to Tool Bar then do

(tool-bar-add-item-from-menu 'write-file "save" nil
                 :label "Save As")
  • Thank you so much for that answer :) It works exactly like I want. I tried and tried to figure this out myself, before posting, but I find it very hard to find any docs on commands, syntax, etc, so you have been very helpful.
    – ironfish
    Commented Jun 25, 2022 at 19:05
  • I understand each part of your answer except for the 'nil' - could you explain why that is there?
    – ironfish
    Commented Jun 26, 2022 at 2:59
  • I made one minor change from using "save" to using "saveas" which shows the "Save as" icon.
    – ironfish
    Commented Jun 26, 2022 at 3:01

To get this

Save as ... toolbar icons

do this

* How to add custom "Save As HTML" or "Save as ASCII" buttons to Toolbar

With cursor inside the below source block, do a =C-c C-c=.  You will
get clickable tool bar buttons when in an ~org-mode~ buffer.

#+begin_src emacs-lisp :results silent
  (tool-bar-add-item "saveas"
             :help "Save as HTML"
             :enable '(derived-mode-p 'org-mode))

  (tool-bar-add-item "saveas"
             :help "Save as ASCII"
             :enable '(derived-mode-p 'org-mode))  
  • Thanks very much for your input
    – ironfish
    Commented Jun 25, 2022 at 12:32
  • Looking up org-ascii-export-to-ascii the manual says this removes Org markup and I am not sure if this is what I would want since I want to save as the original org mode file
    – ironfish
    Commented Jun 25, 2022 at 12:34
  • I would like to be able to do the same command as File > Save as, and I am also not sure why an export to ascii would be needed before saving. Could you explain?
    – ironfish
    Commented Jun 25, 2022 at 12:37
  • I never knew that write-file is called as File -> Save as. I have added another answer.
    – user31220
    Commented Jun 25, 2022 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.