Function: org-table-store-formulas

org-table-store-formulas is a byte-compiled function defined in org-table.el.gz.

Signature

(org-table-store-formulas ALIST &optional LOCATION)

Documentation

Store the list of formulas below the current table.

If optional argument LOCATION is a buffer position, insert it at LOCATION instead.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-store-formulas (alist &optional location)
  "Store the list of formulas below the current table.
If optional argument LOCATION is a buffer position, insert it at
LOCATION instead."
  (save-excursion
    (if location
	(progn (goto-char location) (beginning-of-line))
      (goto-char (org-table-end)))
    (let ((case-fold-search t))
      (if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+TBLFM:\\)\\(.*\n?\\)")
	  (progn
	    ;; Don't overwrite TBLFM, we might use text properties to
	    ;; store stuff.
	    (goto-char (match-beginning 3))
	    (delete-region (match-beginning 3) (match-end 0)))
	(org-indent-line)
	(insert "#+TBLFM:"))
      (insert " "
	      (mapconcat (lambda (x) (concat (car x) "=" (cdr x)))
			 (sort alist #'org-table-formula-less-p)
			 "::")
	      "\n"))))