Ikumi Keita writes:
> This time it doesn't seem to show abnormal behavior. :-)
Thanks for checking. Attached is also a diff against latex.el. If
there are no other comments I will try to commit it tomorrow incl. a
test and announcement etc.
Best, Arash
diff --git a/latex.el b/latex.el
index 142d075c..78451932 100644
--- a/latex.el
+++ b/latex.el
@@ -3751,9 +3751,11 @@ value."
(defvar docTeX-indent-inner-fixed
`((,(concat (regexp-quote TeX-esc)
- "\\(begin\\|end\\)[ \t]*{macrocode\\*?}") 4 t)
+ "\\(begin\\|end\\)[ \t]*{macrocode\\*?}")
+ 4 t)
(,(concat (regexp-quote TeX-esc)
- "\\(begin\\|end\\)[ \t]*{\\(macro\\|environment\\)\\*?}") 0 nil))
+ "\\(begin\\|end\\)[ \t]*{\\(macro\\|environment\\)\\*?}")
+ 0 nil))
"List of items which should have a fixed inner indentation.
The items consist of three parts. The first is a regular
expression which should match the respective string. The second
@@ -3762,6 +3764,110 @@ toggles if comment padding is relevant or not. If t padding is
part of the amount given, if nil the amount of spaces will be
inserted after potential padding.")
+(defvar-local LaTeX-indent-begin-list nil
+ "List of macros increasing indentation.
+Each item in this list is a string with the name of the macro
+without a backslash. The final regexp will be calculated by the
+function `LaTeX-indent-commmands-regexp-make'. A regexp for the
+\\if contructs is added by the function as well. AUCTeX styles
+should add their macros to this variable and then run
+`LaTeX-indent-commmands-regexp-make'.")
+
+(defvar-local LaTeX-indent-begin-exceptions-list nil
+ "List of macros which shouldn't increase the indentation.
+Each item in this list is a string without a backslash and will
+mostly start with 'if'. These macros should not increase
+indentation although they start with 'if', for example the
+'ifthenelse' macro provided by the ifthen package. AUCTeX styles
+should add their macros to this variable and then run
+`LaTeX-indent-commmands-regexp-make'.")
+
+(defvar-local LaTeX-indent-mid-list nil
+ "List of macros which backindent the line where they appear.
+Each item in this list is a string with the name of the macro
+without a backslash. The final regexp will be calculated by the
+function `LaTeX-indent-commmands-regexp-make' which takes care of
+\\else and \\or. AUCTeX styles should add their macros to this
+variable and then run `LaTeX-indent-commmands-regexp-make'.")
+
+(defvar-local LaTeX-indent-end-list nil
+ "List of macros decreasing indentation.
+Each item in this list is a string with the name of the macro
+without a backslash. The final regexp will be calculated by the
+function `LaTeX-indent-commmands-regexp-make' which takes care of
+\\fi. AUCTeX styles should add their macros to this variable and
+then run `LaTeX-indent-commmands-regexp-make'.")
+
+(defvar-local LaTeX-indent-begin-regexp-local nil
+ "Regexp calculated from `LaTeX-indent-begin-list'.
+The value is calculated and set by the function
+`LaTeX-indent-commmands-regexp-make' which already takes care of
+\\if constructs.")
+
+(defvar-local LaTeX-indent-begin-regexp-exceptions-local nil
+ "Regexp calculated from `LaTeX-indent-begin-exceptions-list'.
+The value is calculated and set by the function
+`LaTeX-indent-commmands-regexp-make' which already takes care of
+\\ifthenelse.")
+
+(defvar-local LaTeX-indent-mid-regexp-local nil
+ "Regexp calculated from `LaTeX-indent-mid-list'.
+The value is calculated and set by the function
+`LaTeX-indent-commmands-regexp-make' which already takes care of
+\\else and \\or.")
+
+(defvar-local LaTeX-indent-end-regexp-local nil
+ "Regexp calculated from `LaTeX-indent-end-list'.
+The value is calculated and set by the function
+`LaTeX-indent-commmands-regexp-make' which already takes care of
+\\fi.")
+
+(defun LaTeX-indent-commmands-regexp-make ()
+ "Calculate final regexp for adjusting indentation.
+This function takes the elements provided in
+`LaTeX-indent-begin-list', `LaTeX-indent-begin-exceptions-list',
+`LaTeX-indent-mid-list' and `LaTeX-indent-end-list' and generates
+the regexp's which are stored in
+`LaTeX-indent-begin-regexp-local',
+`LaTeX-indent-begin-regexp-exceptions-local',
+`LaTeX-indent-mid-regexp-local' and
+`LaTeX-indent-end-regexp-local' accordingly. Some standard
+macros are added to the regexp's. This function is called in
+`LaTeX-common-initialization' to set the regexp's."
+ (let* (cmds
+ symbs
+ (func (lambda (in regexp out)
+ (setq cmds nil
+ symbs nil)
+ (dolist (elt in)
+ (if (string-match "[^a-zA-Z@]" elt)
+ (push elt symbs)
+ (push elt cmds)))
+ (set out (concat regexp
+ (when cmds
+(concat "\\|"
+(regexp-opt