Function: org-table--descriptor-line

org-table--descriptor-line is a byte-compiled function defined in org-table.el.gz.

Signature

(org-table--descriptor-line DESC CLINE)

Documentation

Return relative line number corresponding to descriptor DESC.

The cursor is currently in relative line number CLINE.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table--descriptor-line (desc cline)
  "Return relative line number corresponding to descriptor DESC.
The cursor is currently in relative line number CLINE."
  (if (string-match "\\`[0-9]+\\'" desc)
      (aref org-table-dlines (string-to-number desc))
    (when (or (not (string-match
		    "^\\(\\([-+]\\)?\\(I+\\)\\)?\\(\\([-+]\\)?\\([0-9]+\\)\\)?"
		    ;;  1  2          3           4  5          6
		    desc))
	      (and (not (match-end 3)) (not (match-end 6)))
	      (and (match-end 3) (match-end 6) (not (match-end 5))))
      (user-error "Invalid row descriptor `%s'" desc))
    (let* ((hn (and (match-end 3) (- (match-end 3) (match-beginning 3))))
	   (hdir (match-string 2 desc))
	   (odir (match-string 5 desc))
	   (on (and (match-end 6) (string-to-number (match-string 6 desc))))
	   (rel (and (match-end 6)
		     (or (and (match-end 1) (not (match-end 3)))
			 (match-end 5)))))
      (when (and hn (not hdir))
	(setq cline 0)
	(setq hdir "+")
	(when (eq (aref org-table-current-line-types 0) 'hline) (cl-decf hn)))
      (when (and (not hn) on (not odir)) (user-error "Should never happen"))
      (when hn
	(setq cline
	      (org-table--row-type 'hline hn cline (equal hdir "-") nil desc)))
      (when on
	(setq cline
	      (org-table--row-type 'dline on cline (equal odir "-") rel desc)))
      cline)))