Re: [PATCH v2] Fix background color of latex previews

2024-01-09 Thread Roshan Shariff
Hi Timothy,

On Mon, 8 Jan 2024 at 03:24, Timothy  wrote:
> Thanks for this info and the patch! I've had a look at both, and I'm hopeful 
> that https://git.tecosaur.net/tec/org-mode/commit/3b3d48d3bf0 might solve the 
> problem? Do let me know what your think 

Thanks for your prompt bugfix! I can confirm that it works beautifully
on both Emacs 28 and 29.

Looking at the code, I just had a small suggestion:

diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el
index 19e34..973eed47b 100644
--- a/lisp/org-latex-preview.el
+++ b/lisp/org-latex-preview.el
@@ -541,7 +541,7 @@ Faces in `org-latex-preview--ignored-faces' are ignored."
 (normalising-face
  (if (>= emacs-major-version 29) 'default '(:inherit default
:extend t
 (cond
- ((consp face)
+ ((and (consp face) (not (keywordp (car face))) (listp (cdr face)))
   (nconc (cl-set-difference face
org-latex-preview--ignored-faces) (list normalising-face)))
  ((and face (not (memq face org-latex-preview--ignored-faces)))
   (list face normalising-face))

The (not (keywordp (car face))) condition ensures that the face isn't
a single anonymous face, i.e. a plist. The (listp (cdr face))
condition ensures that it's not just a cons like (foreground-color .
color). In both cases, the face spec is not a list of faces, so it
wouldn't be correct to append another face to the end. I'm not sure
how commonly this can happen in practice, but it covers all the cases
handled by merge_face_ref in xfaces.c.

Regards,
Roshan

> All the best,
> Timothy
>
> --
> Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at .



Re: [PATCH v2] Fix background color of latex previews

2024-01-08 Thread Timothy
Hi Roshin,

> Thanks again for your work on this exciting feature! I tried out your
> new code and it does indeed fix the problem on Emacs 29. But then I
> remembered that I originally encountered the issue on Emacs 28, and
> sure enough the issue persists there.
>
> To summarize, to get it to look right on Emacs 28, you need to append
> the face spec '(:inherit default :extend t) to the list of faces,
> rather than just 'default. Otherwise, when an equation overlay wraps
> to the next line in visual-line-mode, you'll see the background color
> of the org-block face leak through after the end-of-line. Emacs 29
> appears to behave more sensibly: if the overlay wraps to the next
> line, its face is not applied to the end of the current line.

Thanks for this info and the patch! I've had a look at both, and I'm hopeful 
that https://git.tecosaur.net/tec/org-mode/commit/3b3d48d3bf0 might solve the 
problem? Do let me know what your think 

All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at .
Support Org development at ,
or support my work at .



Re: [PATCH v2] Fix background color of latex previews

2024-01-06 Thread Timothy
Hi Roshan,

> This change addresses two issues:
>
> 1. Latex previews in headings have the background color of the
> fontified Latex code, rather than the rest of the heading.
>
> 2. If Latex code is fontified with a face that has the :extend
> attribute, and the preview overlay wraps to the next line, then the
> empty space after the end of the line uses the background color of the
> Latex code rather than that of the surrounding text.

Sorry for the delay in getting back to you. I ended up being rather busy around
the middle of last year. I’ve just started another sprint on the LaTeX preview
rewrite, and have made a few changes to how face guessing heuristics.

If you might be willing to try the new code and see if the issue noticed still
appears, that would be brilliant!

All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at .
Support Org development at ,
or support my work at .