From f211541abf6f2260f1bab02f33b67b22a3939e89 Mon Sep 17 00:00:00 2001 From: Oleh Krehel 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