Function: org-table-line-to-dline

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

Signature

(org-table-line-to-dline LINE &optional ABOVE)

Documentation

Turn a buffer line number into a data line number.

If there is no data line in this line, return nil.

If there is no matching dline (most likely the reference was a hline), the first dline below it is used. When ABOVE is non-nil, the one above is used.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-line-to-dline (line &optional above)
  "Turn a buffer line number into a data line number.

If there is no data line in this line, return nil.

If there is no matching dline (most likely the reference was
a hline), the first dline below it is used.  When ABOVE is
non-nil, the one above is used."
  (let ((min 1)
	(max (1- (length org-table-dlines))))
    (cond ((or (> (aref org-table-dlines min) line)
	       (< (aref org-table-dlines max) line))
	   nil)
	  ((= line (aref org-table-dlines max)) max)
	  (t (catch 'exit
	       (while (> (- max min) 1)
		 (let* ((mean (/ (+ max min) 2))
			(v (aref org-table-dlines mean)))
		   (cond ((= v line) (throw 'exit mean))
			 ((> v line) (setq max mean))
			 (t (setq min mean)))))
	       (cond ((= line (aref org-table-dlines max)) max)
		     ((= line (aref org-table-dlines min)) min)
		     (above min)
		     (t max)))))))