emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug#42184: org-fontify-whole-*-line in emacs 27
Date: Fri, 07 Aug 2020 11:26:59 +0200	[thread overview]
Message-ID: <87o8nmq00s.fsf@gmail.com> (raw)
In-Reply-To: <87d043thcr.fsf@kyleam.com> (Kyle Meyer's message of "Thu, 06 Aug 2020 20:44:20 -0400")

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

Kyle Meyer <kyle@kyleam.com> writes:

> Kévin Le Gouguec writes:
>
>> Since 27.1-rc1 is out, I'd like to bump this; it'd be a shame if 27.1
>> shipped with this bug, which seems to be getting some attention (I just
>> spotted a Reddit thread[1] about it, in addition to the original report
>> on Debbugs).
>
> In the associated emacs-bug thread, Eli said that ship has sailed.  With
> the possibility of making it into 27.1 out of the picture, I think this
> patch should be made against the Org repo, as usual.
>
> As I said in the emacs-bug thread, the patch (which you also included
> upstream in this thread) looks fine to me.  If you'd prefer to bundle
> your org-block change in the same patch, could you send an updated patch
> here against the Org repo?

I've just noticed that my patch for org-block (bug#42184#44) was missing
a compatibility shim for Emacs<27; here are updated patches against
maint and master:


[-- Attachment #2: maint.patch --]
[-- Type: text/x-patch, Size: 3171 bytes --]

From 6ca21259589e212452411acd4ac2de3258ede508 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Fri, 7 Aug 2020 11:04:53 +0200
Subject: [PATCH] Fix org-fontify-whole-*-line by setting face extension
 (bug#42184)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-faces.el (org-block): Set background extension beyond
end-of-line.
* lisp/org-compat.el (org--extended-face): New function to add :extend
attribute to face definition for Emacs≥27.
(org--set-faces-extend): New function to temporarily (re)set :extend
for Emacs≥27.
* lisp/org.el (org-mode): Call it to set the extend attribute of
relevant faces to the correct value.
---
 lisp/org-compat.el | 15 +++++++++++++++
 lisp/org-faces.el  |  2 +-
 lisp/org.el        |  6 +++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index c757355ba..c0f4833a3 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -101,6 +101,21 @@ is nil)."
   (defun org-time-convert-to-list (time)
     (seconds-to-time (float-time time))))
 
+(defmacro org--extended-face (attributes)
+  "Make face that extends beyond end of line.
+
+Up to Emacs 26, all faces extended beyond end of line; getting
+the same behaviour starting with Emacs 27 requires :extend t."
+  `(nconc ,attributes (when (>= emacs-major-version 27) '(:extend t))))
+
+(defun org--set-faces-extend (faces extend-p)
+  "Set the :extend attribute of FACES to EXTEND-P.
+
+This is a no-op for Emacs versions lower than 27, since face
+extension beyond end of line was not controllable."
+  (when (fboundp 'set-face-extend)
+    (mapc (lambda (f) (set-face-extend f extend-p)) faces)))
+
 \f
 ;;; Emacs < 26.1 compatibility
 
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 30eab9bc6..4c5a51624 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -393,7 +393,7 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
   "Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
   :group 'org-faces)
 
-(defface org-block '((t :inherit shadow))
+(defface org-block `((t ,(org--extended-face '(:inherit shadow))))
   "Face text in #+begin ... #+end blocks.
 For source-blocks `org-src-block-faces' takes precedence."
   :group 'org-faces
diff --git a/lisp/org.el b/lisp/org.el
index 007dd6e2a..34c0235c1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4940,7 +4940,11 @@ The following commands are available:
   ;; Try to set `org-hide' face correctly.
   (let ((foreground (org-find-invisible-foreground)))
     (when foreground
-      (set-face-foreground 'org-hide 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)
+  (org--set-faces-extend org-level-faces org-fontify-whole-heading-line))
 
 ;; Update `customize-package-emacs-version-alist'
 (add-to-list 'customize-package-emacs-version-alist
-- 
2.28.0


[-- Attachment #3: master.patch --]
[-- Type: text/x-patch, Size: 3175 bytes --]

From 715927aa2f1baae32040e52d2cfca4aef2edc14b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Fri, 7 Aug 2020 11:04:53 +0200
Subject: [PATCH] Fix org-fontify-whole-*-line by setting face extension
 (bug#42184)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-faces.el (org-block): Set background extension beyond
end-of-line.
* lisp/org-compat.el (org--extended-face): New function to add :extend
attribute to face definition for Emacs≥27.
(org--set-faces-extend): New function to temporarily (re)set :extend
for Emacs≥27.
* lisp/org.el (org-mode): Call it to set the extend attribute of
relevant faces to the correct value.
---
 lisp/org-compat.el | 15 +++++++++++++++
 lisp/org-faces.el  |  2 +-
 lisp/org.el        |  6 +++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 5953f89d2..a9cf400a7 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -109,6 +109,21 @@ is nil)."
       (newline-and-indent))
   (defalias 'org-newline-and-indent #'newline-and-indent))
 
+(defmacro org--extended-face (attributes)
+  "Make face that extends beyond end of line.
+
+Up to Emacs 26, all faces extended beyond end of line; getting
+the same behaviour starting with Emacs 27 requires :extend t."
+  `(nconc ,attributes (when (>= emacs-major-version 27) '(:extend t))))
+
+(defun org--set-faces-extend (faces extend-p)
+  "Set the :extend attribute of FACES to EXTEND-P.
+
+This is a no-op for Emacs versions lower than 27, since face
+extension beyond end of line was not controllable."
+  (when (fboundp 'set-face-extend)
+    (mapc (lambda (f) (set-face-extend f extend-p)) faces)))
+
 \f
 ;;; Emacs < 26.1 compatibility
 
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index d78b606ec..0c7de38ff 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -408,7 +408,7 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
   "Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
   :group 'org-faces)
 
-(defface org-block '((t :inherit shadow))
+(defface org-block `((t ,(org--extended-face '(:inherit shadow))))
   "Face text in #+begin ... #+end blocks.
 For source-blocks `org-src-block-faces' takes precedence."
   :group 'org-faces
diff --git a/lisp/org.el b/lisp/org.el
index ee8be256d..d66977dd4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4904,7 +4904,11 @@ The following commands are available:
   ;; Try to set `org-hide' face correctly.
   (let ((foreground (org-find-invisible-foreground)))
     (when foreground
-      (set-face-foreground 'org-hide 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)
+  (org--set-faces-extend org-level-faces org-fontify-whole-heading-line))
 
 ;; Update `customize-package-emacs-version-alist'
 (add-to-list 'customize-package-emacs-version-alist
-- 
2.28.0


[-- Attachment #4: Type: text/plain, Size: 528 bytes --]


I don't think anyone has reviewed org--extended-face yet (I first
drafted it in bug#42184#17), so don't hesitate to call me out on it if
something looks off.  FWIW I saw no warnings when running "make" with
Emacs 26.3 nor with 28.

I made patches for both maint and master because

- the patch for maint has a small conflict in org-compat when applied
  against master,

- I'm not sure which branch will eventually be synchronized with
  emacs-27 (assuming we'll include this fix in 27.2).

Thank you for following up on this.

  reply	other threads:[~2020-08-07  9:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10  9:23 Couple of issues with org block meta lines faces Sébastien Miquel
2020-07-10 11:46 ` Kévin Le Gouguec
2020-07-14 10:19   ` Bug#42184: org-fontify-whole-*-line in emacs 27 (was: Couple of issues with org block meta lines faces) Kévin Le Gouguec
2020-08-02 21:23     ` Bug#42184: org-fontify-whole-*-line in emacs 27 Kévin Le Gouguec
2020-08-07  0:44       ` Kyle Meyer
2020-08-07  9:26         ` Kévin Le Gouguec [this message]
2020-08-09  4:43           ` Kyle Meyer
2020-08-09 14:12             ` Kévin Le Gouguec
2020-08-09 19:27               ` Kyle Meyer
2020-08-10 13:27                 ` Kévin Le Gouguec
2020-08-11  0:43                   ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8nmq00s.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    --subject='Re: Bug#42184: org-fontify-whole-*-line in emacs 27' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).