Skip to content

Instantly share code, notes, and snippets.

@tonini
Created January 13, 2015 09:13
Show Gist options
  • Save tonini/d316120d5fb3fd760d02 to your computer and use it in GitHub Desktop.
Save tonini/d316120d5fb3fd760d02 to your computer and use it in GitHub Desktop.
(defun org-table-next-field ()
"Go to the next field in the current table, creating new lines as needed.
Before doing so, re-align the table if necessary."
(interactive)
(org-table-maybe-eval-formula)
(org-table-maybe-recalculate-line)
(if (and org-table-automatic-realign
org-table-may-need-update)
(org-table-align))
(let ((end (org-table-end)))
(if (org-at-table-hline-p)
(end-of-line 1))
(condition-case nil
(progn
(re-search-forward "|" end)
(if (looking-at "[ \t]*$")
(re-search-forward "|" end))
(if (and (looking-at "-")
org-table-tab-jumps-over-hlines
(re-search-forward "^[ \t]*|\\([^-]\\)" end t))
(goto-char (match-beginning 1)))
(if (looking-at "-")
(progn
(beginning-of-line 0)
(org-table-insert-row 'below))
(if (looking-at " ") (forward-char 1))))
(error
(org-table-insert-row 'below)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment