org-table.el: Rename a variable and a function

* org-table.el (org-table-TBLFM-begin-regexp): Rename from
`org-TBLFM-begin-regexp'.
(org-table-calc-current-TBLFM): Rename from
`org-calc-current-TBLFM'.

* org.el (org-ctrl-c-ctrl-c): Require org-table if needed.
This commit is contained in:
Bastien Guerry 2013-05-15 16:18:37 +02:00
parent f371e5da0d
commit 0c31a4fcb6
2 changed files with 9 additions and 11 deletions

View File

@ -52,7 +52,7 @@ This can be used to add additional functionality after the table is sent
to the receiver position, otherwise, if table is not sent, the functions to the receiver position, otherwise, if table is not sent, the functions
are not run.") are not run.")
(defvar org-TBLFM-begin-regexp "|\n[ \t]*#\\+TBLFM: ") (defvar org-table-TBLFM-begin-regexp "|\n[ \t]*#\\+TBLFM: ")
(defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
"Non-nil means use the optimized table editor version for `orgtbl-mode'. "Non-nil means use the optimized table editor version for `orgtbl-mode'.
@ -3174,8 +3174,8 @@ with the prefix ARG."
(setq checksum c1))) (setq checksum c1)))
(user-error "No convergence after %d iterations" imax)))))) (user-error "No convergence after %d iterations" imax))))))
(defun org-calc-current-TBLFM (&optional arg) (defun org-table-calc-current-TBLFM (&optional arg)
"Apply the #+TBLFM in the line to the table." "Apply the #+TBLFM in the line at point to the table."
(interactive "P") (interactive "P")
(unless (org-at-TBLFM-p) (user-error "Not at a #+TBLFM line")) (unless (org-at-TBLFM-p) (user-error "Not at a #+TBLFM line"))
(let ((formula (buffer-substring (let ((formula (buffer-substring
@ -3184,33 +3184,29 @@ with the prefix ARG."
s e) s e)
(save-excursion (save-excursion
;; Insert a temporary formula at right after the table ;; Insert a temporary formula at right after the table
(goto-char (org-TBLFM-begin)) (goto-char (org-table-TBLFM-begin))
(setq s (set-marker (make-marker) (point))) (setq s (set-marker (make-marker) (point)))
(insert (concat formula "\n")) (insert (concat formula "\n"))
(setq e (set-marker (make-marker) (point))) (setq e (set-marker (make-marker) (point)))
;; Recalculate the table ;; Recalculate the table
(beginning-of-line 0) ; move to the inserted line (beginning-of-line 0) ; move to the inserted line
(skip-chars-backward " \r\n\t") (skip-chars-backward " \r\n\t")
(if (org-at-table-p) (if (org-at-table-p)
(unwind-protect (unwind-protect
(org-call-with-arg 'org-table-recalculate (or arg t)) (org-call-with-arg 'org-table-recalculate (or arg t))
;; delete the formula inserted temporarily ;; delete the formula inserted temporarily
(delete-region s e)))))) (delete-region s e))))))
(defun org-TBLFM-begin () (defun org-table-TBLFM-begin ()
"Find the beginning of the TBLFM lines and return its position. "Find the beginning of the TBLFM lines and return its position.
Return nil when the beginning of TBLFM line was not found." Return nil when the beginning of TBLFM line was not found."
(save-excursion (save-excursion
(when (progn (forward-line 1) (when (progn (forward-line 1)
(re-search-backward (re-search-backward
org-TBLFM-begin-regexp org-table-TBLFM-begin-regexp
nil t)) nil t))
(point-at-bol 2)))) (point-at-bol 2))))
(defun org-table-expand-lhs-ranges (equations) (defun org-table-expand-lhs-ranges (equations)
"Expand list of formulas. "Expand list of formulas.
If some of the RHS in the formulas are ranges or a row reference, expand If some of the RHS in the formulas are ranges or a row reference, expand

View File

@ -20240,7 +20240,9 @@ This command does many different things, depending on context:
(and (eq type 'table-row) (and (eq type 'table-row)
(= (point) (org-element-property :end context)))) (= (point) (org-element-property :end context))))
(save-excursion (save-excursion
(if (org-at-TBLFM-p) (org-calc-current-TBLFM) (if (org-at-TBLFM-p)
(progn (require 'org-table)
(org-table-calc-current-TBLFM))
(goto-char (org-element-property :contents-begin context)) (goto-char (org-element-property :contents-begin context))
(org-call-with-arg 'org-table-recalculate (or arg t)) (org-call-with-arg 'org-table-recalculate (or arg t))
(orgtbl-send-table 'maybe))) (orgtbl-send-table 'maybe)))