Subject: bug#37774: 27.0.50; new :extend attribute broke visuals of all themes and other packages

From: Kévin Le Gouguec <[email-masked]>
Date: Thu, 24 Oct 2019 19:04:31 +0200

Dmitry Gutov <[email-masked]> writes:

> Yeah, so: what's the plan for Magit?
>
> Will the new version of it have to
>
> (if <emacs version is...>
>     (defface ...)
>   (defface ...)
>
> ?

> We should define and document a "migration path", e.g. say what a
> package author should do if they have a face which needs to be
> extended, preferably without breaking compatibility with Emacs 26.

Earlier in the thread[1] I suggested this method to avoid the duplicate
defface issue:

--- magit-diff.el.bkp	2019-10-23 17:02:13.340410735 +0200
+++ magit-diff.el	2019-10-24 17:54:58.769446997 +0200
@@ -509,12 +509,14 @@
   :group 'magit-faces)
 
 (defface magit-diff-hunk-heading
-  '((((class color) (background light))
+  `((((class color) (background light))
      :background "grey80"
-     :foreground "grey30")
+     :foreground "grey30"
+     ,@(when (>= emacs-major-version 27) '(:extend t)))
     (((class color) (background dark))
      :background "grey25"
-     :foreground "grey70"))
+     :foreground "grey70"
+     ,@(when (>= emacs-major-version 27) '(:extend t))))
   "Face for diff hunk headings."
   :group 'magit-faces)

Would this be an acceptable migration path?  Magit requires Emacs≥25.1
if I am not mistaken; I don't know how portable this solution would be.

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37774#212
    AFAICT no-one outright rejected this idea; I apologize if I missed
    someone pointing out shortcomings.