From 9c474129819333d0e3f92a08cd48930d2e652dc0 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 21 May 2014 17:48:29 +0200 Subject: [PATCH] org-table.el (org-table-copy-down): Fix copying from a blank field * org-table.el (org-table-copy-down): Fix copying from a blank field. Thanks to Michael Brand for reporting this. --- lisp/org-table.el | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 0d01cfa71..afe6e3a39 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1135,8 +1135,7 @@ to a number. In the case of a timestamp, increment by days." (orig-n n) txt txt-up inc) (org-table-check-inside-data-field) - (if non-empty - (setq txt (org-trim field)) + (if (not non-empty) (save-excursion (setq txt (catch 'exit @@ -1147,11 +1146,23 @@ to a number. In the case of a timestamp, increment by days." (if (and (looking-at "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|") (<= (setq n (1- n)) 0)) - (throw 'exit (match-string 1)))))))) - (if non-empty-up (setq txt-up (org-trim field-up))) - (when txt + (throw 'exit (match-string 1)))))) + (setq field-up + (catch 'exit + (while (progn (beginning-of-line 1) + (re-search-backward org-table-dataline-regexp + beg t)) + (org-table-goto-column colpos t) + (if (and (looking-at + "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|") + (<= (setq n (1- n)) 0)) + (throw 'exit (match-string 1)))))) + (setq non-empty-up (string-match "[^ \t]" field-up))) + ;; Above field was not empty, go down to the next row + (setq txt (org-trim field)) (org-table-next-row) (org-table-blank-field)) + (if non-empty-up (setq txt-up (org-trim field-up))) (setq inc (cond ((numberp org-table-copy-increment) org-table-copy-increment) (txt-up (cond ((and (string-match org-ts-regexp3 txt-up) -- 2.11.4.GIT