Quellcode durchsuchen

Protect increment-by-copying in tables.

Carsten Dominik vor 16 Jahren
Ursprung
Commit
e862a5cd58
4 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen
  1. 2 0
      ORGWEBPAGE/Changes.org
  2. 6 6
      doc/org.texi
  3. 6 0
      lisp/ChangeLog
  4. 5 2
      lisp/org-table.el

+ 2 - 0
ORGWEBPAGE/Changes.org

@@ -32,6 +32,8 @@
 
 ** 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
     If you attach formulas and plotting instructions to a table
     capturing column view, these extra lines will now survive an

+ 6 - 6
doc/org.texi

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

+ 6 - 0
lisp/ChangeLog

@@ -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>
 
 	* org-exp.el (org-export-as-html): Do not turn on the major mode

+ 5 - 2
lisp/org-table.el

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