Org-mode mailing list
 help / color / mirror / Atom feed
* Adaptive Org faces in headings?
@ 2020-04-26  5:16 Protesilaos Stavrou
  2020-04-26  7:42 ` Ihor Radchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-04-26  5:16 UTC (permalink / raw)
  To: emacs-orgmode

Dear all,

I have noticed that Org faces that combine with headings do not adapt to
their context.  This applies to keywords, priority cookies, links, and
possibly other elements as well.

For example, a "todo" keyword (`org-todo' face) will not scale in size
to match that of the heading level (`org-level-N' face) if the latter
uses a `:height' property.  Same principle for keywords not inheriting
the heading's background, overline, etc.

My expectation is to allow `org-level-N' to pass its attributes to any
element on the same line, unless that element has conflicting face
attributes of its own.  So, in my example, the heading could pass its
height to the "todo" keyword when the `org-todo' face does not define a
`:height' of its own.  Otherwise it would refrain from overriding that
attribute.

Does the community know of a solution to this issue?

I am running:

* Org mode version 9.3.

* GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.17,
  cairo version 1.17.3) of 2020-04-20.

Best regards,
Protesilaos


-- 
Protesilaos Stavrou
protesilaos.com


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

* Re: Adaptive Org faces in headings?
  2020-04-26  5:16 Adaptive Org faces in headings? Protesilaos Stavrou
@ 2020-04-26  7:42 ` Ihor Radchenko
  2020-09-05 14:47 ` Bastien
  2020-09-05 21:39 ` Diego Zamboni
  2 siblings, 0 replies; 21+ messages in thread
From: Ihor Radchenko @ 2020-04-26  7:42 UTC (permalink / raw)
  To: Protesilaos Stavrou, emacs-orgmode

> Does the community know of a solution to this issue?

Not precisely answer to your question, but I use the code below to get
more complete fontification in agenda. The code does not consider
heading level, but can be easily modified to do so [ (insert "* ") ->
(insert (s-concat (make-string level ?*) " ")) ]

(define-advice org-agenda-format-item (:filter-args (&rest args)  fontify-org)
  "Force fontify ageda item. (hack)"
  (cl-multiple-value-bind (extra txt level category tags dotime remove-re habitp) (car args)
    (with-temp-buffer
      (cl-letf (((symbol-function 'yant/process-att-abbrev) #'identity)
		((symbol-function 'yant/process-att-id-abbrev) #'identity)) ;; expanding sometimes causes errors when attempting to access ancestors
	(org-mode)
	(insert "* "
		txt
		"\t"
		(or (and tags (s-join ":" `(nil ,@(cl-remove-duplicates tags) nil)))
		    "")
		"\n")
	(font-lock-fontify-buffer)
	(goto-char (point-min))
	(looking-at "^\\* \\(\\([^\t]+\\)[ 	]+\\(:\\([[:alnum:]_@#%:]+\\):\\)*\\)[ 	]*$")
	(setq txt (match-string 2))
	(setq tags (and tags (s-split ":" (match-string 3) 't))))
      (list extra txt level category tags dotime remove-re habitp)))
  )


Protesilaos Stavrou <info@protesilaos.com> writes:

> Dear all,
>
> I have noticed that Org faces that combine with headings do not adapt to
> their context.  This applies to keywords, priority cookies, links, and
> possibly other elements as well.
>
> For example, a "todo" keyword (`org-todo' face) will not scale in size
> to match that of the heading level (`org-level-N' face) if the latter
> uses a `:height' property.  Same principle for keywords not inheriting
> the heading's background, overline, etc.
>
> My expectation is to allow `org-level-N' to pass its attributes to any
> element on the same line, unless that element has conflicting face
> attributes of its own.  So, in my example, the heading could pass its
> height to the "todo" keyword when the `org-todo' face does not define a
> `:height' of its own.  Otherwise it would refrain from overriding that
> attribute.
>
> Does the community know of a solution to this issue?
>
> I am running:
>
> * Org mode version 9.3.
>
> * GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.17,
>   cairo version 1.17.3) of 2020-04-20.
>
> Best regards,
> Protesilaos
>
>
> -- 
> Protesilaos Stavrou
> protesilaos.com
>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg


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

* Re: Adaptive Org faces in headings?
  2020-04-26  5:16 Adaptive Org faces in headings? Protesilaos Stavrou
  2020-04-26  7:42 ` Ihor Radchenko
@ 2020-09-05 14:47 ` Bastien
  2020-09-06 19:58   ` Protesilaos Stavrou
  2020-09-05 21:39 ` Diego Zamboni
  2 siblings, 1 reply; 21+ messages in thread
From: Bastien @ 2020-09-05 14:47 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: emacs-orgmode

Dear Protesilaos,

thank you very much for your feedback.  Could you insert a small
picture showing where faces customization don't interact nicely,
e.g. when using different heights for org-todo org-level-1?

It would help deciding whether this is an issue for Org or for
Emacs in general regarding faces interaction.

Thanks in advance!

-- 
 Bastien


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

* Re: Adaptive Org faces in headings?
  2020-04-26  5:16 Adaptive Org faces in headings? Protesilaos Stavrou
  2020-04-26  7:42 ` Ihor Radchenko
  2020-09-05 14:47 ` Bastien
@ 2020-09-05 21:39 ` Diego Zamboni
  2020-09-07  4:08   ` Protesilaos Stavrou
  2 siblings, 1 reply; 21+ messages in thread
From: Diego Zamboni @ 2020-09-05 21:39 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: Org-mode

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

Hi Protesilaos,

I had seen the same in my setup. I recently started using Doom Emacs (
https://github.com/hlissner/doom-emacs/) and was pleasantly surprised to
discover that todo and tag faces scale according to the headline in which
they are. I don't know precisely how this is done, but there are some hints
here, you might use it as a starting point:
https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/org/config.el#L146-L175

(tangentially: I am very happy with Doom Emacs. After 30+ years of
handcrafting my Emacs config, I decided to give it a try and I can highly
recommend it).

--Diego


On Sun, Apr 26, 2020 at 9:01 AM Protesilaos Stavrou <info@protesilaos.com>
wrote:

> Dear all,
>
> I have noticed that Org faces that combine with headings do not adapt to
> their context.  This applies to keywords, priority cookies, links, and
> possibly other elements as well.
>
> For example, a "todo" keyword (`org-todo' face) will not scale in size
> to match that of the heading level (`org-level-N' face) if the latter
> uses a `:height' property.  Same principle for keywords not inheriting
> the heading's background, overline, etc.
>
> My expectation is to allow `org-level-N' to pass its attributes to any
> element on the same line, unless that element has conflicting face
> attributes of its own.  So, in my example, the heading could pass its
> height to the "todo" keyword when the `org-todo' face does not define a
> `:height' of its own.  Otherwise it would refrain from overriding that
> attribute.
>
> Does the community know of a solution to this issue?
>
> I am running:
>
> * Org mode version 9.3.
>
> * GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.17,
>   cairo version 1.17.3) of 2020-04-20.
>
> Best regards,
> Protesilaos
>
>
> --
> Protesilaos Stavrou
> protesilaos.com
>
>

[-- Attachment #2: Type: text/html, Size: 2686 bytes --]

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

* Re: Adaptive Org faces in headings?
  2020-09-05 14:47 ` Bastien
@ 2020-09-06 19:58   ` Protesilaos Stavrou
  0 siblings, 0 replies; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-09-06 19:58 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

Hello Bastien!

Bastien <bzg@gnu.org> [2020-09-05, 16:47 +0200]:

>  Could you insert a small picture showing where faces customization
> don't interact nicely, e.g. when using different heights for org-todo
> org-level-1?

Please see attached.  This is on 'emacs -Q'.  What I did:

- C-x C-f test.org
- C-x 2
- C-x b *scratch*
- Insert and then evaluate each of:
  + (set-face-attribute 'org-level-1 nil :height 2.0)
  + (set-face-attribute 'org-level-2 nil :background "#e0e0e0" :height 1.5)
- C-x o
- Insert some headings:
  + * TODO [#A] This is a test                                              :tag:
  + ** TODO [#A] This is a test                                             :tag:
  + * [[https://www.gnu.org/][links also]] This is a test                   :tag:

> It would help deciding whether this is an issue for Org or for
> Emacs in general regarding faces interaction.

The feedback I have received thus far suggests that it may have to do
with how Org configures its font locking in org-set-font-lock-defaults.

In particular:

1. The org-tag has an OVERRIDE argument in the form of 'prepend'
   https://code.orgmode.org/bzg/org-mode/src/5417e384ebab58e560fe6a80eee7bc58b1ef8645/lisp/org.el#L5625

   So it is merged with the underlying face, as shown in the screenshot.

2. While keywords have a 't' argument which overrules the underlying
   face (it would behave the same as tags with 'prepend'):
   https://code.orgmode.org/bzg/org-mode/src/5417e384ebab58e560fe6a80eee7bc58b1ef8645/lisp/org.el#L5647

Not sure about priority cookies and links.

This is what I have for now.  Thank you for looking into this!

My system details:

- GNU Emacs 27.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.22,
  cairo version 1.17.3) of 2020-08-14

- Org mode version 9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)

Best regards
Protesilaos

-- 
Protesilaos Stavrou
protesilaos.com

[-- Attachment #2: Screenshot from 2020-09-05 18-57-24.png --]
[-- Type: image/png, Size: 71161 bytes --]

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

* Re: Adaptive Org faces in headings?
  2020-09-05 21:39 ` Diego Zamboni
@ 2020-09-07  4:08   ` Protesilaos Stavrou
  2020-09-09  8:49     ` Bastien
  0 siblings, 1 reply; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-09-07  4:08 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode

Hello Diego,

Diego Zamboni <diego@zzamboni.org> [2020-09-05, 23:39 +0200]:

> I had seen the same in my setup. I recently started using Doom Emacs
> (https://github.com/hlissner/doom-emacs/) and was pleasantly surprised
> to discover that todo and tag faces scale according to the headline in
> which they are. I don't know precisely how this is done, but there are
> some hints here, you might use it as a starting point:
> https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/org/config.el#L146-L175

I noticed that the doom-themes have some extra code to fontify Org.[0]
It also has some opinionated extras that do not belong to the issue I
raised.  I am curious whether this was ever shared/discussed on this
mailing list.  It does not seem specific to Doom, so it be nice to have
it for the benefit of every user mutatis mutandis.

[0]: https://github.com/hlissner/emacs-doom-themes/blob/master/doom-themes-ext-org.el

-- 
Protesilaos Stavrou
protesilaos.com


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

* Re: Adaptive Org faces in headings?
  2020-09-07  4:08   ` Protesilaos Stavrou
@ 2020-09-09  8:49     ` Bastien
  2020-09-09  9:11       ` TEC
  2020-09-12  7:33       ` Protesilaos Stavrou
  0 siblings, 2 replies; 21+ messages in thread
From: Bastien @ 2020-09-09  8:49 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: Diego Zamboni, Org-mode

Hi Protesilaos,

Protesilaos Stavrou <info@protesilaos.com> writes:

> Diego Zamboni <diego@zzamboni.org> [2020-09-05, 23:39 +0200]:
>
>> I had seen the same in my setup. I recently started using Doom Emacs
>> (https://github.com/hlissner/doom-emacs/) and was pleasantly surprised
>> to discover that todo and tag faces scale according to the headline in
>> which they are. I don't know precisely how this is done, but there are
>> some hints here, you might use it as a starting point:
>> https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/org/config.el#L146-L175
>
> I noticed that the doom-themes have some extra code to fontify Org.[0]
> It also has some opinionated extras that do not belong to the issue I
> raised.  I am curious whether this was ever shared/discussed on this
> mailing list.

I can't remember any such discussion.

(In general, it would be good if downstream enhancements like these
could be shared upstream, we are generally quite grateful for help!)

In any case, thanks for reporting this issue, I confirm we should
work on it for a future release.

Patches welcome,

-- 
 Bastien


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

* Re: Adaptive Org faces in headings?
  2020-09-09  8:49     ` Bastien
@ 2020-09-09  9:11       ` TEC
  2020-09-09 14:44         ` Bastien
  2020-09-12  7:33       ` Protesilaos Stavrou
  1 sibling, 1 reply; 21+ messages in thread
From: TEC @ 2020-09-09  9:11 UTC (permalink / raw)
  To: Bastien; +Cc: Protesilaos Stavrou, emacs-orgmode, Diego Zamboni


Bastien <bzg@gnu.org> writes:

> (In general, it would be good if downstream enhancements like these
> could be shared upstream, we are generally quite grateful for help!)

From memory, Doom actually has a number of rather nice Org patches that
it hoards :P IIRC simply to avoid the effort of going through the patch
process, and have more flexibility (using Doom convenience macros, etc.).

See https://github.com/hlissner/doom-macs/blob/develop/modules/lang/org/config.el
for nice features like lazy loading babel language support.

There are a number of contributors, but if you look at the blame
(https://github.com/hlissner/doom-emacs/blame/develop/modules/lang/org/config.el)
you can see that it looks like everyone other than Henrik (hlissner) has
only made what we'd call TINYCHANGEs.

--
 Timothy.


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

* Re: Adaptive Org faces in headings?
  2020-09-09  9:11       ` TEC
@ 2020-09-09 14:44         ` Bastien
  0 siblings, 0 replies; 21+ messages in thread
From: Bastien @ 2020-09-09 14:44 UTC (permalink / raw)
  To: TEC; +Cc: Protesilaos Stavrou, emacs-orgmode, Diego Zamboni

Hi Timothy,

TEC <tecosaur@gmail.com> writes:

> From memory, Doom actually has a number of rather nice Org patches that
> it hoards :P IIRC simply to avoid the effort of going through the patch
> process, and have more flexibility (using Doom convenience macros, etc.).
>
> See https://github.com/hlissner/doom-macs/blob/develop/modules/lang/org/config.el
> for nice features like lazy loading babel language support.
>
> There are a number of contributors, but if you look at the blame
> (https://github.com/hlissner/doom-emacs/blame/develop/modules/lang/org/config.el)
> you can see that it looks like everyone other than Henrik (hlissner) has
> only made what we'd call TINYCHANGEs.

We do encourage early upstream contributions exactly because of this
issue: when downstream (or distinct) projects accumulate changes made 
with no clear copyright assignment, we cannot integrate these changes
upstream, because of these copyright uncertainty.

-- 
 Bastien


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

* Re: Adaptive Org faces in headings?
  2020-09-09  8:49     ` Bastien
  2020-09-09  9:11       ` TEC
@ 2020-09-12  7:33       ` Protesilaos Stavrou
  2020-09-17  8:25         ` [PATCH] " Ihor Radchenko
  1 sibling, 1 reply; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-09-12  7:33 UTC (permalink / raw)
  To: Bastien; +Cc: Diego Zamboni, Org-mode

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

Bastien <bzg@gnu.org> [2020-09-09, 10:49 +0200]:

> Protesilaos Stavrou <info@protesilaos.com> writes:
>
>> Diego Zamboni <diego@zzamboni.org> [2020-09-05, 23:39 +0200]:
>>
>>> I had seen the same in my setup. I recently started using Doom Emacs
>>> (https://github.com/hlissner/doom-emacs/) and was pleasantly surprised
>>> to discover that todo and tag faces scale according to the headline in
>>> which they are. I don't know precisely how this is done, but there are
>>> some hints here, you might use it as a starting point:
>>> https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/org/config.el#L146-L175
>>
>> I noticed that the doom-themes have some extra code to fontify Org.[0]
>> It also has some opinionated extras that do not belong to the issue I
>> raised.  I am curious whether this was ever shared/discussed on this
>> mailing list.
>
> I can't remember any such discussion.
>
> (In general, it would be good if downstream enhancements like these
> could be shared upstream, we are generally quite grateful for help!)
>
> In any case, thanks for reporting this issue, I confirm we should
> work on it for a future release.
>
> Patches welcome,

Hello again!

I am not sure I can help with the patch, but at least I can share some
more user feedback.

Please see the attached screenshots that could help improve our
understanding of the issue.  The gist is that Org already has working
code that adapts some faces to the underlying heading style (in this
case font height and weight).

To reproduce this demo on emacs -Q:

+ Open an org-mode file, e.g. C-x C-f /tmp/test.org
+ Insert a level 1 heading:

  * TODO [#A] Do they adapt ~test-heading-faces~ and =another-test=?

+ Evaluate each of the expressions in the code block and notice how the
  heading's faces adapt to it:

#+begin_src emacs-lisp
(set-face-attribute 'org-level-1 nil :height 3.0 :weight 'normal)
(set-face-attribute 'org-level-1 nil :weight 'bold)
#+end_src

This is in addition to what I noted in a previous message:
https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00331.html

Best regards,
Protesilaos

-- 
Protesilaos Stavrou
protesilaos.com


[-- Attachment #2: org-faces-adapt-heading-height.png --]
[-- Type: image/png, Size: 51517 bytes --]

[-- Attachment #3: org-faces-adapt-heading-weight.png --]
[-- Type: image/png, Size: 50806 bytes --]

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

* [PATCH] Adaptive Org faces in headings?
  2020-09-12  7:33       ` Protesilaos Stavrou
@ 2020-09-17  8:25         ` Ihor Radchenko
  2020-09-18  9:52           ` Protesilaos Stavrou
                             ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Ihor Radchenko @ 2020-09-17  8:25 UTC (permalink / raw)
  To: Protesilaos Stavrou, Bastien; +Cc: Diego Zamboni, Org-mode

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

The attached patch seems to fix the issue.
Can anyone test?

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-sure-that-headline-faces-take-precedence.patch --]
[-- Type: text/x-diff, Size: 5818 bytes --]

From 7a5bfe2f514af1f6af48652155732dbcb9fe22d0 Mon Sep 17 00:00:00 2001
From: Ihor Radchenko <yantar92@gmail.com>
Date: Thu, 17 Sep 2020 16:14:11 +0800
Subject: [PATCH] Make sure that headline faces take precedence

* lisp/org.el (org-activate-links): Prepend instead of overriding
existing face.
(org-set-font-lock-defaults): Prepend keyword, `org-headline-todo', and
`org-headline-done' faces instead of overriding.
(org-font-lock-add-priority-faces): Prepend priority face instead of
overriding.
(org-font-lock-add-tag-faces): Prepend tag faces instead of
overriding.

Fix bug when org-level-N headline face is overridden while fontifying
smaller elements within headline.  Prepend the element faces instead.
---
 lisp/org.el | 62 ++++++++++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index bc74cedc7..69040a540 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5142,30 +5142,31 @@ This includes angle, plain, and bracket links."
 		 (link (org-element-property :raw-link link-object))
 		 (type (org-element-property :type link-object))
 		 (path (org-element-property :path link-object))
+                 (face-property (pcase (org-link-get-parameter type :face)
+				  ((and (pred functionp) face) (funcall face path))
+				  ((and (pred facep) face) face)
+				  ((and (pred consp) face) face) ;anonymous
+				  (_ 'org-link)))
 		 (properties		;for link's visible part
-		  (list
-		   'face (pcase (org-link-get-parameter type :face)
-			   ((and (pred functionp) face) (funcall face path))
-			   ((and (pred facep) face) face)
-			   ((and (pred consp) face) face) ;anonymous
-			   (_ 'org-link))
-		   'mouse-face (or (org-link-get-parameter type :mouse-face)
-				   'highlight)
-		   'keymap (or (org-link-get-parameter type :keymap)
-			       org-mouse-map)
-		   'help-echo (pcase (org-link-get-parameter type :help-echo)
-				((and (pred stringp) echo) echo)
-				((and (pred functionp) echo) echo)
-				(_ (concat "LINK: " link)))
-		   'htmlize-link (pcase (org-link-get-parameter type
-								:htmlize-link)
-				   ((and (pred functionp) f) (funcall f))
-				   (_ `(:uri ,link)))
-		   'font-lock-multiline t)))
+		  (list 'mouse-face (or (org-link-get-parameter type :mouse-face)
+					'highlight)
+			'keymap (or (org-link-get-parameter type :keymap)
+				    org-mouse-map)
+			'help-echo (pcase (org-link-get-parameter type :help-echo)
+				     ((and (pred stringp) echo) echo)
+				     ((and (pred functionp) echo) echo)
+				     (_ (concat "LINK: " link)))
+			'htmlize-link (pcase (org-link-get-parameter type
+								  :htmlize-link)
+					((and (pred functionp) f) (funcall f))
+					(_ `(:uri ,link)))
+			'font-lock-multiline t)))
 	    (org-remove-flyspell-overlays-in start end)
 	    (org-rear-nonsticky-at end)
 	    (if (not (eq 'bracket style))
-		(add-text-properties start end properties)
+		(progn
+                  (add-face-text-property start end face-property)
+		  (add-text-properties start end properties))
 	      ;; Handle invisible parts in bracket links.
 	      (remove-text-properties start end '(invisible nil))
 	      (let ((hidden
@@ -5174,6 +5175,7 @@ This includes angle, plain, and bracket links."
 				    'org-link))
 			     properties)))
 		(add-text-properties start visible-start hidden)
+                (add-face-text-property visible-start visible-end face-property)
 		(add-text-properties visible-start visible-end properties)
 		(add-text-properties visible-end end hidden)
 		(org-rear-nonsticky-at visible-start)
@@ -5641,7 +5643,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	   ;; TODO keyword
 	   (list (format org-heading-keyword-regexp-format
 			 org-todo-regexp)
-		 '(2 (org-get-todo-face 2) t))
+		 '(2 (org-get-todo-face 2) prepend))
 	   ;; TODO
 	   (when org-fontify-todo-headline
 	     (list (format org-heading-keyword-regexp-format
@@ -5649,7 +5651,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 			    "\\(?:"
 			    (mapconcat 'regexp-quote org-not-done-keywords "\\|")
 			    "\\)"))
-		   '(2 'org-headline-todo t)))
+		   '(2 'org-headline-todo prepend)))
 	   ;; DONE
 	   (when org-fontify-done-headline
 	     (list (format org-heading-keyword-regexp-format
@@ -5657,7 +5659,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 			    "\\(?:"
 			    (mapconcat 'regexp-quote org-done-keywords "\\|")
 			    "\\)"))
-		   '(2 'org-headline-done t)))
+		   '(2 'org-headline-done prepend)))
 	   ;; Priorities
 	   '(org-font-lock-add-priority-faces)
 	   ;; Tags
@@ -5841,18 +5843,24 @@ If TAG is a number, get the corresponding match group."
 (defun org-font-lock-add-priority-faces (limit)
   "Add the special priority faces."
   (while (re-search-forward org-priority-regexp limit t)
+    (add-face-text-property
+     (match-beginning 1)
+     (match-end 1)
+     (org-get-priority-face (string-to-char (match-string 2))))
     (add-text-properties
      (match-beginning 1) (match-end 1)
-     (list 'face (org-get-priority-face (string-to-char (match-string 2)))
-	   'font-lock-fontified t))))
+     (list 'font-lock-fontified t))))
 
 (defun org-font-lock-add-tag-faces (limit)
   "Add the special tag faces."
   (when (and org-tag-faces org-tags-special-faces-re)
     (while (re-search-forward org-tags-special-faces-re limit t)
+      (add-face-text-property
+       (match-beginning 1)
+       (match-end 1)
+       (org-get-tag-face 1))
       (add-text-properties (match-beginning 1) (match-end 1)
-			   (list 'face (org-get-tag-face 1)
-				 'font-lock-fontified t))
+			   (list 'font-lock-fontified t))
       (backward-char 1))))
 
 (defun org-unfontify-region (beg end &optional _maybe_loudly)
-- 
2.26.2


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




Protesilaos Stavrou <info@protesilaos.com> writes:

> Bastien <bzg@gnu.org> [2020-09-09, 10:49 +0200]:
>
>> Protesilaos Stavrou <info@protesilaos.com> writes:
>>
>>> Diego Zamboni <diego@zzamboni.org> [2020-09-05, 23:39 +0200]:
>>>
>>>> I had seen the same in my setup. I recently started using Doom Emacs
>>>> (https://github.com/hlissner/doom-emacs/) and was pleasantly surprised
>>>> to discover that todo and tag faces scale according to the headline in
>>>> which they are. I don't know precisely how this is done, but there are
>>>> some hints here, you might use it as a starting point:
>>>> https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/org/config.el#L146-L175
>>>
>>> I noticed that the doom-themes have some extra code to fontify Org.[0]
>>> It also has some opinionated extras that do not belong to the issue I
>>> raised.  I am curious whether this was ever shared/discussed on this
>>> mailing list.
>>
>> I can't remember any such discussion.
>>
>> (In general, it would be good if downstream enhancements like these
>> could be shared upstream, we are generally quite grateful for help!)
>>
>> In any case, thanks for reporting this issue, I confirm we should
>> work on it for a future release.
>>
>> Patches welcome,
>
> Hello again!
>
> I am not sure I can help with the patch, but at least I can share some
> more user feedback.
>
> Please see the attached screenshots that could help improve our
> understanding of the issue.  The gist is that Org already has working
> code that adapts some faces to the underlying heading style (in this
> case font height and weight).
>
> To reproduce this demo on emacs -Q:
>
> + Open an org-mode file, e.g. C-x C-f /tmp/test.org
> + Insert a level 1 heading:
>
>   * TODO [#A] Do they adapt ~test-heading-faces~ and =another-test=?
>
> + Evaluate each of the expressions in the code block and notice how the
>   heading's faces adapt to it:
>
> #+begin_src emacs-lisp
> (set-face-attribute 'org-level-1 nil :height 3.0 :weight 'normal)
> (set-face-attribute 'org-level-1 nil :weight 'bold)
> #+end_src
>
> This is in addition to what I noted in a previous message:
> https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00331.html
>
> Best regards,
> Protesilaos
>
> -- 
> Protesilaos Stavrou
> protesilaos.com

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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-17  8:25         ` [PATCH] " Ihor Radchenko
@ 2020-09-18  9:52           ` Protesilaos Stavrou
  2020-09-20  3:24             ` Sheng Yang
  2020-09-21 16:05           ` Mikhail Skorzhinskii
  2020-09-23 12:25           ` Bastien
  2 siblings, 1 reply; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-09-18  9:52 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Bastien, Protesilaos Stavrou, Org-mode, Diego Zamboni

Ihor Radchenko <yantar92@gmail.com> [2020-09-17, 16:25 +0800]:

> The attached patch seems to fix the issue.
> Can anyone test?

I just tried this using the standard faces of 'emacs -Q' as well as
custom themes.

In short, the patch fixes the issue on my side.  I tested whether faces
on the headline would correctly inherit any of the following properties:

+ :height
+ :weight
+ :background
+ :overline

I also tested it with 'variable-pitch' headlines and, again, every
construct that does not have a font family explicitly assigned to it
will adapt to the underlying heading.  Excellent!

This is the kind of headline I tried:

     * TODO [#A] This is a test ~scaling-elements~ =faces-adapt= :good-stuff:

Also added links to confirm my findings.  Again, all good.

-- 
Protesilaos Stavrou
protesilaos.com


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-18  9:52           ` Protesilaos Stavrou
@ 2020-09-20  3:24             ` Sheng Yang
  0 siblings, 0 replies; 21+ messages in thread
From: Sheng Yang @ 2020-09-20  3:24 UTC (permalink / raw)
  To: Protesilaos Stavrou, Ihor Radchenko; +Cc: Bastien, Diego Zamboni, Org-mode

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

Thanks for the patch!
I noticed the patch also works for org-link, which had been a headache for me.

On Fri, Sep 18, 2020, at 04:52, Protesilaos Stavrou wrote:
> Ihor Radchenko <yantar92@gmail.com> [2020-09-17, 16:25 +0800]:
> 
> > The attached patch seems to fix the issue.
> > Can anyone test?

I also tested, with the following org file. Works well with one exception: the underline for org-link, which remains the color of itself. The reason is that face org-link inherits face link, which has :underline t in its setting. Therefore, it should be the expected behavior.
> * test ~code~ =verb= [[link]]
>   #+begin_src emacs-lisp
> (set-face-attribute 'org-level-1 nil :height 3.0 :weight 'normal)
> (set-face-attribute 'org-level-1 nil :weight 'bold)
> (set-face-attribute 'org-level-1 nil :background "white")
> (set-face-attribute 'org-level-1 nil :overline "yellow")
> (set-face-attribute 'org-level-1 nil :underline "red")
>   #+end_src


Sheng Yang(杨圣), PhD student
Computer Science Department
University of Maryland, College Park
E-mail: styang@fastmail.com
E-mail (old but still used): yangsheng6810@gmail.com


[-- Attachment #2: Type: text/html, Size: 1925 bytes --]

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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-17  8:25         ` [PATCH] " Ihor Radchenko
  2020-09-18  9:52           ` Protesilaos Stavrou
@ 2020-09-21 16:05           ` Mikhail Skorzhinskii
  2020-09-23 12:25           ` Bastien
  2 siblings, 0 replies; 21+ messages in thread
From: Mikhail Skorzhinskii @ 2020-09-21 16:05 UTC (permalink / raw)
  To: Protesilaos Stavrou, Bastien, emacs-orgmode
  Cc: Diego Zamboni, Org-mode, Ihor Radchenko

Hi,

I've also tried to apply this patch and see if it will work on my, heavily 
customized in terms of theming, setup. It didn't spot any new issues. Instead 
it fixed face inheritance bugs with following elements:

1. Tags with customised faces;
2. Links;
3. Ellipsis;
4. TODO keywords;
5. Priority cookies;

Thank you all for you work!

Mikhail Skorzhinskii

On Thursday, September 17, 2020 10:25:17 AM CEST Ihor Radchenko wrote:
> The attached patch seems to fix the issue.
> Can anyone test?
> 
> Best,
> Ihor






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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-17  8:25         ` [PATCH] " Ihor Radchenko
  2020-09-18  9:52           ` Protesilaos Stavrou
  2020-09-21 16:05           ` Mikhail Skorzhinskii
@ 2020-09-23 12:25           ` Bastien
  2020-09-23 12:28             ` Protesilaos Stavrou
  2020-09-26  6:31             ` Bastien
  2 siblings, 2 replies; 21+ messages in thread
From: Bastien @ 2020-09-23 12:25 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Protesilaos Stavrou, Org-mode, Diego Zamboni

Ihor Radchenko <yantar92@gmail.com> writes:

> The attached patch seems to fix the issue.

Applied as 979e82fc3, thanks a lot!

-- 
 Bastien


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-23 12:25           ` Bastien
@ 2020-09-23 12:28             ` Protesilaos Stavrou
  2020-09-26  6:31             ` Bastien
  1 sibling, 0 replies; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-09-23 12:28 UTC (permalink / raw)
  To: Bastien; +Cc: Org-mode, Protesilaos Stavrou, Diego Zamboni, Ihor Radchenko

Bastien <bzg@gnu.org> [2020-09-23, 14:25 +0200]:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> The attached patch seems to fix the issue.
>
> Applied as 979e82fc3, thanks a lot!

Good news!  Thanks to everyone for their contributions!

-- 
Protesilaos Stavrou
protesilaos.com


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-23 12:25           ` Bastien
  2020-09-23 12:28             ` Protesilaos Stavrou
@ 2020-09-26  6:31             ` Bastien
  2020-10-05 10:11               ` Protesilaos Stavrou
  1 sibling, 1 reply; 21+ messages in thread
From: Bastien @ 2020-09-26  6:31 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Protesilaos Stavrou, Org-mode, Diego Zamboni

Bastien <bzg@gnu.org> writes:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> The attached patch seems to fix the issue.
>
> Applied as 979e82fc3, thanks a lot!

Also, marking the initial bug report as closed, thanks again.

-- 
 Bastien


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-09-26  6:31             ` Bastien
@ 2020-10-05 10:11               ` Protesilaos Stavrou
  2020-10-07  4:20                 ` Kyle Meyer
  0 siblings, 1 reply; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-10-05 10:11 UTC (permalink / raw)
  To: Bastien; +Cc: Org-mode, Ihor Radchenko

On 2020-09-26, 08:31 +0200, Bastien <bzg@gnu.org> wrote:

> Bastien <bzg@gnu.org> writes:
>
>> Ihor Radchenko <yantar92@gmail.com> writes:
>>
>>> The attached patch seems to fix the issue.
>>
>> Applied as 979e82fc3, thanks a lot!
>
> Also, marking the initial bug report as closed, thanks again.

Sorry to re-open this issue.  The following change extends Ihor's patch
to also cover checkbox statistics.  Seems to work just fine on my end.
Thanks again!


#+begin_src diff
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..23c86ba0c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5684,7 +5684,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	     1 'org-checkbox prepend)
 	   (when (cdr (assq 'checkbox org-list-automatic-rules))
 	     '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
-	       (0 (org-get-checkbox-statistics-face) t)))
+	       (0 (org-get-checkbox-statistics-face) prepend)))
 	   ;; Description list items
 	   '("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
 	     1 'org-list-dt prepend)
#+end_src

-- 
Protesilaos Stavrou
protesilaos.com


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-10-05 10:11               ` Protesilaos Stavrou
@ 2020-10-07  4:20                 ` Kyle Meyer
  2020-10-07  5:29                   ` Protesilaos Stavrou
  0 siblings, 1 reply; 21+ messages in thread
From: Kyle Meyer @ 2020-10-07  4:20 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: Bastien, Org-mode, Ihor Radchenko

Protesilaos Stavrou writes:

> Sorry to re-open this issue.  The following change extends Ihor's patch
> to also cover checkbox statistics.  Seems to work just fine on my end.
> Thanks again!

Thanks for the patch.  Looks good on my end too.

Would you mind adding a commit message and sending the git-format-patch
output (details at <https://orgmode.org/worg/org-contribute.html>)?


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-10-07  4:20                 ` Kyle Meyer
@ 2020-10-07  5:29                   ` Protesilaos Stavrou
  2020-10-08  3:37                     ` Kyle Meyer
  0 siblings, 1 reply; 21+ messages in thread
From: Protesilaos Stavrou @ 2020-10-07  5:29 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Bastien, Org-mode, Ihor Radchenko

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

On 2020-10-07, 00:20 -0400, Kyle Meyer <kyle@kyleam.com> wrote:

> Protesilaos Stavrou writes:
>
>> Sorry to re-open this issue.  The following change extends Ihor's patch
>> to also cover checkbox statistics.  Seems to work just fine on my end.
>> Thanks again!
>
> Thanks for the patch.  Looks good on my end too.
>
> Would you mind adding a commit message and sending the git-format-patch
> output (details at <https://orgmode.org/worg/org-contribute.html>)?

Tried to format the patch.  Please see the attached file.  If it does
not work, feel free to dismiss it and just apply the change yourself.

-- 
Protesilaos Stavrou
protesilaos.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-headline-faces-precede-checkbox-statistics.patch --]
[-- Type: text/x-patch, Size: 1172 bytes --]

From 6fc8c6f2c5c81402e2d4a5416b68d8d595f7aaee Mon Sep 17 00:00:00 2001
From: Protesilaos Stavrou <info@protesilaos.com>
Date: Wed, 7 Oct 2020 08:04:24 +0300
Subject: [PATCH] Make headline faces precede checkbox statistics

* lisp/org.el (org-set-font-lock-defaults): Apply `prepend' to
checkbox statistics.  Affects `org-checkbox-statistics-done' and
`org-checkbox-statistics-todo'.

This builds on commit 979e82fc3: org-level-N faces are no longer
overridden by elements placed on top of them.
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..23c86ba0c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5684,7 +5684,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	     1 'org-checkbox prepend)
 	   (when (cdr (assq 'checkbox org-list-automatic-rules))
 	     '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
-	       (0 (org-get-checkbox-statistics-face) t)))
+	       (0 (org-get-checkbox-statistics-face) prepend)))
 	   ;; Description list items
 	   '("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
 	     1 'org-list-dt prepend)
-- 
2.28.0


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

* Re: [PATCH] Adaptive Org faces in headings?
  2020-10-07  5:29                   ` Protesilaos Stavrou
@ 2020-10-08  3:37                     ` Kyle Meyer
  0 siblings, 0 replies; 21+ messages in thread
From: Kyle Meyer @ 2020-10-08  3:37 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: Bastien, Org-mode, Ihor Radchenko

Protesilaos Stavrou writes:

> Tried to format the patch.  Please see the attached file.  If it does
> not work, feel free to dismiss it and just apply the change yourself.

Looks good.  Applied (23f9415c6).

Thanks.


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

end of thread, other threads:[~2020-10-08  3:37 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26  5:16 Adaptive Org faces in headings? Protesilaos Stavrou
2020-04-26  7:42 ` Ihor Radchenko
2020-09-05 14:47 ` Bastien
2020-09-06 19:58   ` Protesilaos Stavrou
2020-09-05 21:39 ` Diego Zamboni
2020-09-07  4:08   ` Protesilaos Stavrou
2020-09-09  8:49     ` Bastien
2020-09-09  9:11       ` TEC
2020-09-09 14:44         ` Bastien
2020-09-12  7:33       ` Protesilaos Stavrou
2020-09-17  8:25         ` [PATCH] " Ihor Radchenko
2020-09-18  9:52           ` Protesilaos Stavrou
2020-09-20  3:24             ` Sheng Yang
2020-09-21 16:05           ` Mikhail Skorzhinskii
2020-09-23 12:25           ` Bastien
2020-09-23 12:28             ` Protesilaos Stavrou
2020-09-26  6:31             ` Bastien
2020-10-05 10:11               ` Protesilaos Stavrou
2020-10-07  4:20                 ` Kyle Meyer
2020-10-07  5:29                   ` Protesilaos Stavrou
2020-10-08  3:37                     ` Kyle Meyer

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git