pandoc-mode
pandoc-mode copied to clipboard
Edit org-mode tables
I have implemented a couple of functions that allow using org-mode to edit tables. This is useful because pandoc supports this table format.
Example usage:
| Header 1 | Header 2|
With the cursor located after the last vertical line M-x edit-table. NowTAB your table away. When done editing press C-c e.
(defun edit-table ()
(interactive)
(clone-indirect-buffer nil t)
(let ((end (point))
(start (progn (mark-paragraph) (point))))
(narrow-to-region start end)
(goto-char end)
(insert-string "\n")
(add-hook 'org-mode-hook (lambda ()
(local-set-key (kbd "C-c e") 'restore-buffer)))
(org-mode)))
(defun restore-buffer ()
"Kills cloned buffer and restores fontification of base buffer"
(interactive)
(kill-buffer)
(delete-window)
(font-lock-fontify-buffer))
Note that org-mode also provides a minor mode orgtbl-mode which allows you to edit org-mode tables directly in your markdown-mode buffer (or any other text buffer).
Thank you! I did not know that. My intention with this issue is to let other pandoc-mode users know that editing tables is easy. The interaction between major modes is not always friendly and people are left wondering how to do it. Perhaps the docs should describe how to enable and use orgtbl-mode.