Function: rst-ttl-at-point
rst-ttl-at-point is a byte-compiled function defined in rst.el.gz.
Signature
(rst-ttl-at-point)
Documentation
Find a section title line around point and return its characteristics.
If the point is on an adornment line find the respective title
line. If the point is on an empty line check previous or next
line whether it is a suitable title line and use it if so. If
point is on a suitable title line use it. Return a rst-Ttl for
a section header or nil if no title line is found.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-ttl-at-point ()
;; testcover: ok.
"Find a section title line around point and return its characteristics.
If the point is on an adornment line find the respective title
line. If the point is on an empty line check previous or next
line whether it is a suitable title line and use it if so. If
point is on a suitable title line use it. Return a `rst-Ttl' for
a section header or nil if no title line is found."
(save-excursion
(save-match-data
(1value
(rst-forward-line-strict 0))
(let* (cnd-beg ; Beginning of a title candidate.
cnd-txt ; Text of a title candidate.
(cnd-fun (lambda (mtcd) ; Function setting title candidate data.
(when mtcd
(setq cnd-beg (match-beginning 0))
(setq cnd-txt (match-string-no-properties 1))
t)))
ttl)
(cond
((looking-at (rst-re 'ado-beg-2-1))
;; Adornment found - consider it.
(setq ttl (rst-classify-adornment (match-string-no-properties 0)
(match-end 0) t)))
((looking-at (rst-re 'lin-end))
;; Empty line found - check surrounding lines for a title.
(or
(rst-forward-line-looking-at -1 'ttl-beg-1 cnd-fun)
(rst-forward-line-looking-at +1 'ttl-beg-1 cnd-fun)))
((looking-at (rst-re 'ttl-beg-1))
;; Title line found - check for a following underline.
(setq ttl (rst-forward-line-looking-at
1 'ado-beg-2-1
(lambda (mtcd)
(when mtcd
(rst-classify-adornment
(match-string-no-properties 0) (match-end 0))))))
;; Title candidate found if no valid adornment found.
(funcall cnd-fun (not ttl))))
(cond
((and ttl (rst-Ttl-is-section ttl))
ttl)
(cnd-beg
(rst-Ttl-from-buffer nil nil cnd-beg nil cnd-txt)))))))