branch: main commit 2d1a9a7c1865976a7929874bb0cf4f7aa5174f35 Author: Paul Nelson <ultr...@gmail.com> Commit: Arash Esbati <ar...@gnu.org>
Add folding support for alert and textcolor macros * NEWS.org (Added): Announce the change. * tex-fold.el (TeX-fold-macro-spec-list): Add alert and textcolor entries. (TeX-fold-textcolor-display): (TeX-fold-alert-display): New functions. (TeX-fold-alert-color): New user option. * auctex.texi (Folding Macros and Environments): Document new user option. (bug#73611) --- NEWS.org | 5 ++++- doc/auctex.texi | 5 +++++ tex-fold.el | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/NEWS.org b/NEWS.org index 532cc546..49dcc10e 100644 --- a/NEWS.org +++ b/NEWS.org @@ -11,8 +11,11 @@ ** Added +- Add new custom option ~TeX-fold-alert-color~ which determines the + color used when folding the ~\alert~ macro, defaults to ~red~. + - Add new support file =style/minted2.el= (=style/minted.el= is updated - to package version v3.1.2). + to package v3.1.2). * [14.0.7] - 2024-10-05 diff --git a/doc/auctex.texi b/doc/auctex.texi index 80847bf7..d8e92e80 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -2874,6 +2874,11 @@ This is a list of commands, consulted under the default behavior of under standard key binding. @end defopt +@defopt TeX-fold-alert-color +This is the color used to fold @samp{\alert@{...@}} macros (for the +replacement specifier given by the default value of +@code{TeX-fold-macro-spec-list}). +@end defopt @node Outline @section Outlining the Document diff --git a/tex-fold.el b/tex-fold.el index 4a67a669..c9f65b59 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -81,6 +81,8 @@ macros, `math' for math macros and `comment' for comments." ("(C)" ("copyright")) ("(R)" ("textregistered")) ("TM" ("texttrademark")) + (TeX-fold-alert-display ("alert")) + (TeX-fold-textcolor-display ("textcolor")) (1 ("part" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph" "part*" "chapter*" "section*" "subsection*" "subsubsection*" @@ -611,6 +613,30 @@ Return non-nil if a comment was found and folded, nil otherwise." (TeX-fold-hide-item (TeX-fold-make-overlay beg (point) 'comment TeX-fold-ellipsis))))))) +;;; Display functions + +(defun TeX-fold-textcolor-display (color text &rest _args) + "Fold display for a \\textcolor{COLOR}{TEXT} macro." + (with-temp-buffer + (insert text) + (put-text-property (point-min) (point-max) + 'face `(:foreground ,color) + (current-buffer)) + (buffer-string))) + +(defcustom TeX-fold-alert-color "red" + "Color for alert text." + :type 'color + :package-version '(auctex . "14.0.8")) + +(defun TeX-fold-alert-display (text &rest _args) + "Fold display for a \\alert{TEXT} macro." + (with-temp-buffer + (insert text) + (put-text-property (point-min) (point-max) + 'face `(:foreground ,TeX-fold-alert-color) + (current-buffer)) + (buffer-string))) ;;; Utilities