summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-07-01 10:07:29 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-07-01 10:30:45 +0200
commit969daf41ac8a365c6ef82be2d6d0539b1cc6992b (patch)
treeb9feb2f0799907e691de1520c774ffc1325e2925
parent40e03973f3bfa0a010b943274918418e108a82bb (diff)
downloadorg-mode-969daf41ac8a365c6ef82be2d6d0539b1cc6992b.tar.gz
org-table: Fix `org-table-move-row-down' without final newline
* lisp/org-table.el (org-table-move-row): Fix `org-table-move-row-down' without final newline.
-rw-r--r--lisp/org-table.el33
1 files changed, 17 insertions, 16 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 4b7f604..8d15dd7 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1532,7 +1532,7 @@ non-nil, the one above is used."
(dline1 (org-table-current-dline))
(dline2 (+ dline1 (if up -1 1)))
(tonew (if up 0 2))
- txt hline2p)
+ hline2p)
(when (and up (= (point-min) (line-beginning-position)))
(user-error "Cannot move row further"))
(beginning-of-line tonew)
@@ -1541,21 +1541,22 @@ non-nil, the one above is used."
(user-error "Cannot move row further"))
(setq hline2p (looking-at org-table-hline-regexp))
(goto-char pos)
- (beginning-of-line 1)
- (setq pos (point))
- (setq txt (buffer-substring (point) (1+ (point-at-eol))))
- (delete-region (point) (1+ (point-at-eol)))
- (beginning-of-line tonew)
- (insert txt)
- (beginning-of-line 0)
- (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)))))))
+ (let ((row (delete-and-extract-region (line-beginning-position)
+ (line-beginning-position 2))))
+ (beginning-of-line tonew)
+ (unless (bolp) (insert "\n")) ;at eob without a newline
+ (insert row)
+ (unless (bolp) (insert "\n")) ;missing final newline in ROW
+ (beginning-of-line 0)
+ (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))))))))
;;;###autoload
(defun org-table-insert-row (&optional arg)