unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits
@ 2023-05-01 13:15 Tobias Bading
  2023-05-01 18:32 ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Bading @ 2023-05-01 13:15 UTC (permalink / raw)
  To: 63204

1. emacs -Q

2. Imagine that in a previous Emacs session you have copied a string with
    text properties from a buffer in vc-annotate-mode, maybe also searched
    for it somewhere. IOW, your ~/.emacs.d/.emacs.desktop file may contain
    something like this:

    (setq some-search-ring-or-whatever
          '(#("heisenbug" 0 9 (face vc-annotate-face-CCCCFF))))

    Evaluate this expression to simulate a desktop-read of such a previous
    session.

3. Open lisp/vc/vc-annotate.el from the Git branch emacs-29.

4. C-x v g (vc-annotate)

5. There are lines with white background caused by the use of undefined face
    vc-annotate-face-CCCCFF. C-h e should contain:

    Invalid face reference: vc-annotate-face-CCCCFF

    If for whatever reason you don’t see these bad lines, use C-u C-x = to
    see what face a line uses and repeat these steps with this face instead
    of vc-annotate-face-CCCCFF.


This can be fixed with:

diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index 70057a6aac..ae8db021ad 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -724,7 +724,9 @@ vc-annotate-lines
                                        (substring (cdr color) 1)
                                      (cdr color))))
                 ;; Make the face if not done.
-               (face (or (intern-soft face-name)
+               (face (or (let ((sym (intern-soft face-name)))
+                           (if (facep sym)
+                               sym))
                           (let ((tmp-face (make-face (intern face-name))))
                             (set-face-extend tmp-face t)
                             (cond

My Emacs Lisp isn’t that great so please feel free to improve this code
if needed. The important part is that (intern-soft face-name) is not
sufficient to check whether a face exists.


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

* bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits
  2023-05-01 13:15 bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits Tobias Bading
@ 2023-05-01 18:32 ` Philip Kaludercic
  2023-05-01 18:50   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2023-05-01 18:32 UTC (permalink / raw)
  To: Tobias Bading; +Cc: 63204

Tobias Bading <tbading@web.de> writes:

> 1. emacs -Q
>
> 2. Imagine that in a previous Emacs session you have copied a string with
>    text properties from a buffer in vc-annotate-mode, maybe also searched
>    for it somewhere. IOW, your ~/.emacs.d/.emacs.desktop file may contain
>    something like this:
>
>    (setq some-search-ring-or-whatever
>          '(#("heisenbug" 0 9 (face vc-annotate-face-CCCCFF))))
>
>    Evaluate this expression to simulate a desktop-read of such a previous
>    session.
>
> 3. Open lisp/vc/vc-annotate.el from the Git branch emacs-29.
>
> 4. C-x v g (vc-annotate)
>
> 5. There are lines with white background caused by the use of undefined face
>    vc-annotate-face-CCCCFF. C-h e should contain:
>
>    Invalid face reference: vc-annotate-face-CCCCFF
>
>    If for whatever reason you don’t see these bad lines, use C-u C-x = to
>    see what face a line uses and repeat these steps with this face instead
>    of vc-annotate-face-CCCCFF.
>
>
> This can be fixed with:
>
> diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
> index 70057a6aac..ae8db021ad 100644
> --- a/lisp/vc/vc-annotate.el
> +++ b/lisp/vc/vc-annotate.el
> @@ -724,7 +724,9 @@ vc-annotate-lines
>                                        (substring (cdr color) 1)
>                                      (cdr color))))
>                 ;; Make the face if not done.
> -               (face (or (intern-soft face-name)
> +               (face (or (let ((sym (intern-soft face-name)))
> +                           (if (facep sym)
> +                               sym))

I'd write this as (and (facep sym) sym).

>                           (let ((tmp-face (make-face (intern face-name))))
>                             (set-face-extend tmp-face t)
>                             (cond
>
> My Emacs Lisp isn’t that great so please feel free to improve this code
> if needed. The important part is that (intern-soft face-name) is not
> sufficient to check whether a face exists.

I think a better solution would be to revise general approach
vc-annotate takes, and instead of hard-coding faces/colours to use (that
break when switching between light and dark themes), to have a list of
faces that could be used independently of vc-annotate.

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

* bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits
  2023-05-01 18:32 ` Philip Kaludercic
@ 2023-05-01 18:50   ` Eli Zaretskii
  2023-05-01 19:12     ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-05-01 18:50 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: tbading, 63204

> Cc: 63204@debbugs.gnu.org
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Mon, 01 May 2023 18:32:49 +0000
> 
> Tobias Bading <tbading@web.de> writes:
> 
> > 1. emacs -Q
> >
> > 2. Imagine that in a previous Emacs session you have copied a string with
> >    text properties from a buffer in vc-annotate-mode, maybe also searched
> >    for it somewhere. IOW, your ~/.emacs.d/.emacs.desktop file may contain
> >    something like this:
> >
> >    (setq some-search-ring-or-whatever
> >          '(#("heisenbug" 0 9 (face vc-annotate-face-CCCCFF))))
> >
> >    Evaluate this expression to simulate a desktop-read of such a previous
> >    session.
> >
> > 3. Open lisp/vc/vc-annotate.el from the Git branch emacs-29.
> >
> > 4. C-x v g (vc-annotate)
> >
> > 5. There are lines with white background caused by the use of undefined face
> >    vc-annotate-face-CCCCFF. C-h e should contain:
> >
> >    Invalid face reference: vc-annotate-face-CCCCFF
> >
> >    If for whatever reason you don’t see these bad lines, use C-u C-x = to
> >    see what face a line uses and repeat these steps with this face instead
> >    of vc-annotate-face-CCCCFF.
> >
> >
> > This can be fixed with:
> >
> > diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
> > index 70057a6aac..ae8db021ad 100644
> > --- a/lisp/vc/vc-annotate.el
> > +++ b/lisp/vc/vc-annotate.el
> > @@ -724,7 +724,9 @@ vc-annotate-lines
> >                                        (substring (cdr color) 1)
> >                                      (cdr color))))
> >                 ;; Make the face if not done.
> > -               (face (or (intern-soft face-name)
> > +               (face (or (let ((sym (intern-soft face-name)))
> > +                           (if (facep sym)
> > +                               sym))
> 
> I'd write this as (and (facep sym) sym).
> 
> >                           (let ((tmp-face (make-face (intern face-name))))
> >                             (set-face-extend tmp-face t)
> >                             (cond
> >
> > My Emacs Lisp isn’t that great so please feel free to improve this code
> > if needed. The important part is that (intern-soft face-name) is not
> > sufficient to check whether a face exists.
> 
> I think a better solution would be to revise general approach
> vc-annotate takes, and instead of hard-coding faces/colours to use (that
> break when switching between light and dark themes), to have a list of
> faces that could be used independently of vc-annotate.

We should probably do that on master, but for emacs-29 this is too
much of a churn, I think.  So for emacs-29, I think we should install
something like the proposed patch, just a bit cleaned-up.





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

* bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits
  2023-05-01 18:50   ` Eli Zaretskii
@ 2023-05-01 19:12     ` Philip Kaludercic
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2023-05-01 19:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: tbading, 63204

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 63204@debbugs.gnu.org
>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Mon, 01 May 2023 18:32:49 +0000
>> 
>> Tobias Bading <tbading@web.de> writes:
>> 
>> > 1. emacs -Q
>> >
>> > 2. Imagine that in a previous Emacs session you have copied a string with
>> >    text properties from a buffer in vc-annotate-mode, maybe also searched
>> >    for it somewhere. IOW, your ~/.emacs.d/.emacs.desktop file may contain
>> >    something like this:
>> >
>> >    (setq some-search-ring-or-whatever
>> >          '(#("heisenbug" 0 9 (face vc-annotate-face-CCCCFF))))
>> >
>> >    Evaluate this expression to simulate a desktop-read of such a previous
>> >    session.
>> >
>> > 3. Open lisp/vc/vc-annotate.el from the Git branch emacs-29.
>> >
>> > 4. C-x v g (vc-annotate)
>> >
>> > 5. There are lines with white background caused by the use of undefined face
>> >    vc-annotate-face-CCCCFF. C-h e should contain:
>> >
>> >    Invalid face reference: vc-annotate-face-CCCCFF
>> >
>> >    If for whatever reason you don’t see these bad lines, use C-u C-x = to
>> >    see what face a line uses and repeat these steps with this face instead
>> >    of vc-annotate-face-CCCCFF.
>> >
>> >
>> > This can be fixed with:
>> >
>> > diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
>> > index 70057a6aac..ae8db021ad 100644
>> > --- a/lisp/vc/vc-annotate.el
>> > +++ b/lisp/vc/vc-annotate.el
>> > @@ -724,7 +724,9 @@ vc-annotate-lines
>> >                                        (substring (cdr color) 1)
>> >                                      (cdr color))))
>> >                 ;; Make the face if not done.
>> > -               (face (or (intern-soft face-name)
>> > +               (face (or (let ((sym (intern-soft face-name)))
>> > +                           (if (facep sym)
>> > +                               sym))
>> 
>> I'd write this as (and (facep sym) sym).
>> 
>> >                           (let ((tmp-face (make-face (intern face-name))))
>> >                             (set-face-extend tmp-face t)
>> >                             (cond
>> >
>> > My Emacs Lisp isn’t that great so please feel free to improve this code
>> > if needed. The important part is that (intern-soft face-name) is not
>> > sufficient to check whether a face exists.
>> 
>> I think a better solution would be to revise general approach
>> vc-annotate takes, and instead of hard-coding faces/colours to use (that
>> break when switching between light and dark themes), to have a list of
>> faces that could be used independently of vc-annotate.
>
> We should probably do that on master, but for emacs-29 this is too
> much of a churn, I think.  So for emacs-29, I think we should install
> something like the proposed patch, just a bit cleaned-up.

I agree, the change that Tobias proposed looks like the right approach
for the immediate issue, I just wanted to mention the idea, since I have
a patch or a stash somewhere I wanted to suggest adding a while back.

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

end of thread, other threads:[~2023-05-01 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-01 13:15 bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits Tobias Bading
2023-05-01 18:32 ` Philip Kaludercic
2023-05-01 18:50   ` Eli Zaretskii
2023-05-01 19:12     ` Philip Kaludercic

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

	https://git.savannah.gnu.org/cgit/emacs.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).