Hi Tassilo,
> I'd welcome a patch that generalizes the idea a bit. For example, the
> ifplatform package provides macros like
>
> \ifwindows
> \this
> \else
> \that
> \fi
>
> and there are dozens of other \if-variants out there. So it would be
> good if an AUCTeX style file could specify that it provides a new
> if-then-else-fi macro, and then indentation should just work.
I've added the generalization to anything that starts with "\if".
Should be fine unless people use something like:
\newcommand\iffy{...}
See the attached patch.
regards,
Oleh
From f211541abf6f2260f1bab02f33b67b22a3939e89 Mon Sep 17 00:00:00 2001
From: Oleh Krehel <[email protected]>
Date: Thu, 18 Dec 2014 13:19:32 +0100
Subject: [PATCH] Add indentation for \if...-\else-\fi statements
* latex.el (LaTeX-begin-regexp): "\if" will now add to indentation
level. Note that there's no "\\b", so it can be e.g. "\ifdefined" or
"\ifwindows" etc.
(LaTeX-end-regexp): "\else" and "\fi" will now
subtract from indentation.
(LaTeX-indent-level-count): add a special case for "\else", since it
ends an indentation block and starts a new one at the same time.
---
latex.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/latex.el b/latex.el
index 477ef66..fcc1365 100644
--- a/latex.el
+++ b/latex.el
@@ -2912,12 +2912,12 @@ indentation level in columns."
:group 'LaTeX-indentation
:type 'regexp)
-(defcustom LaTeX-begin-regexp "begin\\b"
+(defcustom LaTeX-begin-regexp "begin\\b\\|if"
"*Regexp matching macros considered begins."
:group 'LaTeX-indentation
:type 'regexp)
-(defcustom LaTeX-end-regexp "end\\b"
+(defcustom LaTeX-end-regexp "\\(?:end\\|else\\|fi\\)\\b"
"*Regexp matching macros considered ends."
:group 'LaTeX-indentation
:type 'regexp)
@@ -3130,6 +3130,7 @@ outer indentation in case of a commented line. The symbols
(setq count (- count LaTeX-left-right-indent-level)))
((looking-at LaTeX-begin-regexp)
(setq count (+ count LaTeX-indent-level)))
+ ((looking-at "else\\b"))
((looking-at LaTeX-end-regexp)
(setq count (- count LaTeX-indent-level)))
((looking-at (regexp-quote TeX-esc))
--
1.8.4
_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex