Function: org-table-goto-field

org-table-goto-field is a byte-compiled function defined in org-table.el.gz.

Signature

(org-table-goto-field REF &optional CREATE-COLUMN-P)

Documentation

Move point to a specific field in the current table.

REF is either the name of a field its absolute reference, as a string. No column is created unless CREATE-COLUMN-P is non-nil. If it is a function, it is called with the column number as its argument as is used as a predicate to know if the column can be created.

This function assumes the table is already analyzed (i.e., using org-table-analyze).

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-goto-field (ref &optional create-column-p)
  "Move point to a specific field in the current table.

REF is either the name of a field its absolute reference, as
a string.  No column is created unless CREATE-COLUMN-P is
non-nil.  If it is a function, it is called with the column
number as its argument as is used as a predicate to know if the
column can be created.

This function assumes the table is already analyzed (i.e., using
`org-table-analyze')."
  (let* ((coordinates
	  (cond
	   ((cdr (assoc ref org-table-named-field-locations)))
	   ((string-match "\\`@\\([1-9][0-9]*\\)\\$\\([1-9][0-9]*\\)\\'" ref)
	    (list (condition-case nil
		      (aref org-table-dlines
			    (string-to-number (match-string 1 ref)))
		    (error (user-error "Invalid row number in %s" ref)))
		  (string-to-number (match-string 2 ref))))
	   (t (user-error "Unknown field: %s" ref))))
	 (line (car coordinates))
	 (column (nth 1 coordinates))
	 (create-new-column (if (functionp create-column-p)
				(funcall create-column-p column)
			      create-column-p)))
    (when coordinates
      (goto-char org-table-current-begin-pos)
      (forward-line line)
      (org-table-goto-column column nil create-new-column))))