Protect increment-by-copying in tables.

This commit is contained in:
Carsten Dominik 2008-09-08 20:18:18 +02:00
parent ccb0755c75
commit e862a5cd58
4 changed files with 19 additions and 8 deletions

View File

@ -32,6 +32,8 @@
** Details ** Details
*** Prefix arg 0 to S-RET disabled integer increment during copy
This was a request by Chris Randle.
*** Column view capture tables can have formulas and plotting instructions *** Column view capture tables can have formulas and plotting instructions
If you attach formulas and plotting instructions to a table If you attach formulas and plotting instructions to a table
capturing column view, these extra lines will now survive an capturing column view, these extra lines will now survive an

View File

@ -1541,12 +1541,12 @@ be inserted with @kbd{C-y}.
@c @c
@kindex S-@key{RET} @kindex S-@key{RET}
@item S-@key{RET} @item S-@key{RET}
When current field is empty, copy from first non-empty field above. When current field is empty, copy from first non-empty field above. When not
When not empty, copy current field down to next row and move cursor empty, copy current field down to next row and move cursor along with it.
along with it. Depending on the variable Depending on the variable @code{org-table-copy-increment}, integer field
@code{org-table-copy-increment}, integer field values will be values will be incremented during copy. Integers that are too large will not
incremented during copy. This key is also used by CUA mode be incremented. Also, a @code{0} prefix argument temporarily dispables the
(@pxref{Cooperation}). increment. This key is also used by CUA mode (@pxref{Cooperation}).
@tsubheading{Miscellaneous} @tsubheading{Miscellaneous}
@kindex C-c ` @kindex C-c `

View File

@ -1,3 +1,9 @@
2008-09-08 Carsten Dominik <dominik@science.uva.nl>
* org-table.el (org-table-copy-down): Avoid overflow during
increment. Use prefix argument 0 to temporarily disable the
increment.
2008-09-07 Carsten Dominik <dominik@science.uva.nl> 2008-09-07 Carsten Dominik <dominik@science.uva.nl>
* org-exp.el (org-export-as-html): Do not turn on the major mode * org-exp.el (org-export-as-html): Do not turn on the major mode

View File

@ -865,6 +865,7 @@ in order to easily repeat the interval."
(field (org-table-get-field)) (field (org-table-get-field))
(non-empty (string-match "[^ \t]" field)) (non-empty (string-match "[^ \t]" field))
(beg (org-table-begin)) (beg (org-table-begin))
(orig-n n)
txt) txt)
(org-table-check-inside-data-field) (org-table-check-inside-data-field)
(if non-empty (if non-empty
@ -881,12 +882,14 @@ in order to easily repeat the interval."
(org-table-goto-column colpos t) (org-table-goto-column colpos t)
(if (and (looking-at (if (and (looking-at
"|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|") "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|")
(= (setq n (1- n)) 0)) (<= (setq n (1- n)) 0))
(throw 'exit (match-string 1)))))))) (throw 'exit (match-string 1))))))))
(if txt (if txt
(progn (progn
(if (and org-table-copy-increment (if (and org-table-copy-increment
(string-match "^[0-9]+$" txt)) (not (equal orig-n 0))
(string-match "^[0-9]+$" txt)
(< (string-to-number txt) 100000000))
(setq txt (format "%d" (+ (string-to-number txt) 1)))) (setq txt (format "%d" (+ (string-to-number txt) 1))))
(insert txt) (insert txt)
(org-move-to-column col) (org-move-to-column col)