Function: rst-compute-tabs

rst-compute-tabs is a byte-compiled function defined in rst.el.gz.

Signature

(rst-compute-tabs PT)

Documentation

Build the list of possible tabs for all lines above.

Search backwards from point PT to build the list of possible tabs. Return a list of tabs sorted by likeliness to continue writing like rst-line-tabs. Nearer lines have generally a higher likeliness than farther lines. Return nil if no tab is found in the text above.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-compute-tabs (pt)
  "Build the list of possible tabs for all lines above.
Search backwards from point PT to build the list of possible tabs.
Return a list of tabs sorted by likeliness to continue writing
like `rst-line-tabs'.  Nearer lines have generally a higher
likeliness than farther lines.  Return nil if no tab is found in
the text above."
  ;; FIXME: See test 'indent-for-tab-command-BUGS'.
  (save-excursion
    (goto-char pt)
    (let (leftmost ; Leftmost column found so far.
	  innermost ; Leftmost column for inner tab.
	  tablist)
      (while (and (rst-forward-line-strict -1)
		  (or (not leftmost)
		      (> leftmost 0)))
	(let ((tabs (rst-line-tabs)))
	  (when tabs
	    (let ((leftcol (apply #'min (mapcar #'car tabs))))
	      ;; Consider only lines indented less or same if not INNERMOST.
	      (when (or (not leftmost)
			(< leftcol leftmost)
			(and (not innermost) (= leftcol leftmost)))
		(rst-destructuring-dolist ((column &rest inner) tabs)
		  (when (or
			 (and (not inner)
			      (or (not leftmost)
				  (< column leftmost)))
			 (and inner
			      (or (not innermost)
				  (< column innermost))))
		    (setq tablist (cl-adjoin column tablist))))
		(setq innermost (if (cl-some #'cdr tabs) ; Has inner.
				    leftcol
				  innermost))
		(setq leftmost leftcol))))))
      (nreverse tablist))))