I am using Emacs's table.el mode to fill a lot of tables in rst documents. table.el is really fine to do the job, but it lacks the possibility to have one space between vertical separator and cell content.

That is, by default, it fills tables like this:


What I want to achieve is to have a one space padding before and after each separator to match the RST syntax like this :

| content | stuff |
  • 2
    You could switch to using orgtbl-mode, which (according to its docstring) gives you "The org-mode table editor as a minor mode for use in other modes". – itsjeyd Oct 17 '14 at 11:46

Perhaps the easiest way is to convert table to org-mode's table, and then convert it back. Here's the code:

(require 'org)

(setq save-y-or-n-p nil)

(defadvice table-re-indent (around always-yes)
  (fset 'save-y-or-n-p (symbol-function 'y-or-n-p))
  (fset 'y-or-n-p (lambda (s) t))
  (fset 'y-or-n-p (symbol-function 'save-y-or-n-p)))

(defun table-re-indent ()
  "Put the point in the table and call this function"

To use it put the point in the table and call M-x table-re-indent.

  • 1
    You should use unwind-protect in your advice as to assure that y-or-n-p will always get set back to the original value. – Jordon Biondo Aug 5 '15 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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