emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex b77907698e 12/13: Merge remote-tracking branch '


From: Tassilo Horn
Subject: [elpa] externals/auctex b77907698e 12/13: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Sun, 5 Mar 2023 03:25:40 -0500 (EST)

branch: externals/auctex
commit b77907698e0af57382d9695672738283734f2289
Merge: 6d4b412b69 4c77908707
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 Makefile.in                       |   4 +-
 latex.el                          | 105 ++++++++++++------
 style/algpseudocodex.el           | 216 ++++++++++++++++++++++++++++++++++++++
 style/beamer.el                   |   6 +-
 style/ltugboat.el                 |  35 ++++--
 style/overpic.el                  |   7 +-
 style/physics.el                  |   4 +-
 style/url.el                      |   6 +-
 tests/latex/latex-filling-in.tex  |  14 +++
 tests/latex/latex-filling-out.tex |  19 ++++
 tests/latex/latex-test.el         |  21 ++++
 tests/latex/nested-indent-in.tex  |  10 ++
 tests/latex/nested-indent-out.tex |  12 +++
 tests/latex/texmathp-test.el      |  22 ++++
 texmathp.el                       |  27 +++--
 15 files changed, 446 insertions(+), 62 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index f64125c78f..6244269a6e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,7 +2,7 @@
 
 # Maintainer: auctex-devel@gnu.org
 
-# Copyright (C) 2003-2008, 2010, 2013-2015, 2018-2022 Free Software
+# Copyright (C) 2003-2008, 2010, 2013-2015, 2018-2023 Free Software
 #   Foundation, Inc.
 
 # This file is part of AUCTeX.
@@ -196,7 +196,7 @@ STYLESRC = style/prosper.el \
           style/keyval.el    style/kvoptions.el style/kvsetkeys.el \
           style/proc.el      style/microtype.el style/tcolorboxlib-theorems.el 
\
           style/amsaddr.el   style/parskip.el   style/catchfilebetweentags.el \
-          style/physics.el
+          style/physics.el   style/algpseudocodex.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/latex.el b/latex.el
index 56992d54fb..7306fcc4e3 100644
--- a/latex.el
+++ b/latex.el
@@ -821,12 +821,13 @@ environment just inserted, the buffer position just before
     (end-of-line 0)
     (if active-mark
         (progn
-          (or (assoc environment LaTeX-indent-environment-list)
-              (if auto-fill-function
-                  ;; Fill the region only when `auto-fill-mode' is active.
-                  (LaTeX-fill-region content-start (line-beginning-position 2))
-                ;; Else just indent the region. (bug#48518)
-                (indent-region content-start (line-beginning-position 2))))
+          (if (and auto-fill-function
+                   (not (assoc environment LaTeX-indent-environment-list)))
+              ;; Fill the region only when `auto-fill-mode' is active
+              ;; and no special indent rule exists.
+              (LaTeX-fill-region content-start (line-beginning-position 2))
+            ;; Else just indent the region. (bug#48518, bug#28382)
+            (indent-region content-start (line-beginning-position 2)))
           (set-mark content-start))
       (indent-according-to-mode))
     ;; Indent \end{foo}.
@@ -1335,7 +1336,6 @@ Just like array and tabular."
     (LaTeX-newline)
     (indent-according-to-mode))
   (when (TeX-active-mark)
-    (indent-region (point) (mark))
     ;; Restore the positions of point and mark.
     (exchange-point-and-mark)))
 
@@ -3780,46 +3780,72 @@ values of the variable `LaTeX-verbatim-environments' as 
well.")
   (append LaTeX-verbatim-environments
           LaTeX-verbatim-environments-local))
 
-(defun LaTeX-verbatim-macro-boundaries ()
-  "Return boundaries of verbatim macro.
+(defun LaTeX-verbatim-macro-boundaries (&optional arg-only)
+  "Return boundaries of verbatim macro containing point.
 Boundaries are returned as a cons cell where the car is the macro
 start and the cdr the macro end.
 
-Only macros which enclose their arguments with special
-non-parenthetical delimiters, like \\verb+foo+, are recognized."
+If optional argument ARG-ONLY is non-nil, return the inner region
+of the macro argument as cons."
   (save-excursion
     (let ((orig (point))
-          (verbatim-regexp (regexp-opt (LaTeX-verbatim-macros-with-delims) t)))
+          (verbatim-regexp (regexp-opt
+                            (append (LaTeX-verbatim-macros-with-delims)
+                                    (LaTeX-verbatim-macros-with-braces))
+                            t)))
       ;; Search backwards for the macro start, unless we are facing one
-      (unless (looking-at (concat (regexp-quote TeX-esc) verbatim-regexp))
-        (catch 'found
-          (while (progn
-                   (skip-chars-backward (concat "^\n" (regexp-quote TeX-esc))
-                                        (line-beginning-position))
-                   (when (looking-at verbatim-regexp) (throw 'found nil))
-                   (or (bobp) (forward-char -1))
-                   (/= (point) (line-beginning-position))))))
+      (if (looking-at (concat (regexp-quote TeX-esc) verbatim-regexp))
+          (forward-char 1)
+        (while (progn
+                 (skip-chars-backward (concat "^" (regexp-quote TeX-esc))
+                                      (line-beginning-position))
+                 (if (or (bolp)
+                         (looking-at verbatim-regexp))
+                     ;; Terminate the loop.
+                     nil
+                   (forward-char -1)
+                   ;; Continue the loop.
+                   t))))
       ;; Search forward for the macro end, unless we failed to find a start
       (unless (bolp)
         (let* ((beg (1- (point)))
-               (macro-end (match-end 0))
+               (end (match-end 0))
                ;; XXX: Here we assume we are dealing with \verb which
                ;; expects the delimiter right behind the command.
                ;; However, \lstinline can also cope with whitespace as
                ;; well as an optional argument after the command.
-               (delimiter (buffer-substring-no-properties
-                           macro-end (1+ macro-end))))
+               ;; \Verb (from fancyvrb) also accepts an optional
+               ;; argument which we have to encounter.  We assume that
+               ;; users don't write something like this '\Verb[foo['
+               ;; and again the delimiter is directly after the ]
+               ;; closing the optional argument:
+               (delimiter (progn
+                            (if (= (char-after end) (aref LaTeX-optop 0))
+                                ;; Update `end'.
+                                (save-excursion (goto-char end)
+                                                (forward-list)
+                                                (setq end (point))))
+                            (string (char-after end)))))
           ;; Heuristic: If an opening brace is encountered, search for
-          ;; both the opening and the closing brace as an end marker.
+          ;; a closing brace as an end marker.
           ;; Like that the function should work for \verb|...| as well
           ;; as for \url{...}.
-          (when (string= delimiter TeX-grop)
-            (setq delimiter (concat delimiter TeX-grcl)))
-          (goto-char (1+ macro-end))
-          (skip-chars-forward (concat "^" delimiter))
+          (if (string= delimiter TeX-grop)
+              (progn
+                (goto-char end)
+                ;; Allow one level of nested braces as verb argument.
+                (re-search-forward "{[^}{]*\\(?:{[^}{]*}[^}{]*\\)*}"
+                                   (line-end-position) t)
+                (backward-char))
+            (goto-char (1+ end))
+            (skip-chars-forward (concat "^" delimiter) (line-end-position)))
           (when (<= orig (point))
-            (cons beg (1+ (point)))))))))
+            (if arg-only
+                (cons (1+ end) (point))
+              (cons beg (1+ (point))))))))))
 
+;; Currently, AUCTeX doesn't use this function at all.  We leave it as
+;; a utility function.  It was originally used in `LaTeX-verbatim-p'.
 (defun LaTeX-current-verbatim-macro ()
   "Return name of verbatim macro containing point, nil if none is present."
   (let ((macro-boundaries (LaTeX-verbatim-macro-boundaries)))
@@ -3831,16 +3857,25 @@ non-parenthetical delimiters, like \\verb+foo+, are 
recognized."
          (point) (progn (skip-chars-forward "@A-Za-z*") (point)))))))
 
 (defun LaTeX-verbatim-p (&optional pos)
-  "Return non-nil if position POS is in a verbatim-like construct."
+  "Return non-nil if position POS is in a verbatim-like construct.
+The macro body (\"\\verb\") and its delimiters, including
+optional argument if any, aren't considered as component of a
+verbatim-like construct."
   (when pos (goto-char pos))
   (save-match-data
-    (or (progn
+    ;; TODO: Factor out syntax propertize facility from font-latex.el
+    ;; and re-implement as major mode feature.  Then we can drop the
+    ;; fallback code below.
+    (if (eq TeX-install-font-lock 'font-latex-setup)
+        (progn
           (syntax-propertize (point))
           (nth 3 (syntax-ppss)))
-        (member (LaTeX-current-verbatim-macro)
-                (LaTeX-verbatim-macros-with-delims))
-        (member (TeX-current-macro) (LaTeX-verbatim-macros-with-braces))
-        (member (LaTeX-current-environment) (LaTeX-verbatim-environments)))))
+      ;; Fallback for users who stay away from font-latex.
+      (or
+       (let ((region (LaTeX-verbatim-macro-boundaries t)))
+         (and region
+              (<= (car region) (point) (cdr region))))
+       (member (LaTeX-current-environment) (LaTeX-verbatim-environments))))))
 
 
 ;;; Formatting
diff --git a/style/algpseudocodex.el b/style/algpseudocodex.el
new file mode 100644
index 0000000000..d2b9848d92
--- /dev/null
+++ b/style/algpseudocodex.el
@@ -0,0 +1,216 @@
+;;; algpseudocodex.el --- AUCTeX style for `algpseudocodex.sty' (v1.0.2)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Created: 2022-10-10
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for the `algpseudocodex.sty' (v1.0.2) from
+;; 2022-10-07.  `algpseudocodex.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(defun LaTeX-arg-algpseudocodex-block (_optional block &optional num)
+  "Insert the arguments of blocks from algpseudocodex package.
+OPTIONAL is ignored.  BLOCK is the name of the block which also
+determines the macro inserted for the block end.  NUM determines
+the number of arguments."
+  (cond ((string= block "Repeat")
+         (indent-according-to-mode)
+         (LaTeX-newline)
+         (indent-according-to-mode)
+         (LaTeX-newline)
+         (insert TeX-esc "Until" TeX-grop)
+         (set-marker TeX-exit-mark (point))
+         (insert TeX-grcl)
+         (indent-according-to-mode))
+        ((integerp num)
+         (indent-according-to-mode)
+         (insert TeX-grop)
+         (set-marker TeX-exit-mark (point))
+         (insert TeX-grcl)
+         (when (= num 2)
+           (insert TeX-grop TeX-grcl))
+         (LaTeX-newline)
+         (indent-according-to-mode)
+         (LaTeX-newline)
+         (insert TeX-esc "End" block)
+         (indent-according-to-mode))
+        (t
+         (indent-according-to-mode)
+         (LaTeX-newline)
+         (indent-according-to-mode)
+         (set-marker TeX-exit-mark (point))
+         (LaTeX-newline)
+         (insert TeX-esc "End" block)
+         (indent-according-to-mode))))
+
+(TeX-add-style-hook
+ "algpseudocodex"
+ (lambda ()
+
+   ;; 1.1 Algorithmic Block
+   (LaTeX-add-environments
+    '("algorithmic" [ "Number" ]))
+
+   (TeX-add-symbols
+    ;; 1.2 Simple Statements and Commands
+    '("State"  (TeX-arg-literal " "))
+    '("Statex" (TeX-arg-literal " "))
+    '("Return" (TeX-arg-literal " "))
+    '("Output" (TeX-arg-literal " "))
+    '("Call"   2)
+
+    ;; 1.3.1 While Loop
+    '("While" (LaTeX-arg-algpseudocodex-block "While" 1))
+    '("EndWhile" 0)
+
+    ;; 1.3.2 For Loop
+    '("For" (LaTeX-arg-algpseudocodex-block "For" 1))
+    '("EndFor" 0)
+
+    ;; 1.3.3 For-All Loop
+    '("ForAll" (LaTeX-arg-algpseudocodex-block "For" 1))
+
+    ;; 1.3.4 Loop
+    '("Loop" (LaTeX-arg-algpseudocodex-block "Loop"))
+    '("EndLoop" 0)
+
+    ;; 1.3.5 Repeat-Until Loop
+    '("Repeat" (LaTeX-arg-algpseudocodex-block "Repeat"))
+    '("Until" 1)
+
+    ;; 1.3.6 If Statement
+    '("If" (LaTeX-arg-algpseudocodex-block "If" 1))
+    '("ElsIf" 1)
+    '("Else"  0)
+    '("EndIf" 0)
+
+    ;; 1.3.7 Procedure
+    '("Procedure" (LaTeX-arg-algpseudocodex-block "Procedure" 2))
+    '("EndProcedure" 0)
+
+    ;; 1.3.8 Function
+    '("Function" (LaTeX-arg-algpseudocodex-block "Function" 2))
+    '("EndFunction" 0)
+
+    ;; 1.4 Require and Ensure
+    '("Require" (TeX-arg-literal " "))
+    '("Ensure"  (TeX-arg-literal " "))
+
+    ;; 1.5 Comments
+    '("Comment"  1)
+    '("LComment" 1)
+
+    ;; 2.1 Boxes Around Multiple Lines of Code
+    '("BeginBox" (LaTeX-arg-algpseudocodex-block "Box"))
+
+    ;; 2.2 Boxes Inside Single Line
+    '("BoxedString" ["options"] t)
+
+    '("algrenewcommand"
+      (TeX-arg-completing-read ("algorithmicend"
+                                "algorithmicdo"
+                                "algorithmicwhile"
+                                "algorithmicfor"
+                                "algorithmicforall"
+                                "algorithmicloop"
+                                "algorithmicrepeat"
+                                "algorithmicuntil"
+                                "algorithmicprocedure"
+                                "algorithmicfunction"
+                                "algorithmicif"
+                                "algorithmicthen"
+                                "algorithmicelse"
+                                "algorithmicrequire"
+                                "algorithmicensure"
+                                "algorithmicreturn"
+                                "algorithmicoutput")
+                               "Macro (cr): \\" t "\\")
+      t))
+
+   ;; Indentation: Add the keywords above to the respective variables
+   ;; and run `LaTeX-indent-commands-regexp-make'.
+   (unless (member "BeginBox" LaTeX-indent-begin-list)
+     (let ((beg '("For" "ForAll"
+                  "While"
+                  "Repeat"
+                  "If"
+                  "Procedure"
+                  "Function"
+                  "Loop"
+                  "BeginBox"))
+           (mid '("ElsIf" "Else"))
+           (end '("EndFor"
+                  "EndWhile"
+                  "Until"
+                  "EndIf"
+                  "EndProcedure"
+                  "EndFunction"
+                  "EndLoop"
+                  "EndBox")))
+       (dolist (elt beg)
+         (add-to-list 'LaTeX-indent-begin-list elt t))
+       (dolist (elt mid)
+         (add-to-list 'LaTeX-indent-mid-list elt t))
+       (dolist (elt end)
+         (add-to-list 'LaTeX-indent-end-list elt t))
+       (LaTeX-indent-commands-regexp-make)))
+
+   ;; Add the 'algorithmic' environment to a local version of
+   ;; `LaTeX-indent-environment-list'.  This effectively kills filling
+   ;; but indenting works as expected.  Hence, 'M-q' gives a better
+   ;; experience.
+   (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
+                '("algorithmic")
+                t)
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("algrenewcommand" "|{\\{"))
+                              'function)))
+ TeX-dialect)
+
+(defun LaTeX-algpseudocodex-package-options ()
+  "Package options for the algpseudocodex package."
+  (TeX-read-key-val t '(("noEnd" ("true" "false"))
+                        ("indLines" ("true" "false"))
+                        ("spaceRequire" ("true" "false"))
+                        ("italicComments" ("true" "false"))
+                        ("rightComments" ("true" "false"))
+                        ("commentColor")
+                        ("beginComment")
+                        ("endComment")
+                        ("beginLComment")
+                        ("endLComment"))))
+
+;;; algpseudocodex.el ends here
diff --git a/style/beamer.el b/style/beamer.el
index 9a33b348c2..765519b934 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -70,7 +70,8 @@
    (add-hook 'LaTeX-after-insert-env-hook #'LaTeX-beamer-after-insert-env nil 
t)
 
    (TeX-run-style-hooks "amsmath" "amssymb" "amsthm" "color" "geometry"
-                        "hyperref" "inputenc" "translator" "xcolor")
+                        "hyperref" "inputenc" "translator" "xcolor"
+                        "graphicx")
 
    (LaTeX-section-list-add-locally
     '(("part" 0)
@@ -160,7 +161,8 @@
     '("hyperlinkdocumentend" [TeX-arg-beamer-overlay-spec] 1)
     '("hypertarget" [TeX-arg-beamer-overlay-spec] "Target name" t)
     '("includegraphics" [TeX-arg-beamer-overlay-spec]
-      [LaTeX-arg-graphicx-includegraphics-key-val] LaTeX-arg-includegraphics)
+      [TeX-arg-key-val (LaTeX-graphicx-key-val-options) nil nil ?\s]
+      LaTeX-arg-includegraphics)
     '("includeonlyframes" "Frame label(s)")
     '("includeonlylecture" "Lecture label")
     '("includeslide" ["Options"] "Label")
diff --git a/style/ltugboat.el b/style/ltugboat.el
index 67d58e6378..85866df912 100644
--- a/style/ltugboat.el
+++ b/style/ltugboat.el
@@ -1,6 +1,6 @@
-;;; ltugboat.el --- AUCTeX style for `ltugboat.cls' (v2.22)  -*- 
lexical-binding: t; -*-
+;;; ltugboat.el --- AUCTeX style for `ltugboat.cls' (v2.28)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2019--2022 Free Software Foundation, Inc.
+;; Copyright (C) 2019--2023 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `ltugboat.cls' (v2.22) from 2019/11/09.
+;; This file adds support for `ltugboat.cls' (v2.28) from 2023/01/16.
 ;; `ltugboat.cls' is part of TeXLive.
 
 ;;; Code:
@@ -39,6 +39,8 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
+(declare-function font-latex-set-syntactic-keywords
+                  "font-latex")
 
 (TeX-add-style-hook
  "ltugboat"
@@ -94,9 +96,10 @@
                                          "small" "normalsize" "large"
                                          "Large" "LARGE"      "huge"
                                          "Huge"  "makevmeta"  "ruled")
-                                        "Command(s)" nil nil
+                                        "Command(s) (crm): \\" t
+                                        ,TeX-esc
                                         ,(regexp-quote TeX-esc)
-                                        ,TeX-esc nil nil nil nil ,TeX-esc]))
+                                        ,TeX-esc]))
 
    ;; 10.1 Acronyms and logos
    (TeX-add-symbols
@@ -237,10 +240,20 @@
     '("tubbraced" "Text")
     '("nth"       "Number")
 
-    ;; 12 Bibliography
+    ;; 12 Typesetting urls
+    '("tburl" "Url")
+    '("tbsurl" "https Url")
+    '("tbhurl" "http Url")
+    '("tburlfootnote" "Url")
+
+    ;; 13 Bibliography
     '("SetBibJustification"
       (TeX-arg-completing-read ("\\raggedright" "\\sloppy") "Justification")))
 
+   ;; Add the macros to `LaTeX-verbatim-macros-with-braces-local':
+   (dolist (mac '("tburl" "tbsurl" "tbhurl" "tburlfootnote"))
+     (add-to-list 'LaTeX-verbatim-macros-with-braces-local mac t))
+
    ;; Fontification
    (when (and (featurep 'font-latex)
               (eq TeX-install-font-lock 'font-latex-setup))
@@ -260,8 +273,14 @@
      (font-latex-add-keywords '(("makesignature"   "")
                                 ("SetBibJustification"  "{"))
                               'function)
-     (font-latex-add-keywords '(("nameref" "{"))
-                              'reference)))
+     (font-latex-add-keywords '(("nameref" "{")
+                                ("tburl"   "")
+                                ("tbsurl"  "")
+                                ("tbhurl"  "")
+                                ("tburlfootnote" ""))
+                              'reference)
+     ;; Tell font-lock about the update.
+     (font-latex-set-syntactic-keywords)))
  TeX-dialect)
 
 (defvar LaTeX-ltugboat-class-options
diff --git a/style/overpic.el b/style/overpic.el
index 52d51d0dfb..9022bb2fce 100644
--- a/style/overpic.el
+++ b/style/overpic.el
@@ -55,10 +55,9 @@
   "Insert key-val for optional argument of overpic environments.
 If OPTIONAL is non-nil, insert argument in square brackets.
 
-This function is an variation of
-`LaTeX-arg-graphicx-includegraphics-key-val' where the key-val's
-in `LaTeX-overpic-key-val-options' are offered in addition to the
-ones provided by `LaTeX-graphicx-key-val-options'."
+The key-val's in `LaTeX-overpic-key-val-options' are offered in
+addition to the ones provided by
+`LaTeX-graphicx-key-val-options'."
   (let ((crm-local-completion-map
          (remove (assoc 32 crm-local-completion-map)
                  crm-local-completion-map))
diff --git a/style/physics.el b/style/physics.el
index f805df1b75..9465f0035d 100644
--- a/style/physics.el
+++ b/style/physics.el
@@ -67,8 +67,8 @@
 ;;  + as opposed to the document, \tr and \trace aren't equivalent.
 ;;  + dv accepts one or two arguments except optional argument.
 ;;    o 1 arg      ... {derivative variable}
-;;    o 2 arg      ... {function to derive}{derivative variable}
-;;    O 1 arg + () ... {derivative variable}(function to derive)
+;;    o 2 args     ... {function to derive}{derivative variable}
+;;    o 1 arg + () ... {derivative variable}(function to derive)
 ;;  + pdv accepts one, two or three arguments except optional argument.
 ;;    o 1 arg      ... {derivative variable}
 ;;    o 2 args     ... {function to derive}{derivative variable}
diff --git a/style/url.el b/style/url.el
index e1bac616c7..70baf10226 100644
--- a/style/url.el
+++ b/style/url.el
@@ -1,6 +1,6 @@
 ;;; url.el --- AUCTeX style for `url.sty'  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2022  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2023  Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -177,7 +177,9 @@ standard one."
     '("urldef" TeX-arg-url-urldef)
 
     '("urlstyle" (TeX-arg-completing-read ("rm" "same" "sf" "tt")
-                                          "Style")))
+                                          "Style"))
+
+    '("DeclareUrlCommand" TeX-arg-url-DeclareUrlCommand))
 
    ;; For '\path', use the facilities provided by this style.  Also
    ;; don't add "path" for fontification below since
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index 16c314f95b..8d297b1b69 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -1,4 +1,6 @@
 \documentclass{article}
+\usepackage{url}
+\usepackage{fvextra}
 \usepackage{shortvrb}
 \begin{document}
 
@@ -81,6 +83,18 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
\verb|sed do|eiusmod te
 % '(?\") in the function `LaTeX-filling' in latex-test.el.
 Lorem ipsum dolor sit amet, consectetur adipiscing elit, "sed do"eiusmod tempor
 
+% bug#61400 Various verb-like commands should allow line break at just
+% before them.
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec \path{bar}
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec \path|bar|
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec \Verb{bar}
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec \Verb|bar|
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec \verb|bar|
+
 \end{document}
 
 %%% Local Variables:
diff --git a/tests/latex/latex-filling-out.tex 
b/tests/latex/latex-filling-out.tex
index 18dec27ccc..4843329cdb 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -1,4 +1,6 @@
 \documentclass{article}
+\usepackage{url}
+\usepackage{fvextra}
 \usepackage{shortvrb}
 \begin{document}
 
@@ -91,6 +93,23 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit,
 Lorem ipsum dolor sit amet, consectetur adipiscing elit,
 "sed do"eiusmod tempor
 
+% bug#61400 Various verb-like commands should allow line break at just
+% before them.
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+\path{bar}
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+\path|bar|
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+\Verb{bar}
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+\Verb|bar|
+% bug#61400
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+\verb|bar|
+
 \end{document}
 
 %%% Local Variables:
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index c82b240fcd..fbd64e0953 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -55,6 +55,10 @@
  "conditionals-indent-in.tex"
  'LaTeX-conditionals-indent/out
  "conditionals-indent-out.tex"
+ 'LaTeX-nested-indent/in
+ "nested-indent-in.tex"
+ 'LaTeX-nested-indent/out
+ "nested-indent-out.tex"
  'docTeX/in
  "doctex-indent-in.dtx"
  'docTeX/out
@@ -143,6 +147,23 @@
       (newline-and-indent)
       (should (= (current-column) 2)))))
 
+;; bug#48518 Test indent in nested environments
+(ert-deftest LaTeX-indent-nested-envs ()
+  (should (string=
+           (with-temp-buffer
+             (insert-file-contents LaTeX-nested-indent/in)
+             (LaTeX-mode)
+             (let ((TeX-parse-self t))
+               (TeX-update-style t))
+             (search-forward "a^2 + b^2 = c^2")
+             (set-mark (match-beginning 0))
+             (activate-mark)
+             (LaTeX-insert-environment "equation")
+             (buffer-string))
+           (with-temp-buffer
+             (insert-file-contents LaTeX-nested-indent/out)
+             (buffer-string)))))
+
 ;; Test LaTeX code with math modes is indented as expected.  This has mostly to
 ;; do with the value of `LaTeX-fill-break-at-separators' and how
 ;; `LaTeX-fill-move-to-break-point' handles it.  If the test fails, try to look
diff --git a/tests/latex/nested-indent-in.tex b/tests/latex/nested-indent-in.tex
new file mode 100644
index 0000000000..eb8510784f
--- /dev/null
+++ b/tests/latex/nested-indent-in.tex
@@ -0,0 +1,10 @@
+\documentclass{article}
+
+\begin{document}
+\begin{itemize}
+\item hello test.
+  some more text.
+  a^2 + b^2 = c^2
+  and some text afterwards here.
+\end{itemize}
+\end{document}
diff --git a/tests/latex/nested-indent-out.tex 
b/tests/latex/nested-indent-out.tex
new file mode 100644
index 0000000000..e321ccfb53
--- /dev/null
+++ b/tests/latex/nested-indent-out.tex
@@ -0,0 +1,12 @@
+\documentclass{article}
+
+\begin{document}
+\begin{itemize}
+\item hello test.
+  some more text.
+  \begin{equation}
+    a^2 + b^2 = c^2
+  \end{equation}
+  and some text afterwards here.
+\end{itemize}
+\end{document}
diff --git a/tests/latex/texmathp-test.el b/tests/latex/texmathp-test.el
index 3fb6f5497c..121af22c7f 100644
--- a/tests/latex/texmathp-test.el
+++ b/tests/latex/texmathp-test.el
@@ -48,4 +48,26 @@
             (LaTeX-mode)
             (texmathp))))
 
+;; bug#61410
+(ert-deftest texmathp-verbatim ()
+  "Test for math command inside verbatim which is ignored."
+  (let ((TeX-install-font-lock #'font-latex-setup))
+    (should-not (with-temp-buffer
+                  (insert "a $b$ \\verb|$| c ")
+                  (LaTeX-mode)
+                  (font-lock-ensure)
+                  (texmathp)))
+
+    (should-not (with-temp-buffer
+                  (insert "\
+a $b$
+
+\\begin{verbatim}
+$
+\\end{verbatim}
+c")
+                  (LaTeX-mode)
+                  (font-lock-ensure)
+                  (texmathp)))))
+
 ;;; texmathp-test.el ends here
diff --git a/texmathp.el b/texmathp.el
index ad0089863a..1030ed858b 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -283,7 +283,7 @@ See the variable `texmathp-tex-commands' about which 
commands are checked."
                        (if (eq major-mode 'doctex-mode)
                            "[\n\r]%*[ \t]*[\n\r]"
                          "[\n\r][ \t]*[\n\r]")
-                                          nil 1 texmathp-search-n-paragraphs)
+                       nil 1 texmathp-search-n-paragraphs)
                       (match-beginning 0)
                     (point-min))))
          (mac-match (texmathp-match-macro bound))
@@ -321,12 +321,25 @@ See the variable `texmathp-tex-commands' about which 
commands are checked."
 
     ;; Store info, show as message when interactive, and return
     (setq texmathp-why match)
-    (and (called-interactively-p 'any)
-         (message "math-mode is %s: %s begins at buffer position %d"
-                  (if math-on "on" "off")
-                  (or (car match) "new paragraph")
-                  (cdr match)))
-    (and math-on t)))
+    ;; Check also if the match is inside a verbatim construct and
+    ;; return immediately nil.  This relies on the function
+    ;; `LaTeX-verbatim-p'.  We add a check here in case this library
+    ;; is used stand-alone without latex.el provided by AUCTeX
+    ;; (bug#61410):
+    (if (and (fboundp 'LaTeX-verbatim-p)
+             (save-excursion (LaTeX-verbatim-p (cdr match))))
+        (progn
+          (setq texmathp-why `(nil . ,(cdr match)))
+          (when (called-interactively-p 'any)
+            (message "math-mode is off: Math command in verbatim construct at 
buffer position %d"
+                     (cdr match)))
+          nil)
+      (and (called-interactively-p 'any)
+           (message "math-mode is %s: %s begins at buffer position %d"
+                    (if math-on "on" "off")
+                    (or (car match) "new paragraph")
+                    (cdr match)))
+      (and math-on t))))
 
 (defun texmathp-match-environment (bound)
   "Find out if point is inside any of the math environments.



reply via email to

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