branch: elpa/cdlatex
commit c3089ace3ff00f460780e80780751bc272a1d7ba
Author: Carsten Dominik <[email protected]>
Commit: Carsten Dominik <[email protected]>
Indent environment when expansion key is indented
---
cdlatex.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/cdlatex.el b/cdlatex.el
index 821a1e9dfb..15a37adced 100644
--- a/cdlatex.el
+++ b/cdlatex.el
@@ -1069,10 +1069,13 @@ the template. This is mainly useful for \"items\" of
environments, where
(cdlatex-wrap-environment environment)
(let ((env environment) begpos (endmarker (make-marker))
(auto-label cdlatex-insert-auto-labels-in-env-templates)
- template)
+ template prefix)
(if (not env)
(setq env (completing-read "Environment: " cdlatex-env-alist-comb
nil nil "")))
- (if (not (bolp)) (newline))
+ (if (looking-back "^[ \t]*" (point-at-bol))
+ (setq prefix (match-string 0))
+ (setq prefix "")
+ (newline))
(setq begpos (point))
(if (try-completion env cdlatex-env-alist-comb)
(progn
@@ -1088,6 +1091,8 @@ the template. This is mainly useful for \"items\" of
environments, where
(save-excursion
(skip-chars-backward " \t\n")
(insert "\\\\")))))
+ (setq template
+ (replace-regexp-in-string "\n" (concat "\n" prefix)
template))
(insert template))
(insert "\\begin{" env "}\n?\n\\end{" env "}\n"))
(move-marker endmarker (point))
@@ -1096,7 +1101,7 @@ the template. This is mainly useful for \"items\" of
environments, where
(goto-char begpos)
(while (search-forward "AUTOFILE" (marker-position endmarker) t)
(backward-delete-char 8)
- (call-interactively 'cdlatex-insert-filename))
+ (call-interactively 'cdlatexi-nsert-filename))
;; Look for AUTOLABEL requests
(goto-char begpos)