Re: Uncertain prettification

2022-04-11 Thread Arash Esbati
Ikumi Keita  writes:

>> Tassilo Horn  writes:
>>> I like the second option, considering that Arash proposed to raise the
>>> minimum supported Emacs version to 25.1. How about the attached patch?
>
>> Looks good to me.
>
> Thanks, pushed.

The assumption for your patch is now fulfilled :)

Best, Arash



Re: Uncertain prettification

2022-04-10 Thread Ikumi Keita
> Tassilo Horn  writes:
>> I like the second option, considering that Arash proposed to raise the
>> minimum supported Emacs version to 25.1. How about the attached patch?

> Looks good to me.

Thanks, pushed.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine



Re: Uncertain prettification

2022-04-10 Thread Tassilo Horn
Ikumi Keita  writes:

> Hi Tassilo, thanks for your comments and working on the new ELPA
> release!

You're welcome.

> I like the second option, considering that Arash proposed to raise the
> minimum supported Emacs version to 25.1. How about the attached patch?

Looks good to me.

Bye,
Tassilo



Re: Uncertain prettification

2022-04-10 Thread Ikumi Keita
Hi Tassilo, thanks for your comments and working on the new ELPA
release!

> Tassilo Horn  writes:
> For me its 220 vs. 233 seconds which is totally acceptable.  Another way
> would be to bump the required Emacs version to 25.1 where we could omit
> all (f)boundp-checks.  Or as a third option, we could only check

>   (fboundp 'prettify-symbols-default-compose-p)

> which is always defined (even directly after emacs -Q) and available
> from 25.1 on where we can assume that prettify-symbols-compose-predicate
> and tex--prettify-symbols-alist are also available.  And then we can
> defer loading tex-mode in VirTeX-common-initialization.

I like the second option, considering that Arash proposed to raise the
minimum supported Emacs version to 25.1. How about the attached patch?

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

>From 169b2a49d59cd06192a728b8a5016f65096a7f6e Mon Sep 17 00:00:00 2001
From: Ikumi Keita 
Date: Sun, 10 Apr 2022 16:52:37 +0900
Subject: [PATCH] Make prettification work reliably

Simplify at the same time, assuming to bump required Emacs version to
25.1.

* tex.el (TeX--prettify-symbols-compose-p): Define unconditionally.
(VirTeX-common-initialization): Always enable prettification.
---
 tex.el | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/tex.el b/tex.el
index ca4b8ad3..0187459b 100644
--- a/tex.el
+++ b/tex.el
@@ -3719,14 +3719,12 @@ The algorithm is as follows:
  answer
TeX-default-mode))
 
-(when (and (boundp 'tex--prettify-symbols-alist)
-   (boundp 'prettify-symbols-compose-predicate))
-  (defun TeX--prettify-symbols-compose-p (start end match)
-(and (tex--prettify-symbols-compose-p start end match)
- (not (let ((face (get-text-property end 'face)))
-(if (consp face)
-(memq 'font-latex-verbatim-face face)
-  (eq face 'font-latex-verbatim-face)))
+(defun TeX--prettify-symbols-compose-p (start end match)
+  (and (tex--prettify-symbols-compose-p start end match)
+   (not (let ((face (get-text-property end 'face)))
+  (if (consp face)
+  (memq 'font-latex-verbatim-face face)
+(eq face 'font-latex-verbatim-face))
 
 (defun VirTeX-common-initialization ()
   "Perform basic initialization."
@@ -3786,13 +3784,10 @@ The algorithm is as follows:
 (TeX-source-correlate-mode 1))
 
   ;; Prettify Symbols mode
-  (when (fboundp 'TeX--prettify-symbols-compose-p)
-(set (make-local-variable 'prettify-symbols-alist) tex--prettify-symbols-alist)
-(TeX--if-macro-fboundp add-function
-(add-function :override (local 'prettify-symbols-compose-predicate)
-  #'TeX--prettify-symbols-compose-p)
-  (set (make-local-variable 'prettify-symbols-compose-predicate)
-   #'TeX--prettify-symbols-compose-p)))
+  (require 'tex-mode)
+  (setq-local prettify-symbols-alist tex--prettify-symbols-alist)
+  (add-function :override (local 'prettify-symbols-compose-predicate)
+#'TeX--prettify-symbols-compose-p)
 
   ;; Standard Emacs completion-at-point support
   (add-hook 'completion-at-point-functions
-- 
2.34.1



Re: Uncertain prettification

2022-04-10 Thread Arash Esbati
Hi Tassilo and Keita,

Tassilo Horn  writes:

> Another way would be to bump the required Emacs version to 25.1 where
> we could omit all (f)boundp-checks.

Is there any reason why we shouldn't do this?  We started thinking about
it in this thread[1] but didn't come to a conclusion.

Best, Arash

Footnotes:
[1]  https://lists.gnu.org/archive/html/auctex-devel/2022-03/msg00110.html



Re: Uncertain prettification

2022-04-09 Thread Tassilo Horn
Ikumi Keita  writes:

Hi Keita,

> --
> (when (and (boundp 'tex--prettify-symbols-alist)
>(boundp 'prettify-symbols-compose-predicate))
>   (defun TeX--prettify-symbols-compose-p (start end match)
> [...]
> (defun VirTeX-common-initialization ()
> [...]
>   ;; Prettify Symbols mode
>   (when (fboundp 'TeX--prettify-symbols-compose-p)
> (set (make-local-variable 'prettify-symbols-alist) 
> tex--prettify-symbols-alist)
> [...]
> --
>
> [snip]
>
> The simplest solution is to add "(require 'tex-mode)" in tex.el. See
> the patch at the last of this message.
>
> This, however, increases byte compilation time, in particular for
> "make dynvars-check"[1]. I think it's acceptable, but what do others
> think about this issue?

For me its 220 vs. 233 seconds which is totally acceptable.  Another way
would be to bump the required Emacs version to 25.1 where we could omit
all (f)boundp-checks.  Or as a third option, we could only check

  (fboundp 'prettify-symbols-default-compose-p)

which is always defined (even directly after emacs -Q) and available
from 25.1 on where we can assume that prettify-symbols-compose-predicate
and tex--prettify-symbols-alist are also available.  And then we can
defer loading tex-mode in VirTeX-common-initialization.

Bye,
Tassilo