Function: rst-font-lock-extend-region-extend
rst-font-lock-extend-region-extend is a byte-compiled function defined
in rst.el.gz.
Signature
(rst-font-lock-extend-region-extend PT DIR)
Documentation
Extend the region starting at point PT and extending in direction DIR.
Return extended point or nil if not moved.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
;; FIXME: If a single line is made a section header by `rst-adjust' the header
;; is not always fontified immediately.
(defun rst-font-lock-extend-region-extend (pt dir)
"Extend the region starting at point PT and extending in direction DIR.
Return extended point or nil if not moved."
;; There are many potential multiline constructs but there are two groups
;; which are really relevant. The first group consists of
;;
;; * comment lines without leading explicit markup tag and
;;
;; * literal blocks following "::"
;;
;; which are both indented. Thus indentation is the first thing recognized
;; here. The second criteria is an explicit markup tag which may be a comment
;; or a double colon at the end of a line.
;;
;; The second group consists of the adornment cases.
(if (not (get-text-property pt 'font-lock-multiline))
;; Move only if we don't start inside a multiline construct already.
(save-match-data
(save-excursion
(let ( ; Non-empty non-indented line, explicit markup tag or literal
; block tag.
(stop-re (rst-re '(:alt "[^ \t\n]"
(:seq hws-tag exm-tag)
(:seq ".*" dcl-tag lin-end)))))
;; The comments below are for dir == -1 / dir == 1.
(goto-char pt)
(rst-forward-line-strict 0)
(setq pt (point))
(while (and (not (looking-at stop-re))
(zerop (rst-forward-line dir)))) ; try previous / next
; line if it exists.
(if (looking-at (rst-re 'ado-beg-2-1)) ; may be an underline /
; overline.
(if (zerop (rst-forward-line dir))
(if (looking-at (rst-re 'ttl-beg-1)) ; title found, i.e.
; underline / overline
; found.
(if (zerop (rst-forward-line dir))
(if (not
(looking-at (rst-re 'ado-beg-2-1))) ; no
; overline
; /
; underline.
(rst-forward-line (- dir)))) ; step back to
; title /
; adornment.
(if (< dir 0) ; keep downward adornment.
(rst-forward-line (- dir))))) ; step back to adornment.
(if (looking-at (rst-re 'ttl-beg-1)) ; may be a title.
(if (zerop (rst-forward-line dir))
(if (not
(looking-at (rst-re 'ado-beg-2-1))) ; no overline /
; underline.
(rst-forward-line (- dir)))))) ; step back to line.
(if (not (= (point) pt))
(point)))))))