From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id SJUFEzmq12UqeAEAqHPOHw:P1 (envelope-from ) for ; Thu, 22 Feb 2024 21:10:33 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id SJUFEzmq12UqeAEAqHPOHw (envelope-from ) for ; Thu, 22 Feb 2024 21:10:33 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=an44sfoS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708632633; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VdcN4Wj8ocCqEVjVSUSQTI729kVBM+8f89+pZk0LBBA=; b=Qd+smQat7Gjfum4PI3ASM4Q25WZmi6r/UiviguOcpa+6OjvoWa040QQBefy/cRNbudHUNN fimpMYw8ITPHHv8e6DdCxfYX1gj0Bnuzj6A9TCIn4afpdM4ZdEDNEh5y/GqwqtPLKmkHXR JKD3HmEWka6uD/6RjsBolD5WMhf63rF8+yrGoZsKI6/7Urcr0CkswqoW+n9hOmmM8FsLSB Gjij/2IFGm+UHJOnUbNq9TtSVH0ebImsLQd6QB7jR9aNIVIKl1uZGC64aznW5fhYLTg+7e uF0ujGWXL1n+Hbhihrk4DH4NvBBeWuPf5j5zKI2JdyQ7evJb4mOyY/pvwm7Nlw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=an44sfoS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708632633; a=rsa-sha256; cv=none; b=uldfF2x+oJHUQXfSt6drlmFEq9sBo10NTTTxm3H407Dxk94ski73+zyor4cp5id1dZz85T zLjA7TRmw2M1YlydY6fnXJbb7zoSkHbeShJEzYk2dMsrjSOFtWIJ+4C6DWg8JNIDKbmrdj HZs4VtrJA+WUA3caOMxvSEIAuG1/vS8QngPZhB0djrKl6f2u9yn2iNNzJVi0sGGN+Ar8kD hIXGkeZuT1oWUS86mxfnQVP2k6xKAt+ft6DMu15L7VnFpetmumy1hKYqPzPWgPbJGgtWVa mj2EUj1Ts+hOE7yPLhaSZvOSxh1OII44Uw/TR6oR2yl0O01xaJAZ9zqq3syIiA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id ECD301C58D for ; Thu, 22 Feb 2024 21:10:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFNp-0005Sr-3n; Thu, 22 Feb 2024 15:09:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdFNm-0005SJ-P3 for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 15:09:26 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFNk-0004ay-22 for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 15:09:26 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-206689895bfso98416fac.1 for ; Thu, 22 Feb 2024 12:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708632562; x=1709237362; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VdcN4Wj8ocCqEVjVSUSQTI729kVBM+8f89+pZk0LBBA=; b=an44sfoS1I2V5masRIWa3KO0tAGSO6jkpCVzV95+Tsin4mJQT64oDhhOcC9wlSc3JZ Q4ghrK2KDF3WQUGB6f5TnZZ6oEwRLfK4qBXbCNmO7Beby9Cc4PFOldFjjvabjxvZQYQW WRqFbh3zPe4iYmCbDQ18wy68a0gS4tFUmAneXrEKzdi/iYiygoA7gobItSt7mF8bq09G FZOdWsYhCLXF3WryWmfbwbx3/jub5pNuClK2OB8XuTEYboIDZ6f0A7bsrpGuAcri+hOF kZ4uhsuBj9XT3EhuWRRHRr92+D4HEwIR0DYdLA0QWIQEAHIx7RW1leLU+rpXv6xvcNRN O8Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708632562; x=1709237362; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VdcN4Wj8ocCqEVjVSUSQTI729kVBM+8f89+pZk0LBBA=; b=SMm+8p6zNW5Wb9REOCUzaiPiTQ6YafVUOqOrk857H+y0/FNfk/cYJp8prTY6Ortksb DA40L/7JNapXxyLu4eSIc5MwOCspoK07kwFwwzQTMsm2R216Txty+ySAiP1MnhszdORC eXwxpNZbcsbjc7coa/yBAhKPiIa8s/P9UV96UhKobcErn28iMWAgfHcygACGH/Ng9RCT DBXT/NbDWOnUW8+3alGVcNUwJc8XYXEbJZqXzLP4KMlOmmgJhQv04oex41W9B8BLChgx yxOwPq/ZDiOEGCg9b66/3l+GPjxypdmxFSH+kucpzCvs5rWx+spj8IkrvZ0lK+aaSIsn pVlA== X-Gm-Message-State: AOJu0YwQhwRWfGK7Y4+GjwKmiuX4N42/D065O6Q1jj/DA5XHqCj97oQP Q50e89TRPnpqHoAqAosU5SHihyWBLHTh7J+/LtpeRDjOxwCTPLzgrcE0Nz5hSJzjxpmgtkInhrd gve2m8Tu0UCT2LOKEjVZ+Dur7PsVijMs86ey1cQ== X-Google-Smtp-Source: AGHT+IHNejsiCwKC4icA78MLKv/xF/Jcwxib2Um1+0PlgDtghM4wL55TcOO1X9n5ZZSiveLWA0R5RF/3/KhK4SFRnI0= X-Received: by 2002:a05:6871:713:b0:21e:6670:b84a with SMTP id f19-20020a056871071300b0021e6670b84amr19667496oap.5.1708632562409; Thu, 22 Feb 2024 12:09:22 -0800 (PST) MIME-Version: 1.0 References: <65d76c84.df0a0220.8cb17.afd6@mx.google.com> In-Reply-To: <65d76c84.df0a0220.8cb17.afd6@mx.google.com> From: Rudi C Date: Thu, 22 Feb 2024 23:38:46 +0330 Message-ID: Subject: Re: org-mode: example blocks are no longer syntax highlighted in emacs To: Bruno Barbier Cc: emacs-orgmode@gnu.org Content-Type: multipart/alternative; boundary="000000000000ef248e0611fe049f" Received-SPF: pass client-ip=2001:4860:4864:20::33; envelope-from=rudiwillalwaysloveyou@gmail.com; helo=mail-oa1-x33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -9.56 X-Spam-Score: -9.56 X-Migadu-Queue-Id: ECD301C58D X-TUID: o8l46Nw4ohsS --000000000000ef248e0611fe049f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Why is `:eval never` not as good ? You don't have to write it on each > code block; you may set it globally, per file, per headline, etc. The main reason is that I also use source blocks for babel blocks that are runnable. So I cannot use per headline etc. solutions. I can use snippets to automatically insert `:eval never`, but it's not as good a UX. I also already have lots of org-mode notes written using `example lang` blocks. Rewriting all of these will be a PITA. > My version of pandoc generates org source blocks from markdown code > blocks (pandoc 3.1.11.1). I upgraded my pandoc, and it now indeed does this if the markdown block has a source lang defined. --- NickD has identified the commit that introduced this breaking change: ``` commit 616e80a9f10c4bd085d7b5ac96fd6ea23e9c9191 Author: Date: Thu Apr 6 08:49:20 2023 -0500 Handle block-type when checking `org-src-fontify-natively` * lisp/org.el (org-fontify-meta-lines-and-blocks-1): Only fontify natively for blocks of src type. lisp/org.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ``` Thanks to the above commit ( https://github.com/bzg/org-mode/commit/616e80a9f10c4bd085d7b5ac96fd6ea23e9c= 9191), I wrote this patch which can be put in one's config to make this behavior configurable. Can you merge this upstream? emacs is all about user customizability, and in general, breaking backward compatibility without giving a way out is bad= . ```lisp (defvar night/org-fontify-block-types '("src" "example") "List of block types to fontify in org-mode.") (defun night/org-fontify-block-p (block-type) "Check if BLOCK-TYPE is one of the types to fontify." (member block-type night/org-fontify-block-types)) (defun night/org-fontify-meta-lines-and-blocks-1 (limit) "Fontify #+ lines and blocks." (let ((case-fold-search t)) (when (re-search-forward (rx bol (group (zero-or-more (any " \t")) "#" (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":")) (any " \t") eol)) (optional (group "_" (group (one-or-more (any "a-zA-Z")))))) (zero-or-more (any " \t")) (group (group (zero-or-more (not (any " \t\n")))) (zero-or-more (any " \t")) (group (zero-or-more any))))) limit t) (let ((beg (match-beginning 0)) (end-of-beginline (match-end 0)) ;; Including \n at end of #+begin line will include \n ;; after the end of block content. (block-start (match-end 0)) (block-end nil) (lang (match-string 7)) ; The language, if it is a source block. (bol-after-beginline (line-beginning-position 2)) (dc1 (downcase (match-string 2))) (dc3 (downcase (match-string 3))) (whole-blockline org-fontify-whole-block-delimiter-line) beg-of-endline end-of-endline nl-before-endline quoting block-type) (cond ((and (match-end 4) (equal dc3 "+begin")) ;; Truly a block (setq block-type (downcase (match-string 5)) ;; Src, example, export, maybe more. quoting (member block-type org-protecting-blocks)) (when (re-search-forward (rx-to-string `(group bol (or (seq (one-or-more "*") space) (seq (zero-or-more (any " \t")) "#+end" ,(match-string 4) word-end (zero-or-more any))))) ;; We look further than LIMIT on purpose. nil t) ;; We do have a matching #+end line. (setq beg-of-endline (match-beginning 0) end-of-endline (match-end 0) nl-before-endline (1- (match-beginning 0))) (setq block-end (match-beginning 0)) ; Include the final newline. (when quoting (org-remove-flyspell-overlays-in bol-after-beginline nl-before-endline= ) (remove-text-properties beg end-of-endline '(display t invisible t intangible t))) (add-text-properties beg end-of-endline '(font-lock-fontified t font-lock-multiline t)) (org-remove-flyspell-overlays-in beg bol-after-beginline) (org-remove-flyspell-overlays-in nl-before-endline end-of-endline) (cond ((and org-src-fontify-natively (night/org-fontify-block-p block-type)) (save-match-data (org-src-font-lock-fontify-block (or lang "") block-start block-end)) (add-text-properties bol-after-beginline block-end '(src-block t))) (quoting (add-text-properties bol-after-beginline beg-of-endline (list 'face (list :inherit (let ((face-name (intern (format "org-block-%s" lang)))) (append (and (facep face-name) (list face-name)) '(org-block))))))) ((not org-fontify-quote-and-verse-blocks)) ((string=3D block-type "quote") (add-face-text-property bol-after-beginline beg-of-endline 'org-quote t)) ((string=3D block-type "verse") (add-face-text-property bol-after-beginline beg-of-endline 'org-verse t))) ;; Fontify the #+begin and #+end lines of the blocks (add-text-properties beg (if whole-blockline bol-after-beginline end-of-beginline) '(face org-block-begin-line)) (unless (eq (char-after beg-of-endline) ?*) (add-text-properties beg-of-endline (if whole-blockline (let ((beg-of-next-line (1+ end-of-endline))) (min (point-max) beg-of-next-line)) (min (point-max) end-of-endline)) '(face org-block-end-line))) t)) ((member dc1 '("+title:" "+subtitle:" "+author:" "+email:" "+date:")) (org-remove-flyspell-overlays-in (match-beginning 0) (if (equal "+title:" dc1) (match-end 2) (match-end 0))) (add-text-properties beg (match-end 3) (if (member (intern (substring dc1 1 -1)) org-hidden-keywords) '(font-lock-fontified t invisible t) '(font-lock-fontified t face org-document-info-keyword))) (add-text-properties (match-beginning 6) (min (point-max) (1+ (match-end 6))) (if (string-equal dc1 "+title:") '(font-lock-fontified t face org-document-title) '(font-lock-fontified t face org-document-info)))) ((string-prefix-p "+caption" dc1) (org-remove-flyspell-overlays-in (match-end 2) (match-end 0)) (remove-text-properties (match-beginning 0) (match-end 0) '(display t invisible t intangible t)) ;; Handle short captions (save-excursion (forward-line 0) (looking-at (rx (group (zero-or-more (any " \t")) "#+caption" (optional "[" (zero-or-more any) "]") ":") (zero-or-more (any " \t"))))) (add-text-properties (line-beginning-position) (match-end 1) '(font-lock-fontified t face org-meta-line)) (add-text-properties (match-end 0) (line-end-position) '(font-lock-fontified t face org-block)) t) ((member dc3 '(" " "")) ;; Just a comment, the plus was not there (org-remove-flyspell-overlays-in beg (match-end 0)) (add-text-properties beg (match-end 0) '(font-lock-fontified t face font-lock-comment-face))) (t ;; Just any other in-buffer setting, but not indented (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (remove-text-properties (match-beginning 0) (match-end 0) '(display t invisible t intangible t)) (add-text-properties beg (match-end 0) '(font-lock-fontified t face org-meta-line)) t)))))) (advice-add 'org-fontify-meta-lines-and-blocks-1 :override #'night/org-fontify-meta-lines-and-blocks-1) ``` On Thu, Feb 22, 2024 at 7:17=E2=80=AFPM Bruno Barbier = wrote: > > Hi Rudi, > > Rudi C writes: > > > After upgrading to emacs 29.2 and org 9.7, my example blocks are no > longer > > syntax highlighted in emacs. They used to be syntax highlighted when I > > specified the block's language. Any ideas? > > > > I use Doom, so it might have been a third-party feature. > > > > I know org-mode officially suggests that example blocks should not have > > syntax highlighting, but I want it anyway. IMO `:eval never` is just no= t > as > > good, > > Why is `:eval never` not as good ? You don't have to write it on each > code block; you may set it globally, per file, per headline, etc. > > See https://orgmode.org/manual/Using-Header-Arguments.html. > > > > not to mention tools like `pandoc` also produce example blocks from > > markdown source blocks. > > My version of pandoc generates org source blocks from markdown code > blocks (pandoc 3.1.11.1). > > I'm not sure you'll get a better answer than this SE answer: > > > https://emacs.stackexchange.com/questions/76466/how-do-i-get-syntax-highl= ighting-in-example-blocks-when-exporting-org-mode-to-ht > > I.e. "begin_example" is just not designed for source blocks. It > may have worked by chance before. > > Hoping this helps, > > Bruno > > --000000000000ef248e0611fe049f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> Why is `:eval never` not as good ?=C2=A0 You don'= t have to write it on each
> code block; you may set it globally, per= file, per headline, etc.

The main reason is that I also= use source blocks for babel blocks that are runnable. So I cannot use per = headline etc. solutions. I can use snippets to automatically insert `:eval = never`, but it's not as good a UX.

I also alre= ady have lots of org-mode notes written using `example lang` blocks. Rewrit= ing all of these will be a PITA.

> My version o= f pandoc generates org source blocks from markdown code
> blocks (p= andoc 3.1.11.1).

I upgraded my pandoc, and it now indeed= does this if the markdown block has a source lang defined.

<= /div>
---

NickD has identified the commit that= introduced this breaking change:

```
commit 616e80a9f10c4= bd085d7b5ac96fd6ea23e9c9191
Author: <elided>
Date: =C2=A0 Thu A= pr 6 08:49:20 2023 -0500

=C2=A0 =C2=A0 Handle block-type when checki= ng `org-src-fontify-natively`

=C2=A0 =C2=A0 * lisp/org.el (org-fonti= fy-meta-lines-and-blocks-1): Only fontify
=C2=A0 =C2=A0 =C2=A0 natively = for blocks of src type.

=C2=A0lisp/org.el | 5 +++--
=C2=A01 file = changed, 3 insertions(+), 2 deletions(-)
```

Thanks to the above commit (https://github.com/bzg/org-m= ode/commit/616e80a9f10c4bd085d7b5ac96fd6ea23e9c9191), I wrote this patc= h which can be put in one's config to make this behavior configurable.<= /div>

Can you merge this upstream? emacs is all about us= er customizability, and in general, breaking backward compatibility without= giving a way out is bad.

```lisp
(defvar night/org-fontify-block= -types '("src" "example")
=C2=A0 "List of b= lock types to fontify in org-mode.")

(defun night/org-fontify-b= lock-p (block-type)
=C2=A0 "Check if BLOCK-TYPE is one of the types= to fontify."
=C2=A0 (member block-type night/org-fontify-block-typ= es))

(defun night/org-fontify-meta-lines-and-blocks-1 (limit)
=C2= =A0 "Fontify #+ lines and blocks."
=C2=A0 (let ((case-fold-sea= rch t))
=C2=A0 =C2=A0 (when (re-search-forward
=C2=A0 (rx bol (grou= p (zero-or-more (any " \t")) "#"
=C2=A0(group (g= roup (or (seq "+" (one-or-more (any "a-zA-Z")) (optiona= l ":"))
=C2=A0 =C2=A0(any " \t")
=C2= =A0 =C2=A0eol))
(optional (group "_" (group (one-or-more = (any "a-zA-Z"))))))
=C2=A0(zero-or-more (any " \t&quo= t;))
=C2=A0(group (group (zero-or-more (not (any " \t\n"))= ))
(zero-or-more (any " \t"))
(group (zero-or-mor= e any)))))
=C2=A0 limit t)
=C2=A0 =C2=A0 =C2=A0 (let ((beg (match-b= eginning 0))
=C2=A0 =C2=A0(end-of-beginline (match-end 0))
=C2=A0= =C2=A0;; Including \n at end of #+begin line will include \n
=C2=A0 = =C2=A0;; after the end of block content.
=C2=A0 =C2=A0(block-start (ma= tch-end 0))
=C2=A0 =C2=A0(block-end nil)
=C2=A0 =C2=A0(lang (matc= h-string 7)) =C2=A0 =C2=A0 ; The language, if it is a source block.
= =C2=A0 =C2=A0(bol-after-beginline (line-beginning-position 2))
=C2=A0 = =C2=A0(dc1 (downcase (match-string 2)))
=C2=A0 =C2=A0(dc3 (downcase (m= atch-string 3)))
=C2=A0 =C2=A0(whole-blockline org-fontify-whole-block= -delimiter-line)
=C2=A0 =C2=A0beg-of-endline end-of-endline nl-before-= endline quoting block-type)
(cond
((and (match-end 4) (equal dc3 &= quot;+begin"))
=C2=A0;; Truly a block
=C2=A0(setq block-type= (downcase (match-string 5))
;; Src, example, export, maybe more.
= quoting (member block-type org-protecting-blocks))
=C2=A0(when (re-se= arch-forward
(rx-to-string `(group bol (or (seq (one-or-more "*&= quot;) space)
=C2=A0 =C2=A0 =C2=A0 (seq (zero-or-more (any " = \t"))
=C2=A0 =C2=A0"#+end"
=C2=A0 =C2=A0= ,(match-string 4)
=C2=A0 =C2=A0word-end
=C2=A0 =C2=A0(z= ero-or-more any)))))
;; We look further than LIMIT on purpose.
= nil t)
=C2=A0 =C2=A0;; We do have a matching #+end line.
=C2=A0 = =C2=A0(setq beg-of-endline (match-beginning 0)
=C2=A0end-of-endline (= match-end 0)
=C2=A0nl-before-endline (1- (match-beginning 0)))
= =C2=A0 =C2=A0(setq block-end (match-beginning 0)) ; Include the final newli= ne.
=C2=A0 =C2=A0(when quoting
=C2=A0 =C2=A0 =C2=A0(org-remove-fl= yspell-overlays-in bol-after-beginline nl-before-endline)
=C2=A0 =C2= =A0 =C2=A0(remove-text-properties beg end-of-endline
=C2=A0 =C2=A0 = =C2=A0'(display t invisible t intangible t)))
=C2=A0 =C2=A0(add-te= xt-properties
=C2=A0 =C2=A0 beg end-of-endline '(font-lock-fontifi= ed t font-lock-multiline t))
=C2=A0 =C2=A0(org-remove-flyspell-overlay= s-in beg bol-after-beginline)
=C2=A0 =C2=A0(org-remove-flyspell-overla= ys-in nl-before-endline end-of-endline)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (cond
=C2=A0 =C2=A0 ((and org-src-fontify-natively
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(night/or= g-fontify-block-p block-type))
=C2=A0 =C2=A0 =C2=A0(save-match-data=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-src-font-lock= -fontify-block (or lang "") block-start block-end))
=C2=A0 = =C2=A0 =C2=A0(add-text-properties bol-after-beginline block-end '(src-b= lock t)))
=C2=A0 =C2=A0 (quoting
=C2=A0 =C2=A0 =C2=A0(add-text-pr= operties
=C2=A0 =C2=A0 =C2=A0 bol-after-beginline beg-of-endline
= =C2=A0 =C2=A0 =C2=A0 (list 'face
=C2=A0 =C2=A0 (list :inherit
= =C2=A0 (let ((face-name
=C2=A0(intern (format "org-block-%= s" lang))))
=C2=A0 =C2=A0 (append (and (facep face-name) (list = face-name))
=C2=A0 =C2=A0 '(org-block)))))))
=C2=A0 =C2=A0= ((not org-fontify-quote-and-verse-blocks))
=C2=A0 =C2=A0 ((string=3D = block-type "quote")
=C2=A0 =C2=A0 =C2=A0(add-face-text-prope= rty
=C2=A0 =C2=A0 =C2=A0 bol-after-beginline beg-of-endline 'org-q= uote t))
=C2=A0 =C2=A0 ((string=3D block-type "verse")
= =C2=A0 =C2=A0 =C2=A0(add-face-text-property
=C2=A0 =C2=A0 =C2=A0 bol-a= fter-beginline beg-of-endline 'org-verse t)))
=C2=A0 =C2=A0;; Font= ify the #+begin and #+end lines of the blocks
=C2=A0 =C2=A0(add-text-p= roperties
=C2=A0 =C2=A0 beg (if whole-blockline bol-after-beginline en= d-of-beginline)
=C2=A0 =C2=A0 '(face org-block-begin-line))
= =C2=A0 =C2=A0(unless (eq (char-after beg-of-endline) ?*)
=C2=A0 =C2=A0= =C2=A0(add-text-properties
=C2=A0 =C2=A0 =C2=A0 beg-of-endline
= =C2=A0 =C2=A0 =C2=A0 (if whole-blockline
=C2=A0 (let ((beg-of-next-li= ne (1+ end-of-endline)))
=C2=A0 =C2=A0 (min (point-max) beg-of-next-l= ine))
(min (point-max) end-of-endline))
=C2=A0 =C2=A0 =C2=A0 = 9;(face org-block-end-line)))
=C2=A0 =C2=A0t))
((member dc1 '= ("+title:" "+subtitle:" "+author:" "+ema= il:" "+date:"))
=C2=A0(org-remove-flyspell-overlays-in<= br> =C2=A0 (match-beginning 0)
=C2=A0 (if (equal "+title:" = dc1) (match-end 2) (match-end 0)))
=C2=A0(add-text-properties
=C2= =A0 beg (match-end 3)
=C2=A0 (if (member (intern (substring dc1 1 -1))= org-hidden-keywords)
=C2=A0 =C2=A0 =C2=A0 '(font-lock-fontified t= invisible t)
=C2=A0 =C2=A0 '(font-lock-fontified t face org-docum= ent-info-keyword)))
=C2=A0(add-text-properties
=C2=A0 (match-begi= nning 6) (min (point-max) (1+ (match-end 6)))
=C2=A0 (if (string-equal= dc1 "+title:")
=C2=A0 =C2=A0 =C2=A0 '(font-lock-fontifi= ed t face org-document-title)
=C2=A0 =C2=A0 '(font-lock-fontified = t face org-document-info))))
((string-prefix-p "+caption" dc= 1)
=C2=A0(org-remove-flyspell-overlays-in (match-end 2) (match-end 0))=
=C2=A0(remove-text-properties (match-beginning 0) (match-end 0)
= =C2=A0'(display t invisible t intangible t))
=C2=A0;; Handle sh= ort captions
=C2=A0(save-excursion
=C2=A0 =C2=A0(forward-line 0)<= br> =C2=A0 =C2=A0(looking-at (rx (group (zero-or-more (any " \t"= ))
=C2=A0 "#+caption"
=C2=A0 (optional "[&qu= ot; (zero-or-more any) "]")
=C2=A0 ":")
= =C2=A0 =C2=A0(zero-or-more (any " \t")))))
=C2=A0(add-text-p= roperties (line-beginning-position) (match-end 1)
=C2=A0 =C2=A0 =C2= =A0 '(font-lock-fontified t face org-meta-line))
=C2=A0(add-text-p= roperties (match-end 0) (line-end-position)
=C2=A0 =C2=A0 =C2=A0 = 9;(font-lock-fontified t face org-block))
=C2=A0t)
((member dc3 &= #39;(" " ""))
=C2=A0;; Just a comment, the plus wa= s not there
=C2=A0(org-remove-flyspell-overlays-in beg (match-end 0))<= br> =C2=A0(add-text-properties
=C2=A0 beg (match-end 0)
=C2=A0 &= #39;(font-lock-fontified t face font-lock-comment-face)))
(t ;; Just a= ny other in-buffer setting, but not indented
=C2=A0(org-remove-flyspel= l-overlays-in (match-beginning 0) (match-end 0))
=C2=A0(remove-text-pr= operties (match-beginning 0) (match-end 0)
=C2=A0'(display t in= visible t intangible t))
=C2=A0(add-text-properties beg (match-end 0)<= br> =C2=A0 =C2=A0 =C2=A0 '(font-lock-fontified t face org-meta-line)= )
=C2=A0t))))))
(advice-add 'org-fontify-meta-lines-and-blocks-= 1 :override #'night/org-fontify-meta-lines-and-blocks-1)
```

On Thu, Feb 22, 2024 at 7:17=E2=80=AFPM Bruno Barbier <brubar.cs@gmail.com> wrote:

Hi Rudi,

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

> After upgrading to emacs 29.2 and org 9.7, my example blocks are no lo= nger
> syntax highlighted in emacs. They used to be syntax highlighted when I=
> specified the block's language. Any ideas?
>
> I use Doom, so it might have been a third-party feature.
>
> I know org-mode officially suggests that example blocks should not hav= e
> syntax highlighting, but I want it anyway. IMO `:eval never` is just n= ot as
> good,

Why is `:eval never` not as good ?=C2=A0 You don't have to write it on = each
code block; you may set it globally, per file, per headline, etc.

See https://orgmode.org/manual/Using-Header-A= rguments.html.


> not to mention tools like `pandoc` also produce example blocks from > markdown source blocks.

My version of pandoc generates org source blocks from markdown code
blocks (pandoc 3.1.11.1).

I'm not sure you'll get a better answer than this SE answer:

=C2=A0 https://emacs.stackexchange.com/question= s/76466/how-do-i-get-syntax-highlighting-in-example-blocks-when-exporting-o= rg-mode-to-ht

I.e. "begin_example" is just not designed for source blocks.=C2= =A0 It
may have worked by chance before.

Hoping this helps,

Bruno

--000000000000ef248e0611fe049f--