auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex 1823017839 55/60: Wrap the 'funct


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 1823017839 55/60: Wrap the 'function' environment better with %
Date: Fri, 8 Apr 2022 11:52:56 -0400 (EDT)

branch: externals/auctex
commit 1823017839b2c2bd09d3d58fd08ef6dd168c10b8
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Wrap the 'function' environment better with %
    
    * style/l3doc.el (LaTeX-env-l3doc-function): Improve inserting of
    comment-char % around and in the 'function' environment.
---
 style/l3doc.el | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/style/l3doc.el b/style/l3doc.el
index 1e11bb1415..e51e83a472 100644
--- a/style/l3doc.el
+++ b/style/l3doc.el
@@ -63,7 +63,7 @@ This function should be used for the environments 'function' 
and
                                          ("noTF")
                                          ("label")
                                          ("verb"))
-                                     "Flag(s)"))
+                                     "Flags (k=v)"))
          (mac (TeX-read-string
                (TeX-argument-prompt nil nil "Macro(s)")
                TeX-esc))
@@ -72,19 +72,37 @@ This function should be used for the environments 
'function' and
          (elt-count 0)
          (count 1)
          (comment-func (lambda ()
-                         (if (TeX-in-commented-line)
+                         (if (TeX-in-line-comment)
                              (indent-according-to-mode)
                            (delete-horizontal-space)
                            (beginning-of-line)
                            (insert "%")
-                           (indent-according-to-mode)))))
+                           (indent-according-to-mode))))
+         p)
     (LaTeX-insert-environment environment
                               (concat
                                (unless (zerop (length exp-flag))
                                  (format "[%s]" exp-flag))
                                TeX-grop mac TeX-grcl))
-    ;; Now make sure the current line starts with a '%':
+    ;; Remember where we start:
+    (setq p (point-marker))
+    ;; Now make sure we have '%' everywhere, start at the beginning:
+    (search-backward (concat TeX-esc "begin" TeX-grop environment TeX-grcl)
+                     (if active-mark nil (line-beginning-position 0))
+                     t)
     (funcall comment-func)
+    ;; Now at the end:
+    (goto-char p)
+    (search-forward (concat TeX-esc "end" TeX-grop environment TeX-grcl)
+                    (if active-mark nil (line-end-position 2))
+                    t)
+    (goto-char (match-beginning 0))
+    (funcall comment-func)
+    ;; Finally for where we started and clean up only when region was
+    ;; not active:
+    (goto-char p)
+    (unless active-mark (funcall comment-func))
+    (set-marker p nil)
     ;; Ask if we should insert a 'syntax' environment:
     (when (and (not active-mark)
                (y-or-n-p "Insert syntax environment? "))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]