]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-table.el
Merge from emacs-24 branch
[gnu-emacs] / lisp / org / org-table.el
index df93a9a72714267e6a54aa67e2c85de89284c50a..08981b57e498762183c6f2978d7086205e9b47c8 100644 (file)
@@ -50,7 +50,7 @@
 (defvar orgtbl-after-send-table-hook nil
   "Hook for functions attaching to `C-c C-c', if the table is sent.
 This can be used to add additional functionality after the table is sent
-to the receiver position, othewise, if table is not sent, the functions
+to the receiver position, otherwise, if table is not sent, the functions
 are not run.")
 
 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
@@ -169,11 +169,13 @@ window configuration, it is not recommended to set this variable to nil,
 except maybe locally in a special file that has mostly tables with long
 fields."
   :group 'org-table
+  :version "24.1"
   :type 'boolean)
 
 (defcustom org-table-fix-formulas-confirm nil
   "Whether the user should confirm when Org fixes formulas."
   :group 'org-table-editing
+  :version "24.1"
   :type '(choice
          (const :tag "with yes-or-no" yes-or-no-p)
          (const :tag "with y-or-n" y-or-n-p)
@@ -236,6 +238,7 @@ number of hours.  Other allowed values are 'seconds, 'minutes and
 'days, and the output will be a fraction of seconds, minutes or
 days."
   :group 'org-table-calculation
+  :version "24.1"
   :type '(choice (symbol :tag "Seconds" 'seconds)
                 (symbol :tag "Minutes" 'minutes)
                 (symbol :tag "Hours  " 'hours)
@@ -247,6 +250,7 @@ For example, using \"~%s~\" will display the result within tilde
 characters.  Beware that modifying the display can prevent the
 field from being used in another formula."
   :group 'org-table-settings
+  :version "24.1"
   :type 'string)
 
 (defcustom org-table-formula-evaluate-inline t
@@ -1299,7 +1303,7 @@ However, when FORCE is non-nil, create new columns if necessary."
 (defun org-table-line-to-dline (line &optional above)
   "Turn a buffer line number into a data line number.
 If there is no data line in this line, return nil.
-If there is no matchin dline (most likely te refrence was a hline), the
+If there is no matching dline (most likely te reference was a hline), the
 first dline below it is used.  When ABOVE is non-nil, the one above is used."
   (catch 'exit
     (let ((ll (length org-table-dlines))
@@ -2364,7 +2368,7 @@ of the new mark."
                       (looking-at org-table-auto-recalculate-regexp))
        (org-table-recalculate) t))
 
-(defvar modes)
+(defvar org-table-modes)
 (defsubst org-set-calc-mode (var &optional value)
   (if (stringp var)
       (setq var (assoc var '(("D" calc-angle-mode deg)
@@ -2372,10 +2376,10 @@ of the new mark."
                             ("F" calc-prefer-frac t)
                             ("S" calc-symbolic-mode t)))
            value (nth 2 var) var (nth 1 var)))
-  (if (memq var modes)
-      (setcar (cdr (memq var modes)) value)
-    (cons var (cons value modes)))
-  modes)
+  (if (memq var org-table-modes)
+      (setcar (cdr (memq var org-table-modes)) value)
+    (cons var (cons value org-table-modes)))
+  org-table-modes)
 
 (defun org-table-eval-formula (&optional arg equation
                                         suppress-align suppress-const
@@ -2522,8 +2526,13 @@ not overwrite the stored one."
                (replace-match
                 (save-match-data
                   (org-table-make-reference
-                   (org-table-get-remote-range
-                    (match-string 1 form) (match-string 2 form))
+                   (let ((rmtrng (org-table-get-remote-range
+                                  (match-string 1 form) (match-string 2 form))))
+                     (if duration
+                         (if (listp rmtrng)
+                             (mapcar (lambda(x) (org-table-time-string-to-seconds x)) rmtrng)
+                           (org-table-time-string-to-seconds rmtrng))
+                       rmtrng))
                    keep-empty numbers lispp))
                 t t form)))
        ;; Insert complex ranges
@@ -2659,8 +2668,8 @@ in the buffer and column1 and column2 are table column numbers."
 ;      (setq r2 (or r2 r1) c2 (or c2 c1))
       (if (not r1) (setq r1 thisline))
       (if (not r2) (setq r2 thisline))
-      (if (not c1) (setq c1 col))
-      (if (not c2) (setq c2 col))
+      (if (or (not c1) (= 0 c1)) (setq c1 col))
+      (if (or (not c2) (= 0 c2)) (setq c2 col))
       (if (and (not corners-only)
               (or (not rangep) (and (= r1 r2) (= c1 c2))))
          ;; just one field
@@ -2671,7 +2680,7 @@ in the buffer and column1 and column2 are table column numbers."
            (prog1 (org-trim (org-table-get-field c1))
              (if highlight (org-table-highlight-rectangle (point) (point)))))
        ;; A range, return a vector
-       ;; First sort the numbers to get a regular ractangle
+       ;; First sort the numbers to get a regular rectangle
        (if (< r2 r1) (setq tmp r1 r1 r2 r2 tmp))
        (if (< c2 c1) (setq tmp c1 c1 c2 c2 tmp))
        (if corners-only
@@ -2931,7 +2940,7 @@ known that the table will be realigned a little later anyway."
 
 (defun org-table-iterate (&optional arg)
   "Recalculate the table until it does not change anymore.
-The maximun number of iterations is 10, but you can chose a different value
+The maximum number of iterations is 10, but you can choose a different value
 with the prefix ARG."
   (interactive "P")
   (let ((imax (if arg (prefix-numeric-value arg) 10))
@@ -4154,7 +4163,7 @@ overwritten, and the table is not marked as requiring realignment."
           (looking-at "[^|\n]*  +|"))
       (let (org-table-may-need-update)
        (goto-char (1- (match-end 0)))
-       (delete-char -1)
+       (backward-delete-char 1)
        (goto-char (match-beginning 0))
        (self-insert-command N))
     (setq org-table-may-need-update t)