[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex c290376d5d 15/37: Allow programmatic folding
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex c290376d5d 15/37: Allow programmatic folding |
Date: |
Wed, 11 Oct 2023 03:41:55 -0400 (EDT) |
branch: externals/auctex
commit c290376d5d5b3834939fd38cdcd60678291ca60e
Author: Paul Nelson <ultrono@gmail.com>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Allow programmatic folding
* tex-fold.el (TeX-fold-hide-item): Abort folding if computed result
is the symbol `abort'.
(TeX-fold-macro-spec-list): Mention the new feature in the doc string.
(): Update copyright year.
* doc/auctex.texi (Folding): Mention the new feature.
Signed-off-by: Ikumi Keita <ikumi@ikumi.que.jp>
---
doc/auctex.texi | 2 ++
tex-fold.el | 63 +++++++++++++++++++++++++++++++++------------------------
2 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 61f125774a..087d1405f9 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2747,6 +2747,8 @@ placeholder.
If the first element is a function symbol, the function will be called
with all mandatory arguments of the macro and the result of the function
call will be used as a replacement for the macro.
+Such functions typically return a string, but may also return the
+symbol @code{abort} to indicate that the macro should not be folded.
The placeholder is made by copying the text from the buffer together with
its properties, i.e.@: its face as well. If fontification has not
diff --git a/tex-fold.el b/tex-fold.el
index 78b58d4dd0..e3857460f5 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -1,6 +1,6 @@
;;; tex-fold.el --- Fold TeX macros. -*- lexical-binding: t; -*-
-;; Copyright (C) 2004-2022 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2023 Free Software Foundation, Inc.
;; Author: Ralf Angeli <angeli@caeruleus.net>
;; Maintainer: auctex-devel@gnu.org
@@ -111,6 +111,8 @@ the respective macro argument.
If the first element is a function symbol, the function will be
called with all mandatory arguments of the macro and the result
of the function call will be used as a replacement for the macro.
+Such functions typically return a string, but may also return the
+symbol `abort' to indicate that the macro should not be folded.
Setting this variable does not take effect immediately. Use
Customize or reset the mode."
@@ -796,31 +798,40 @@ That means, put respective properties onto overlay OV."
(display-string (if (listp computed) (car computed) computed))
;; (face (when (listp computed) (cadr computed)))
)
- ;; Do nothing if the overlay is empty.
- (when (and ov-start ov-end)
- ;; Cater for zero-length display strings.
- (when (string= display-string "") (setq display-string
TeX-fold-ellipsis))
- ;; Add a linebreak to the display string and adjust the overlay end
- ;; in case of an overfull line.
- (when (TeX-fold-overfull-p ov-start ov-end display-string)
- (setq display-string (concat display-string "\n"))
- (move-overlay ov ov-start (save-excursion
- (goto-char ov-end)
- (skip-chars-forward " \t")
- (point))))
- (overlay-put ov 'mouse-face 'highlight)
- (when font-lock-mode
- ;; Add raise adjustment for superscript and subscript.
- ;; (bug#42209)
- (setq display-string
- (propertize display-string
- 'display (get-text-property ov-start 'display))))
- (overlay-put ov 'display display-string)
- (when font-lock-mode
- (overlay-put ov 'face TeX-fold-folded-face))
- (unless (zerop TeX-fold-help-echo-max-length)
- (overlay-put ov 'help-echo (TeX-fold-make-help-echo
- (overlay-start ov) (overlay-end ov)))))))
+
+ (if (eq computed 'abort)
+ ;; Abort folding if computed result is the symbol `abort'.
+ ;; This allows programmatic customization.
+ ;; Suggested by Paul Nelson <ultrono@gmail.com>.
+ ;; <URL:https://lists.gnu.org/r/auctex/2023-08/msg00026.html>
+ (progn (delete-overlay ov)
+ t ; so that `TeX-fold-dwim' "gives up"
+ )
+ ;; Do nothing if the overlay is empty.
+ (when (and ov-start ov-end)
+ ;; Cater for zero-length display strings.
+ (when (string= display-string "") (setq display-string
TeX-fold-ellipsis))
+ ;; Add a linebreak to the display string and adjust the overlay end
+ ;; in case of an overfull line.
+ (when (TeX-fold-overfull-p ov-start ov-end display-string)
+ (setq display-string (concat display-string "\n"))
+ (move-overlay ov ov-start (save-excursion
+ (goto-char ov-end)
+ (skip-chars-forward " \t")
+ (point))))
+ (overlay-put ov 'mouse-face 'highlight)
+ (when font-lock-mode
+ ;; Add raise adjustment for superscript and subscript.
+ ;; (bug#42209)
+ (setq display-string
+ (propertize display-string
+ 'display (get-text-property ov-start 'display))))
+ (overlay-put ov 'display display-string)
+ (when font-lock-mode
+ (overlay-put ov 'face TeX-fold-folded-face))
+ (unless (zerop TeX-fold-help-echo-max-length)
+ (overlay-put ov 'help-echo (TeX-fold-make-help-echo
+ (overlay-start ov) (overlay-end
ov))))))))
(defun TeX-fold-show-item (ov)
"Show a single LaTeX macro or environment.
- [elpa] externals/auctex 8e4043a899 08/37: ; * latex.el (LaTeX-completion-parse-args): Use `cl-flet'., (continued)
- [elpa] externals/auctex 8e4043a899 08/37: ; * latex.el (LaTeX-completion-parse-args): Use `cl-flet'., Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 95163c6602 14/37: ; Fix typo and spacing in Texinfo document, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex e2f18de580 23/37: ; * auctex.el.in: Provide the final product., Tassilo Horn, 2023/10/11
- [elpa] externals/auctex f69211af62 03/37: Fix context nl mode, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 7b1d4156b2 32/37: * latex.el (LaTeX-auto-counter-regexp-list): Save regexp groups., Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 95d7a81f40 20/37: Fix "Honor file local variables" (bug#65750), Tassilo Horn, 2023/10/11
- [elpa] externals/auctex d9a6c248d0 35/37: ; Minor improvement of documentation, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 91da27754b 13/37: Keep preview images when killing indirect buffer (bug#65462), Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 8c3e73c4bb 07/37: Unbreak in-buffer completion for Emacs prior to v.28, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex aabf144dfb 22/37: Arrange indent of tabular-like environments (bug#65648), Tassilo Horn, 2023/10/11
- [elpa] externals/auctex c290376d5d 15/37: Allow programmatic folding,
Tassilo Horn <=
- [elpa] externals/auctex 454f02a588 25/37: Take care of temporal buffers (bug#65912), Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 0df824d5d2 19/37: Remove menu title inconsistency, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex fe3ef154cd 09/37: Support verbatim shorthands defined with fancyvrb package, Tassilo Horn, 2023/10/11
- [elpa] externals/auctex bb5e6c0a27 27/37: Remove let-binding for `max-specpdl-size', Tassilo Horn, 2023/10/11
- [elpa] externals/auctex ad81644cf1 26/37: ; * tex.el (TeX-brace-count-line): Fix last change., Tassilo Horn, 2023/10/11
- [elpa] externals/auctex 34a94db2ae 29/37: * tex.el (plain-TeX-auto-regexp-list): Save regexp groups., Tassilo Horn, 2023/10/11