Function: org-table-edit-formulas
org-table-edit-formulas is an autoloaded, interactive and
byte-compiled function defined in org-table.el.gz.
Signature
(org-table-edit-formulas)
Documentation
Edit the formulas of the current table in a separate buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table-edit-formulas ()
"Edit the formulas of the current table in a separate buffer."
(interactive)
(let ((at-tblfm (org-at-TBLFM-p)))
(unless (or at-tblfm (org-at-table-p))
(user-error "Not at a table"))
(save-excursion
;; Move point within the table before analyzing it.
(when at-tblfm (re-search-backward "^[ \t]*|"))
(org-table-analyze))
(let ((key (org-table-current-field-formula 'key 'noerror))
(eql (sort (org-table-get-stored-formulas t (and at-tblfm (point)))
#'org-table-formula-less-p))
(pos (point-marker))
(source (copy-marker (line-beginning-position)))
(startline 1)
(wc (current-window-configuration))
(sel-win (selected-window))
(titles '((column . "# Column Formulas\n")
(field . "# Field and Range Formulas\n")
(named . "# Named Field Formulas\n"))))
(let ((pop-up-frames nil))
;; We explicitly prohibit creating edit buffer in a new frame
;; - such configuration is not supported.
(switch-to-buffer-other-window "*Edit Formulas*"))
(erase-buffer)
;; Keep global-font-lock-mode from turning on font-lock-mode
(let ((font-lock-global-modes '(not fundamental-mode)))
(fundamental-mode))
(setq-local font-lock-global-modes (list 'not major-mode))
(setq-local org-pos pos)
(setq-local org-table--fedit-source source)
(setq-local org-window-configuration wc)
(setq-local org-selected-window sel-win)
(use-local-map org-table-fedit-map)
(add-hook 'post-command-hook #'org-table-fedit-post-command t t)
(setq startline (org-current-line))
(dolist (entry eql)
(let* ((type (cond
((string-match "\\`\\$\\([0-9]+\\|[<>]+\\)\\'"
(car entry))
'column)
((equal (string-to-char (car entry)) ?@) 'field)
(t 'named)))
(title (assq type titles)))
(when title
(unless (bobp) (insert "\n"))
(insert
(org-add-props (cdr title) nil 'face 'font-lock-comment-face))
(setq titles (remove title titles)))
(when (equal key (car entry)) (setq startline (org-current-line)))
(let ((s (concat
(if (memq (string-to-char (car entry)) '(?@ ?$)) "" "$")
(car entry) " = " (cdr entry) "\n")))
(remove-text-properties 0 (length s) '(face nil) s)
(insert s))))
(when (eq org-table-use-standard-references t)
(org-table-fedit-toggle-ref-type))
(org-goto-line startline)
(message "%s" (substitute-command-keys "\\<org-mode-map>\
Edit formulas, finish with `\\[org-ctrl-c-ctrl-c]' or `\\[org-edit-special]'. \
See menu for more commands.")))))