From 03c1fdad859eff56be76d3ba7bce1321c23e3c95 Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@gmail.com>
Date: Thu, 11 Apr 2024 05:31:55 +0200
Subject: [PATCH] Add new custom option `TeX-fold-region-functions'

* tex-fold.el (TeX-fold-region-functions): New custom option.
(TeX-fold-region): Use it.
---
 tex-fold.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tex-fold.el b/tex-fold.el
index d786ff62..e593aed5 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -324,6 +324,12 @@ and `TeX-fold-math-spec-list', and environments in `TeX-fold-env-spec-list'."
       (TeX-fold-clearout-region start end)
       (TeX-fold-region start end))))
 
+(defcustom TeX-fold-region-functions nil
+  "List of additional functions to call when folding a region.
+Each function is called with two arguments, the start and end positions
+of the region to fold."
+  :type '(repeat function))
+
 (defun TeX-fold-region (start end)
   "Fold all items in region from START to END."
   (interactive "r")
@@ -335,7 +341,8 @@ and `TeX-fold-math-spec-list', and environments in `TeX-fold-env-spec-list'."
   (when (memq 'math TeX-fold-type-list)
     (TeX-fold-region-macro-or-env start end 'math))
   (when (memq 'comment TeX-fold-type-list)
-    (TeX-fold-region-comment start end)))
+    (TeX-fold-region-comment start end))
+  (run-hook-with-args 'TeX-fold-region-functions start end))
 
 (defun TeX-fold-region-macro-or-env (start end type)
   "Fold all items of type TYPE in region from START to END.
-- 
2.39.3 (Apple Git-145)

