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.
Thanks, best,
Paul
From 69772c95c0a0eb7b417bbf1e7e5f295a8868575c Mon Sep 17 00:00:00 2001
From: Paul Nelson <[email protected]>
Date: Tue, 23 Apr 2024 05:49:01 +0200
Subject: [PATCH] Make auto-reveal customizations easier to extend
* preview.el.in (preview-auto-reveal-commands): New user option.
(preview-auto-reveal): Use it.
* tex-fold.el (TeX-fold-auto-reveal-commands): New user option.
(TeX-fold-auto-reveal): Use it.
(doc/auctex.texi): Document it.
---
doc/auctex.texi | 12 +++++++++---
preview.el.in | 13 +++++++++++--
tex-fold.el | 15 ++++++++++++---
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 4d338c39..05695f0f 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2864,9 +2864,15 @@ Cons cell @code{(@var{FUNCTION} . @var{ARGUMENTS})}: @AUCTeX{} calls the
is regarded as a boolean flag.
@end itemize
-It has a reasonable default value to reveal when the point enters the
-folded portion with @kbd{@key{left}}, @kbd{@key{right}}, @kbd{C-b},
-@kbd{C-f} or mouse click under standard key binding.
+The default behavior is to reveal when the point enters the folded portion
+via one of the commands specified in @code{TeX-fold-auto-reveal-commands}.
+@end defopt
+
+@defopt TeX-fold-auto-reveal-commands
+This is a list of commands, consulted under the default behavior of
+@code{TeX-fold-auto-reveal}. By default, it consists of the commands
+@kbd{@key{left}}, @kbd{@key{right}}, @kbd{C-b}, @kbd{C-f} or mouse click
+under standard key binding.
@end defopt
diff --git a/preview.el.in b/preview.el.in
index 1f65f728..cdf79cc7 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -1635,9 +1635,18 @@ numbers (can be float if available)."
Fallback to :inherit and \\='default implemented."
:group 'preview-appearance)
+(defcustom preview-auto-reveal-commands
+ '((key-binding [left])
+ (key-binding [right])
+ backward-char
+ forward-char)
+ "List of commands that may cause a preview to be revealed.
+This list is consulted by the default value of `preview-auto-reveal'."
+ :type '(repeat (choice (function :tag "Function")
+ (sexp :tag "Key binding"))))
+
(defcustom preview-auto-reveal
- '(eval (preview-arrived-via (key-binding [left]) (key-binding [right])
- #'backward-char #'forward-char))
+ '(eval (apply 'preview-arrived-via preview-auto-reveal-commands))
"Cause previews to open automatically when entered.
Possibilities are:
t autoopens,
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))
"Predicate to open a fold when entered.
Possibilities are:
t autoopens,
--
2.39.3 (Apple Git-145)
_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex