bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#70525: [PATCH] Make auto-reveal customizations easier to extend


From: Paul Nelson
Subject: bug#70525: [PATCH] Make auto-reveal customizations easier to extend
Date: Tue, 30 Apr 2024 09:29:59 +0200

Hi Arash,

> Thanks.  In this case, I think we can have a sort of API by patching the
> function `TeX-fold-auto-reveal-p' and declaring a standard var like this:
>
> --8<---------------cut here---------------start------------->8---
> (defvar-local TeX-fold-auto-reveal-external-commands nil
>   "List of external commands which may cause a fold to be revealed.
> This is list is intended for external packages ...")
>
> (defun TeX-fold-auto-reveal-p (mode)
>   "Decide whether to auto-reveal.
> Return non-nil if folded region should be auto-opened.
> See `TeX-fold-auto-reveal' for definitions of MODE."
>   (cond ((symbolp mode)
>          (and (boundp mode)
>               (symbol-value mode)))
>         ;; Clause modified:
>         ((and (consp mode)
>               (null TeX-fold-auto-reveal-external-commands))
>          (apply (car mode) (cdr mode)))
>         ;; Clause added:
>         ((and (consp mode) TeX-fold-auto-reveal-external-commands)
>          (apply (car mode) (cons (caadr mode)
>                                  (append 
> TeX-fold-auto-reveal-external-commands
>                                          (cdadr mode)))))
>         (t mode)))
> --8<---------------cut here---------------end--------------->8---
>
> Does this make sense?  The question would then be: Should
> `TeX-fold-auto-reveal-external-commands' be a regualar var or a custom
> one?

Currently, the user is promised that if *-reveal is a cons cell, then
*-reveal-p determines whether to reveal or not by applying CAR to CDR.
With the proposal in your email, it seems to me that that promise is
invalidated: the "Clause Added" branch in your proposal would behave
in strange ways when TeX-fold-auto-reveal-external-commands is non-nil
and *-reveal is not of the same pattern as the default (in particular,
its CDR should be a list of commands).  Conceivably some users have
customized this variable in other ways while keeping it a cons cell.

With my patch, I wanted to keep the existing interface the same, so
that nobody would need to update their config (unless they have
already explicitly customized *-reveal and choose to install a package
that introduces commands that would make sense to include there, in
which case they presumably know what they're doing and can add such
commands on their own), but the default behavior would improve with
external packages.

Happy to discuss further.

Thanks, best,

Paul





reply via email to

[Prev in Thread] Current Thread [Next in Thread]