emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Handle block-type when checking `org-src-fontify-natively'
@ 2023-04-06 15:04 Nathaniel Nicandro
  2023-04-07 10:13 ` Ihor Radchenko
  2024-02-23 13:13 ` Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Nathaniel Nicandro @ 2023-04-06 15:04 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]


Hello,

I think I found a bug where the condition for `org-src-fontify-natively`
in `org-src-fontify-meta-lines-and-blocks-1` wasn't handling the block
type.  `org-src-fontify-natively` says it should fontify src blocks
only, but the condition didn't have that constraint.  Attached is a
patch that adds in the constraint.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1157 bytes --]

From 2f1342ad5b13f75387f6a26f0c68aac054903bcc Mon Sep 17 00:00:00 2001
From: Nathaniel Nicandro <nathanielnicandro@gmail.com>
Date: Thu, 6 Apr 2023 08:49:20 -0500
Subject: [PATCH] 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(-)

diff --git a/lisp/org.el b/lisp/org.el
index a6b8a30..d6c5803 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5414,8 +5414,9 @@ (defun org-fontify-meta-lines-and-blocks-1 (limit)
 	     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
-	     (org-src-fontify-natively
+            (cond
+	     ((and org-src-fontify-natively
+                   (string= block-type "src"))
 	      (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)))
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 15 bytes --]


-- 
Nathaniel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Handle block-type when checking `org-src-fontify-natively'
  2023-04-06 15:04 [PATCH] Handle block-type when checking `org-src-fontify-natively' Nathaniel Nicandro
@ 2023-04-07 10:13 ` Ihor Radchenko
  2024-02-23 13:13 ` Ihor Radchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-04-07 10:13 UTC (permalink / raw)
  To: Nathaniel Nicandro; +Cc: emacs-orgmode

Nathaniel Nicandro <nathanielnicandro@gmail.com> writes:

> I think I found a bug where the condition for `org-src-fontify-natively`
> in `org-src-fontify-meta-lines-and-blocks-1` wasn't handling the block
> type.  `org-src-fontify-natively` says it should fontify src blocks
> only, but the condition didn't have that constraint.  Attached is a
> patch that adds in the constraint.

Thanks!
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=616e80a9f

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Handle block-type when checking `org-src-fontify-natively'
  2023-04-06 15:04 [PATCH] Handle block-type when checking `org-src-fontify-natively' Nathaniel Nicandro
  2023-04-07 10:13 ` Ihor Radchenko
@ 2024-02-23 13:13 ` Ihor Radchenko
  2024-02-24 17:48   ` Nathaniel Nicandro
  1 sibling, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-02-23 13:13 UTC (permalink / raw)
  To: Nathaniel Nicandro; +Cc: emacs-orgmode, Rudi C

Nathaniel Nicandro <nathanielnicandro@gmail.com> writes:

> I think I found a bug where the condition for `org-src-fontify-natively`
> in `org-src-fontify-meta-lines-and-blocks-1` wasn't handling the block
> type.  `org-src-fontify-natively` says it should fontify src blocks
> only, but the condition didn't have that constraint.  Attached is a
> patch that adds in the constraint.

It turned out, that some people relied on the undocumented behavior that
Org mode fontifies example blocks as well.
https://orgmode.org/list/CAE9z9A3ko27NeN0oYFs_aBWV_cUbNm5YQTLrRux16dHsixsMBA@mail.gmail.com

Nathaniel, is there any particular problem you encountered that your
patch was aiming to solve? If no, we should probably re-add fontifying
example blocks as undocumented feature people rely on in practice.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Handle block-type when checking `org-src-fontify-natively'
  2024-02-23 13:13 ` Ihor Radchenko
@ 2024-02-24 17:48   ` Nathaniel Nicandro
  0 siblings, 0 replies; 4+ messages in thread
From: Nathaniel Nicandro @ 2024-02-24 17:48 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Nathaniel Nicandro, emacs-orgmode, Rudi C


Ihor Radchenko <yantar92@posteo.net> writes:

> Nathaniel, is there any particular problem you encountered that your
> patch was aiming to solve? If no, we should probably re-add fontifying
> example blocks as undocumented feature people rely on in practice.

No there wasn't any particular problem, I was just browsing the code and
saw that it was undocumented behavior.

-- 
Nathaniel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-24 17:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 15:04 [PATCH] Handle block-type when checking `org-src-fontify-natively' Nathaniel Nicandro
2023-04-07 10:13 ` Ihor Radchenko
2024-02-23 13:13 ` Ihor Radchenko
2024-02-24 17:48   ` Nathaniel Nicandro

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).