comparison lisp/textmodes/org.el @ 64518:7b82147924c7

(org-table-formula-substitute-names, org-table-get-vertical-vector): Doc fixes. (org-table-recalculate): Remove unused argument to `message'.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 19 Jul 2005 23:37:03 +0000
parents 3f75dfc753c0
children 5b1a238fcbb4 187d6a1f84f7
comparison
equal deleted inserted replaced
64517:098497d516e8 64518:7b82147924c7
6994 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0))))) 6994 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0)))))
6995 ((equal n 0) nil) 6995 ((equal n 0) nil)
6996 (t n)))) 6996 (t n))))
6997 6997
6998 (defun org-table-get-vertical-vector (desc &optional tbeg col) 6998 (defun org-table-get-vertical-vector (desc &optional tbeg col)
6999 "Get a calc vector from a column, accorting to desctiptor 6999 "Get a calc vector from a column, according to descriptor DESC.
7000 Optional arguments TBEG and COL can give the beginning of the table and 7000 Optional arguments TBEG and COL can give the beginning of the table
7001 the current column, to avoid unnecessary parsing." 7001 and the current column, to avoid unnecessary parsing."
7002 (save-excursion 7002 (save-excursion
7003 (or tbeg (setq tbeg (org-table-begin))) 7003 (or tbeg (setq tbeg (org-table-begin)))
7004 (or col (setq col (org-table-current-column))) 7004 (or col (setq col (org-table-current-column)))
7005 (let (beg end nn n n1 n2 l (thisline (org-current-line)) hline-list) 7005 (let (beg end nn n n1 n2 l (thisline (org-current-line)) hline-list)
7006 (cond 7006 (cond
7044 (lambda (x) (setq x (org-trim x)) 7044 (lambda (x) (setq x (org-trim x))
7045 (if (equal x "") "0" x)) 7045 (if (equal x "") "0" x))
7046 l ",") "]")) 7046 l ",") "]"))
7047 ((string-match "\\([0-9]+\\)" desc) 7047 ((string-match "\\([0-9]+\\)" desc)
7048 (beginning-of-line 1) 7048 (beginning-of-line 1)
7049 (when (re-search-backward org-table-dataline-regexp tbeg t 7049 (when (re-search-backward org-table-dataline-regexp tbeg t
7050 (string-to-number (match-string 0 desc))) 7050 (string-to-number (match-string 0 desc)))
7051 (org-table-goto-column col) 7051 (org-table-goto-column col)
7052 (org-trim (org-table-get-field)))))))) 7052 (org-trim (org-table-get-field))))))))
7053 7053
7054 (defvar org-table-formula-history nil) 7054 (defvar org-table-formula-history nil)
7140 (defun org-table-modify-formulas (action &rest columns) 7140 (defun org-table-modify-formulas (action &rest columns)
7141 "Modify the formulas stored below the current table. 7141 "Modify the formulas stored below the current table.
7142 ACTION can be `remove', `insert', `swap'. For `swap', two column numbers are 7142 ACTION can be `remove', `insert', `swap'. For `swap', two column numbers are
7143 expected, for the other action only a single column number is needed." 7143 expected, for the other action only a single column number is needed."
7144 (let ((list (org-table-get-stored-formulas)) 7144 (let ((list (org-table-get-stored-formulas))
7145 (nmax (length (org-split-string 7145 (nmax (length (org-split-string
7146 (buffer-substring (point-at-bol) (point-at-eol)) 7146 (buffer-substring (point-at-bol) (point-at-eol))
7147 "|"))) 7147 "|")))
7148 col col1 col2 scol si sc1 sc2) 7148 col col1 col2 scol si sc1 sc2)
7149 (cond 7149 (cond
7150 ((null list)) ; No action needed if there are no stored formulas 7150 ((null list)) ; No action needed if there are no stored formulas
7219 (while (re-search-forward "^[ \t]*| *\\([_^]\\) *\\(|.*\\)" end t) 7219 (while (re-search-forward "^[ \t]*| *\\([_^]\\) *\\(|.*\\)" end t)
7220 (setq c (match-string 1) 7220 (setq c (match-string 1)
7221 fields (org-split-string (match-string 2) " *| *")) 7221 fields (org-split-string (match-string 2) " *| *"))
7222 (save-excursion 7222 (save-excursion
7223 (beginning-of-line (if (equal c "_") 2 0)) 7223 (beginning-of-line (if (equal c "_") 2 0))
7224 (setq line (org-current-line) col 1) 7224 (setq line (org-current-line) col 1)
7225 (and (looking-at "^[ \t]*|[^|]*\\(|.*\\)") 7225 (and (looking-at "^[ \t]*|[^|]*\\(|.*\\)")
7226 (setq fields1 (org-split-string (match-string 1) " *| *")))) 7226 (setq fields1 (org-split-string (match-string 1) " *| *"))))
7227 (while (and fields1 (setq field (pop fields))) 7227 (while (and fields1 (setq field (pop fields)))
7228 (setq v (pop fields1) col (1+ col)) 7228 (setq v (pop fields1) col (1+ col))
7229 (when (and (stringp field) (stringp v) 7229 (when (and (stringp field) (stringp v)
7555 (org-table-eval-formula nil (cdr eq) 'noalign 'nocst 'nostore))) 7555 (org-table-eval-formula nil (cdr eq) 'noalign 'nocst 'nostore)))
7556 ;; back to initial position 7556 ;; back to initial position
7557 (goto-line thisline) 7557 (goto-line thisline)
7558 (org-table-goto-column thiscol) 7558 (org-table-goto-column thiscol)
7559 (or noalign (and org-table-may-need-update (org-table-align)) 7559 (or noalign (and org-table-may-need-update (org-table-align))
7560 (and all (message "Re-applying formulas...done" cnt))))) 7560 (and all (message "Re-applying formulas...done")))))
7561 7561
7562 (defun org-table-formula-substitute-names (f) 7562 (defun org-table-formula-substitute-names (f)
7563 "Replace $const with values in stirng F." 7563 "Replace $const with values in string F."
7564 (let ((start 0) a n1 n2 nn1 nn2 s (f1 f)) 7564 (let ((start 0) a n1 n2 nn1 nn2 s (f1 f))
7565 ;; First, check for column names 7565 ;; First, check for column names
7566 (while (setq start (string-match org-table-column-name-regexp f start)) 7566 (while (setq start (string-match org-table-column-name-regexp f start))
7567 (setq start (1+ start)) 7567 (setq start (1+ start))
7568 (setq a (assoc (match-string 1 f) org-table-column-names)) 7568 (setq a (assoc (match-string 1 f) org-table-column-names))
7619 (erase-buffer) 7619 (erase-buffer)
7620 (fundamental-mode) 7620 (fundamental-mode)
7621 (set (make-local-variable 'org-pos) pos) 7621 (set (make-local-variable 'org-pos) pos)
7622 (set (make-local-variable 'org-window-configuration) wc) 7622 (set (make-local-variable 'org-window-configuration) wc)
7623 (use-local-map org-edit-formulas-map) 7623 (use-local-map org-edit-formulas-map)
7624 (setq s "# Edit formulas and finish with `C-c C-c'. 7624 (setq s "# Edit formulas and finish with `C-c C-c'.
7625 # Use `C-u C-c C-c' to also appy them immediately to the entire table. 7625 # Use `C-u C-c C-c' to also appy them immediately to the entire table.
7626 # Use `C-c ?' to get information about $name at point. 7626 # Use `C-c ?' to get information about $name at point.
7627 # To cancel editing, press `C-c C-q'.\n") 7627 # To cancel editing, press `C-c C-q'.\n")
7628 (put-text-property 0 (length s) 'face 'font-lock-comment-face s) 7628 (put-text-property 0 (length s) 'face 'font-lock-comment-face s)
7629 (insert s) 7629 (insert s)
7657 (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e))) 7657 (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e)))
7658 ((setq e (assoc var org-table-column-names)) 7658 ((setq e (assoc var org-table-column-names))
7659 (switch-to-buffer-other-window (marker-buffer pos)) 7659 (switch-to-buffer-other-window (marker-buffer pos))
7660 (goto-char pos) 7660 (goto-char pos)
7661 (goto-char (org-table-begin)) 7661 (goto-char (org-table-begin))
7662 (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|") 7662 (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|")
7663 (org-table-end) t) 7663 (org-table-end) t)
7664 (progn 7664 (progn
7665 (goto-char (match-beginning 1)) 7665 (goto-char (match-beginning 1))
7666 (message "Named column (column %s)" (cdr e))) 7666 (message "Named column (column %s)" (cdr e)))
7667 (error "Column name not found")) 7667 (error "Column name not found"))
7712 (unless (org-at-table-p) 7712 (unless (org-at-table-p)
7713 (error "Lost table position - cannot install formulae")) 7713 (error "Lost table position - cannot install formulae"))
7714 (org-table-store-formulas eql) 7714 (org-table-store-formulas eql)
7715 (move-marker pos nil) 7715 (move-marker pos nil)
7716 (kill-buffer "*Edit Formulas*") 7716 (kill-buffer "*Edit Formulas*")
7717 (if arg 7717 (if arg
7718 (org-table-recalculate 'all) 7718 (org-table-recalculate 'all)
7719 (message "New formulas installed - press C-u C-c C-c to apply.")))) 7719 (message "New formulas installed - press C-u C-c C-c to apply."))))
7720 7720
7721 (defun org-abort-edit-formulas () 7721 (defun org-abort-edit-formulas ()
7722 "Abort editing formulas, without installing the changes." 7722 "Abort editing formulas, without installing the changes."