Function: org-table-move-row

org-table-move-row is an autoloaded, interactive and byte-compiled function defined in org-table.el.gz.

Signature

(org-table-move-row &optional UP)

Documentation

Move the current table line down. With arg UP, move it up.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table-move-row (&optional up)
  "Move the current table line down.  With arg UP, move it up."
  (interactive "P")
  (let* ((col (current-column))
	 (pos (point))
	 (hline1p (save-excursion (forward-line 0)
				  (looking-at org-table-hline-regexp)))
	 (dline1 (org-table-current-dline))
	 (dline2 (+ dline1 (if up -1 1)))
	 (tonew (if up -1 1))
	 hline2p)
    (when (and up (= (point-min) (line-beginning-position)))
      (user-error "Cannot move row further"))
    (forward-line tonew)
    (when (or (and (not up) (eobp)) (not (org-at-table-p)))
      (goto-char pos)
      (user-error "Cannot move row further"))
    (org-table-with-shrunk-columns
     (setq hline2p (looking-at org-table-hline-regexp))
     (goto-char pos)
     (let ((row (delete-and-extract-region (line-beginning-position)
					   (line-beginning-position 2))))
       (forward-line tonew)
       (unless (bolp) (insert "\n"))	;at eob without a newline
       (insert row)
       (unless (bolp) (insert "\n"))	;missing final newline in ROW
       (forward-line -1)
       (org-move-to-column col)
       (unless (or hline1p hline2p
		   (not (or (not org-table-fix-formulas-confirm)
			  (funcall org-table-fix-formulas-confirm
				   "Fix formulas? "))))
	 (org-table-fix-formulas
	  "@" (list
	       (cons (number-to-string dline1) (number-to-string dline2))
	       (cons (number-to-string dline2) (number-to-string dline1)))))))))