OK, here's the updated patch.
regards,
Oleh
From e7d4f74e5fd9bca75906c7b2c2e68695a09cbd78 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-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. "\if"
will now add to indentation level, unless there's a "{" on the same
line.
Note that there's no "\\b", so:
\ifdefinded will add indentation
\ifwindows will add indentation
\ifstrequal{#4}{} will not add indentation
---
latex.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/latex.el b/latex.el
index 477ef66..e2d1f68 100644
--- a/latex.el
+++ b/latex.el
@@ -2917,7 +2917,7 @@ indentation level in columns."
: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)
@@ -3129,7 +3129,13 @@ outer indentation in case of a commented line. The symbols
((looking-at "right\\b")
(setq count (- count LaTeX-left-right-indent-level)))
((looking-at LaTeX-begin-regexp)
- (setq count (+ count LaTeX-indent-level)))
+ (setq count (+ count LaTeX-indent-level)))
+ ((and (looking-at "if")
+ (not
+ (save-excursion
+ (search-forward "{" (line-end-position) t))))
+ (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