org.el (org-fontify-extend-region): Fix headline fontification in edge case
* lisp/org.el (org-fontify-extend-region): Fix fontification of headline or meta line created by inserting a newline. Unrelated to the fix: `org-fontify-extend-region' is added to `font-lock-extend-after-change-region-function' and doesn't need to use `save-excursion'.
This commit is contained in:
parent
df51e934ae
commit
d74a82448b
19
lisp/org.el
19
lisp/org.el
|
@ -5440,7 +5440,9 @@ by a #."
|
||||||
t)))))
|
t)))))
|
||||||
|
|
||||||
(defun org-fontify-extend-region (beg end _old-len)
|
(defun org-fontify-extend-region (beg end _old-len)
|
||||||
(let ((begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
|
(let ((end (if (progn (goto-char end) (looking-at-p "^[*#]"))
|
||||||
|
(1+ end) end))
|
||||||
|
(begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
|
||||||
(end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
|
(end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
|
||||||
(extend
|
(extend
|
||||||
(lambda (r1 r2 dir)
|
(lambda (r1 r2 dir)
|
||||||
|
@ -5450,15 +5452,14 @@ by a #."
|
||||||
"[][]" r2
|
"[][]" r2
|
||||||
(match-string-no-properties 0)))))
|
(match-string-no-properties 0)))))
|
||||||
(re-search-forward (regexp-quote re) nil t dir)))))
|
(re-search-forward (regexp-quote re) nil t dir)))))
|
||||||
|
(goto-char beg)
|
||||||
|
(back-to-indentation)
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(save-excursion
|
(cond ((looking-at end-re)
|
||||||
(goto-char beg)
|
(cons (or (funcall extend "begin" "[" -1) beg) end))
|
||||||
(back-to-indentation)
|
((looking-at begin-re)
|
||||||
(cond ((looking-at end-re)
|
(cons beg (or (funcall extend "end" "]" 1) end)))
|
||||||
(cons (or (funcall extend "begin" "[" -1) beg) end))
|
(t (cons beg end))))))
|
||||||
((looking-at begin-re)
|
|
||||||
(cons beg (or (funcall extend "end" "]" 1) end)))
|
|
||||||
(t (cons beg end)))))))
|
|
||||||
|
|
||||||
(defun org-activate-footnote-links (limit)
|
(defun org-activate-footnote-links (limit)
|
||||||
"Add text properties for footnotes."
|
"Add text properties for footnotes."
|
||||||
|
|
Loading…
Reference in New Issue