This patch is a change to how org fontifies verbatim source blocks re: [1]. Hopefully it answers Nicolas's question from that thread. Best! Tom
On Sun, Dec 8, 2019 at 12:05 AM Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote: > I do not understand. Source and example blocks are verbatim blocks, > whereas verse blocks are not. There is nothing to match, is there? [1] Bug: headlines escape blocks: https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00133.html
From 531eac23e22b5b8b16f2747bbd5c1bd43fcbe43b Mon Sep 17 00:00:00 2001 From: Tom Gillespie <tgbugs@gmail.com> Date: Wed, 11 Dec 2019 17:57:47 -0800 Subject: org.el: Fix verbatim block fontification to end blocks on headlines * lisp/org.el (org-fontify-meta-lines-and-blocks-1): Enhance regex for finding the end of blocks (i.e., `beg-of-endline') to detect headlines (i.e., "^\\*") so that fontification matches the behavior of org mode (i.e., that headlines are healines, even in vertabim). This change aligns the behavior and the visual appearance of verbatim blocks that contain headlines. When `font-lock-mode' is enabled this change makes situations like those in (info "(org) Literal Examples") literally jump off the page. Overview of new fontification Source | fontification before | fontification after | \#+BEGIN_EXAMPLE | org-block-begin-line | org-block-begin-line | I look verbatim! | org-block | org-block | * Org headers in | org-block | org-level-1 | verbatim blocks | org-block | nil | ** highly accordingly | org-block | org-level-2 | \#+END_EXAMPLE | org-block-end-line | org-meta-line | TINYCHANGE --- lisp/org.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 9b84592ba..0e8dda495 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5287,7 +5287,7 @@ by a #." (setq block-type (downcase (match-string 5)) quoting (member block-type org-protecting-blocks)) ; src, example, export, maybe more (when (re-search-forward - (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") + (concat "\\(^\\*\\|^[ \t]*#\\+end" (match-string 4) "\\>.*\\)") nil t) ;; on purpose, we look further than LIMIT ;; We do have a matching #+end line (setq beg-of-endline (match-beginning 0) @@ -5326,10 +5326,11 @@ by a #." (add-text-properties beg (if whole-blockline bol-after-beginline end-of-beginline) '(face org-block-begin-line)) - (add-text-properties - beg-of-endline - (min (point-max) (if whole-blockline (min (point-max) (1+ end-of-endline)) end-of-endline)) - '(face org-block-end-line)) + (when (not (string= (match-string 1) "*")) + (add-text-properties + beg-of-endline + (min (point-max) (if whole-blockline (min (point-max) (1+ end-of-endline)) end-of-endline)) + '(face org-block-end-line))) t)) ((member dc1 '("+title:" "+author:" "+email:" "+date:")) (org-remove-flyspell-overlays-in -- 2.23.0