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

From: Arash Esbati <[email-masked]>
Date: Mon, 29 Apr 2024 11:54:34 +0200

Paul Nelson <[email-masked]> writes:

> External packages (e.g., a couple that I've written) may wish to
> provide navigation commands that automatically reveal previews and
> folds, but auto-reveal behavior is currently controlled by defcustoms,
> such as preview-auto-reveal, that are not easily extended:
>
> (defcustom preview-auto-reveal
>   '(eval (preview-arrived-via (key-binding [left]) (key-binding [right])
>                               #'backward-char #'forward-char))
>   "...")
>
> I attach a patch that addresses this, without affecting default
> behavior, by changing the default value of preview-auto-reveal so that
> it refers to a list, (defcustom preview-auto-reveal-commands).
> Similarly for TeX-fold-auto-reveal.

Hi Paul,

thanks for the patch.  I have one question: You suggest we introduce a
new custom option `TeX-fold-auto-reveal-commands' which will be used in
another custom option `TeX-fold-auto-reveal' in the setter?  Is the plan
that users add functions provided by external packages to
`TeX-fold-auto-reveal-commands' and then that value is used when
`TeX-fold-auto-reveal' is set?  Basically this hunk:

> diff --git a/tex-fold.el b/tex-fold.el
> index 62f0834c..4f4ee377 100644
> --- a/tex-fold.el
> +++ b/tex-fold.el
> @@ -257,10 +257,19 @@ After that, changing the prefix key requires manipulating keymaps."
>      (define-key map "i"    #'TeX-fold-clearout-item)
>      map))
>  
> +(defcustom TeX-fold-auto-reveal-commands
> +  '((key-binding [left])
> +    (key-binding [right])
> +    backward-char
> +    forward-char
> +    mouse-set-point)
> +  "List of commands that may cause a fold to be revealed.
> +This list is consulted by the default value of `TeX-fold-auto-reveal'."
> +  :type '(repeat (choice (function :tag "Function")
> +                         (sexp :tag "Key binding"))))
> +
>  (defcustom TeX-fold-auto-reveal
> -  '(eval (TeX-fold-arrived-via (key-binding [left]) (key-binding [right])
> -                               #'backward-char #'forward-char
> -                               #'mouse-set-point))
> +  '(eval (apply 'TeX-fold-arrived-via TeX-fold-auto-reveal-commands))

'(eval (apply #'TeX-fold-arrived-via TeX-fold-auto-reveal-commands))

?

>    "Predicate to open a fold when entered.
>  Possibilities are:
>  t autoopens,

Best, Arash