emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] (cosmetic) improving block declaration colors
@ 2022-06-08  7:00 Phil Estival
  2022-06-08 13:50 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Estival @ 2022-06-08  7:00 UTC (permalink / raw)
  To: emacs-orgmode

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


Hi,

from org 9.5.3-g69c588

PATCH 1/2:

Having several programming books converted to org,
I read a lot of begin/end_src expressions. The
following patch helps lessen the visibility of
those terms: they are syntax tokens and can be
replaced my colors.

So this gives different faces to the language
specifiers and begin_ words, to attenuate
begin_/end_src and emphasize the language selected.

The picture in the attachment shows how source
blocks get rendered then.  Don't mind too much
the "begin_quote" on it, as it's intended to
be "begin_src" under normal circumstances.


PATCH 2/2:
org/lisp/org.el::4966
#+begin_src elisp
   ;; Set face extension as requested. FIXME
   ;; (org--set-faces-extend '(org-block-begin-line org-block-end-line)
   ;;                        org-fontify-whole-block-delimiter-line)
#+end_src

I turned off those two lines otherwise the extend
property of org-block-begin-line and org-block-end-line
would keep coming back even after customizing them
("but I just did untick that box!")

When org-fontify-whole-block-delimiter-line is set to nil,
the block background start after /#+begin_src elisp/.
When it isn't set, an underline will run all over the line.


have a nice day,
Phil




[-- Attachment #2: org_src_block_2022-06-08.png --]
[-- Type: image/png, Size: 4885 bytes --]

[-- Attachment #3: 0001-cosmetic-distinct-faces-in-block-declaration-when-is.patch --]
[-- Type: text/x-patch, Size: 3445 bytes --]

From c6e0bf2b4753608467bf9d545f62cc1d79bda80f Mon Sep 17 00:00:00 2001
From: Phil Estival <pe@7d.nz>
Date: Wed, 8 Jun 2022 08:24:00 +0200
Subject: [PATCH 1/2] (cosmetic) distinct faces in block declaration when is
 language set

---
 lisp/org-faces.el | 12 ++++++++++++
 lisp/org.el       | 21 ++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index d96898372..96e190a17 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -455,6 +455,18 @@ verse and quote blocks are fontified using the `org-verse' and
   "Face used for the line delimiting the end of source blocks."
   :group 'org-faces)
 
+(defface org-block-begin-src '((t (:inherit org-block-begin-line)))
+  "Face used for the begin_term of source blocks."
+  :group 'org-faces)
+
+(defface org-block-lang '((t (:inherit org-block-begin-line)))
+  "Face used for the language of source blocks."
+  :group 'org-faces)
+
+(defface org-block-switches '((t (:inherit org-block-begin-line)))
+  "Face used for the switches and headers arguments of source blocks."
+  :group 'org-faces)
+
 (defface org-verbatim '((t (:inherit shadow)))
   "Face for fixed-with text like code snippets."
   :group 'org-faces
diff --git a/lisp/org.el b/lisp/org.el
index 1fc4251a3..c7de64b81 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4964,7 +4964,7 @@ The following commands are available:
       (set-face-foreground 'org-hide foreground)))
   ;; Set face extension as requested.
   (org--set-faces-extend '(org-block-begin-line org-block-end-line)
-                         org-fontify-whole-block-delimiter-line)
+                          org-fontify-whole-block-delimiter-line)
   (org--set-faces-extend org-level-faces org-fontify-whole-heading-line))
 
 ;; Update `customize-package-emacs-version-alist'
@@ -5291,6 +5291,8 @@ by a #."
 	    ;; after the end of block content.
 	    (block-start (match-end 0))
 	    (block-end nil)
+            (lang-begin (match-beginning 7))
+            (lang-end (match-end 7))
 	    (lang (match-string 7)) ; The language, if it is a source block.
 	    (bol-after-beginline (line-beginning-position 2))
 	    (dc1 (downcase (match-string 2)))
@@ -5346,10 +5348,19 @@ by a #."
 	     ((string= 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))
+             ;; Fontify the #+begin and #+end lines of the blocks
+             (if (string= lang "")
+                 (add-text-properties
+	          beg (if whole-blockline bol-after-beginline end-of-beginline)
+                  '(face org-block-begin-line))
+               ;; when language is set, fontify separately
+               ;; begin_[src], language and switches
+              (and (add-text-properties beg lang-begin
+                                        '(face org-block-begin-src))
+                   (add-text-properties lang-begin lang-end
+                                        '(face org-block-lang))
+	           (add-text-properties lang-end bol-after-beginline
+                                        '(face org-block-switches))))
 	    (unless (eq (char-after beg-of-endline) ?*)
 	      (add-text-properties
 	       beg-of-endline
-- 
2.31.GIT


[-- Attachment #4: 0002-prevent-org-fontify-whole-block-delimiter-line-to-ov.patch --]
[-- Type: text/x-patch, Size: 1107 bytes --]

From b80d37d57d71a747e113ec56fa10aacb0bd750d4 Mon Sep 17 00:00:00 2001
From: Phil Estival <pe@7d.nz>
Date: Wed, 8 Jun 2022 08:26:56 +0200
Subject: [PATCH 2/2] prevent org-fontify-whole-block-delimiter-line to
 override extend

---
 lisp/org.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index c7de64b81..81f3a98f2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4962,9 +4962,9 @@ The following commands are available:
   (let ((foreground (org-find-invisible-foreground)))
     (when foreground
       (set-face-foreground 'org-hide foreground)))
-  ;; Set face extension as requested.
-  (org--set-faces-extend '(org-block-begin-line org-block-end-line)
-                          org-fontify-whole-block-delimiter-line)
+  ;; Set face extension as requested. FIXME
+  ;; (org--set-faces-extend '(org-block-begin-line org-block-end-line)
+  ;;                         org-fontify-whole-block-delimiter-line)
   (org--set-faces-extend org-level-faces org-fontify-whole-heading-line))
 
 ;; Update `customize-package-emacs-version-alist'
-- 
2.31.GIT


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

* Re: [PATCH] (cosmetic) improving block declaration colors
  2022-06-08  7:00 [PATCH] (cosmetic) improving block declaration colors Phil Estival
@ 2022-06-08 13:50 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-06-08 13:50 UTC (permalink / raw)
  To: Phil Estival; +Cc: emacs-orgmode

Phil Estival <pe@7d.nz> writes:

> Having several programming books converted to org,
> I read a lot of begin/end_src expressions. The
> following patch helps lessen the visibility of
> those terms: they are syntax tokens and can be
> replaced my colors.
>
> So this gives different faces to the language
> specifiers and begin_ words, to attenuate
> begin_/end_src and emphasize the language selected.
>
> The picture in the attachment shows how source
> blocks get rendered then.  Don't mind too much
> the "begin_quote" on it, as it's intended to
> be "begin_src" under normal circumstances.

The idea is reasonable and also in line with our inline src block
fontification. However, we are currently switching the fontification
backend. Hence, I'd prefer to postpone this patch to later. It will need
to be adapted to the new fontification code.

See https://orgmode.org/list/87ee7c9quk.fsf@localhost

Best,
Ihor


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

end of thread, other threads:[~2022-06-08 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-08  7:00 [PATCH] (cosmetic) improving block declaration colors Phil Estival
2022-06-08 13:50 ` Ihor Radchenko

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).