Edit document as other format, as long as your format is supported by Pandoc.
You love OrgMode, but have to use markdown sometimes, open your markdown file in
emacs, M-x edit-as-format-org, happy writing!
- Edit document as other format in a separate buffer, with changes commited back to original buffer
- Handle selected region or whole buffer
edit-as-format-orgedit current buffer as org documentedit-as-formatedit current buffer as other format, prompt for target format- supported formats
- default format list use intersection of
pandoc --list-input-formatsandpandoc --list-output-formats - however, not all that list is supported, especially non-textual formats
- basically, markup language formats will works OK
- it’s customizable
edit-as-format-formats
- default format list use intersection of
Prerequisite
- install Pandoc, make it accessible from
PATH
Use package from Melpa
(use-package edit-as-format
:ensure t
:bind ("C-c e e" . edit-as-format))Custom commands can be created easily with edit-as-format, examples:
(defun edit-org-as-markdown ()
(interactive)
(edit-as-format "org" "markdown"))
(defun edit-as-markdown ()
(interactive)
(edit-as-format nil "gfm")This package uses edit-indirect for editing, the key binding in
edit-indirect-mode-map resembles org-src-mode-map
- C-c ’ edit-indirect-commit
- C-c C-c edit-indirect-commit
- C-c C-k edit-indirect-abort
- C-x C-s edit-indirect-save
Bind key to edit-as-format edit-as-format-org for convenient access
(global-set-key (kbd "C-c e e") 'edit-as-format)
(global-set-key (kbd "C-c e o") 'edit-as-format-org)Optionally, unbind edit-indirect-commit, give [C-c ‘] back to
org-edit-special in org-mode
(unbind-key "C-c '" edit-indirect-mode-map)- org-pandoc-import gives a rather complete solution, it has many good features,
in contrast,
edit-as-formattakes a simpler way:pandoc + edit-indirect(and takes some code fromorg-pandoc-import, great thanks).
- markdown redundant spaces, maybe write pandoc filter ?
