Answers:
这是可能的:
(setq LaTeX-begin-regexp "\\(?:begin\\|if@\\)\\b")
(setq LaTeX-end-regexp "\\(?:end\\|else\\|fi\\)\\b")
(defun LaTeX-indent-level-count ()
"Count indentation change caused by all \\left, \\right, \\begin, and
\\end commands in the current line."
(save-excursion
(save-restriction
(let ((count 0))
(narrow-to-region (point)
(save-excursion
(re-search-forward
(concat "[^" TeX-esc "]"
"\\(" LaTeX-indent-comment-start-regexp
"\\)\\|\n\\|\\'"))
(backward-char)
(point)))
(while (search-forward TeX-esc nil t)
(cond
((looking-at "left\\b")
(setq count (+ count LaTeX-left-right-indent-level)))
((looking-at "right\\b")
(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))
(forward-char 1))))
count))))
请注意,我必须重新定义LaTeX-indent-level-count
。diff只是一个cond
分支:
((looking-at "else\\b"))
\else
。的位置\else
是正确的,但是下面的代码(\doanotherthin
,请参阅问题)仍在第一列而不是第3列。会有所帮助,但我失败了(至少在之后再次缩进\else
)。这是我的部分工作代码:有(setq LaTeX-begin-regexp "\\(?:begin\\|if\\|ifx\\|else\\)\\b")
什么想法吗?