aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-06-24 19:21:07 -0400
committerStefan Monnier2019-06-24 19:21:07 -0400
commit0ef31639593b97d6edc6dd263c915595a8fdc3b1 (patch)
tree1316e0a4a51c7c913dab335410a459a4abac424f
parent630e01a70312d8e6ad47aeba370228fc05c789a9 (diff)
downloademacs-0ef31639593b97d6edc6dd263c915595a8fdc3b1.tar.gz
emacs-0ef31639593b97d6edc6dd263c915595a8fdc3b1.zip
* 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.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/textmodes/tex-mode.el28
-rw-r--r--test/manual/indent/latex-mode.tex4
3 files changed, 30 insertions, 5 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 74a8bbe8fa1..0f764cd9986 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -475,6 +475,9 @@ current and the previous or the next line, as before.
475 475
476* Changes in Specialized Modes and Packages in Emacs 27.1 476* Changes in Specialized Modes and Packages in Emacs 27.1
477 477
478** tex-mode
479*** 'latex-noindent-commands' stops indenting arguments of \emph and friends
480
478** byte compiler 481** byte compiler
479*** byte-compile-dynamic is now obsolete 482*** byte-compile-dynamic is now obsolete
480This is because on the one hand it suffers from various misbehaviors in corner 483This 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 9c91d27b944..4511354a3d1 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'."
2803(defvar tex-indent-basic 2) 2803(defvar tex-indent-basic 2)
2804(defvar tex-indent-item tex-indent-basic) 2804(defvar tex-indent-item tex-indent-basic)
2805(defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>") 2805(defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
2806(defvar latex-noindent-environments '("document")) 2806(defcustom latex-noindent-environments '("document")
2807(put 'latex-noindent-environments 'safe-local-variable 2807 "Environments whose content is not indented by `tex-indent-basic'."
2808 (lambda (x) (null (delq t (mapcar #'stringp x))))) 2808 :type '(repeat string)
2809 :safe (lambda (x) (lambda (x) (memq nil (mapcar #'stringp x))))
2810 :group 'tex-file
2811 :version "27.1")
2812
2813(defcustom latex-noindent-commands '("emph" "footnote")
2814 "Commands for which `tex-indent-basic' should not be used."
2815 :type '(repeat string)
2816 :safe (lambda (x) (memq nil (mapcar #'stringp x)))
2817 :group 'tex-file
2818 :version "27.1")
2809 2819
2810(defvar tex-latex-indent-syntax-table 2820(defvar tex-latex-indent-syntax-table
2811 (let ((st (make-syntax-table tex-mode-syntax-table))) 2821 (let ((st (make-syntax-table tex-mode-syntax-table)))
@@ -2912,9 +2922,17 @@ There might be text before point."
2912 (current-column) 2922 (current-column)
2913 ;; We're the first element after a hanging brace. 2923 ;; We're the first element after a hanging brace.
2914 (goto-char up-list-pos) 2924 (goto-char up-list-pos)
2915 (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)") 2925 (+ (if (if (eq (char-after) ?\{)
2926 (save-excursion
2927 (skip-chars-backward " \t")
2928 (let ((end (point)))
2929 (skip-chars-backward "a-zA-Z")
2930 (and (eq (char-before) ?\\)
2931 (member (buffer-substring (point) end)
2932 latex-noindent-commands))))
2933 (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
2916 (member (match-string 1) 2934 (member (match-string 1)
2917 latex-noindent-environments)) 2935 latex-noindent-environments)))
2918 0 tex-indent-basic) 2936 0 tex-indent-basic)
2919 indent (latex-find-indent 'virtual)))) 2937 indent (latex-find-indent 'virtual))))
2920 ;; We're now at the "beginning" of a line. 2938 ;; 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 55c8e7033bd..d314b98b483 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
8\url{/lib/modules/$(uname -r)}, %bug#11953. 8\url{/lib/modules/$(uname -r)}, %bug#11953.
9and install the appropriate \url{gspca-modules} package. 9and install the appropriate \url{gspca-modules} package.
10 10
11Footnotes and emphasis shouldn't be indented \footnote{as can be seen here,
12for example}, \emph{or there
13as well}.
14
11\end{document} 15\end{document}