emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 0ef3163: * lisp/textmodes/tex-mode.el (latex-noinde


From: Stefan Monnier
Subject: [Emacs-diffs] master 0ef3163: * lisp/textmodes/tex-mode.el (latex-noindent-commands): New custom var
Date: Mon, 24 Jun 2019 19:21:12 -0400 (EDT)

branch: master
commit 0ef31639593b97d6edc6dd263c915595a8fdc3b1
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/textmodes/tex-mode.el (latex-noindent-commands): New custom var
    
    (latex-find-indent): Obey it.
    (latex-noindent-environments): Make it into a defcustom as well.
---
 etc/NEWS                          |  3 +++
 lisp/textmodes/tex-mode.el        | 28 +++++++++++++++++++++++-----
 test/manual/indent/latex-mode.tex |  4 ++++
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 74a8bbe..0f764cd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -475,6 +475,9 @@ current and the previous or the next line, as before.
 
 * Changes in Specialized Modes and Packages in Emacs 27.1
 
+** tex-mode
+*** 'latex-noindent-commands' stops indenting arguments of \emph and friends
+
 ** byte compiler
 *** byte-compile-dynamic is now obsolete
 This is because on the one hand it suffers from various misbehaviors in corner
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 9c91d27..4511354 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -2803,9 +2803,19 @@ Runs the shell command defined by 
`tex-show-queue-command'."
 (defvar tex-indent-basic 2)
 (defvar tex-indent-item tex-indent-basic)
 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
-(defvar latex-noindent-environments '("document"))
-(put 'latex-noindent-environments 'safe-local-variable
-     (lambda (x) (null (delq t (mapcar #'stringp x)))))
+(defcustom latex-noindent-environments '("document")
+  "Environments whose content is not indented by `tex-indent-basic'."
+  :type '(repeat string)
+  :safe (lambda (x) (lambda (x) (memq nil (mapcar #'stringp x))))
+  :group 'tex-file
+  :version "27.1")
+
+(defcustom latex-noindent-commands '("emph" "footnote")
+  "Commands for which `tex-indent-basic' should not be used."
+  :type '(repeat string)
+  :safe (lambda (x) (memq nil (mapcar #'stringp x)))
+  :group 'tex-file
+  :version "27.1")
 
 (defvar tex-latex-indent-syntax-table
   (let ((st (make-syntax-table tex-mode-syntax-table)))
@@ -2912,9 +2922,17 @@ There might be text before point."
               (current-column)
             ;; We're the first element after a hanging brace.
             (goto-char up-list-pos)
-            (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
+            (+ (if (if (eq (char-after) ?\{)
+                        (save-excursion
+                          (skip-chars-backward " \t")
+                          (let ((end (point)))
+                            (skip-chars-backward "a-zA-Z")
+                            (and (eq (char-before) ?\\)
+                                 (member (buffer-substring (point) end)
+                                         latex-noindent-commands))))
+                      (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
                         (member (match-string 1)
-                                latex-noindent-environments))
+                                latex-noindent-environments)))
                    0 tex-indent-basic)
                indent (latex-find-indent 'virtual))))
          ;; We're now at the "beginning" of a line.
diff --git a/test/manual/indent/latex-mode.tex 
b/test/manual/indent/latex-mode.tex
index 55c8e70..d314b98 100644
--- a/test/manual/indent/latex-mode.tex
+++ b/test/manual/indent/latex-mode.tex
@@ -8,4 +8,8 @@ To fix this, remove the \url{sn9c102.ko} from where it appears 
in
 \url{/lib/modules/$(uname -r)},  %bug#11953.
 and install the appropriate \url{gspca-modules} package.
 
+Footnotes and emphasis shouldn't be indented \footnote{as can be seen here,
+for example}, \emph{or there
+as well}.
+
 \end{document}



reply via email to

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