6

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:

+-------+-----+
|content|stuff|
+-------+-----+

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 |
+---------+-------+
calve
  • 61
  • 2
  • 3
    You could switch to using `orgtbl-mode`, which (according to its [docstring](http://doc.endlessparentheses.com/Fun%2Forgtbl-mode.html)) gives you "The `org-mode` table editor as a minor mode for use in other modes". – itsjeyd Oct 17 '14 at 11:46

1 Answers1

0

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))
  ad-do-it
  (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"
  (interactive)
  (org-table-create-with-table.el)
  (org-table-create-with-table.el))

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

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
Adobe
  • 1,859
  • 13
  • 27
  • 2
    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 05 '15 at 15:59