From f038de72cc8a5d2ba57ba797f7e69c41f5c823ec Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Wed, 30 Jul 2014 19:58:38 +0200
Subject: [PATCH] org.el: add function to indent environment inserted by
 cdlatex-enviroment

* lisp/org.el (org-cdlatex-environment-indent): TINYCHANGE new function `org-cdlatex-environment-indent' bound to "\C-c{" in `org-cdlatex-mode-map' to add a LaTeX environment and indent it.
---
 lisp/org.el |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 lisp/org.el

diff --git a/lisp/org.el b/lisp/org.el
old mode 100644
new mode 100755
index 0f7a4ef..8732840
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18405,7 +18405,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 (org-defkey org-cdlatex-mode-map "^" 'org-cdlatex-underscore-caret)
 (org-defkey org-cdlatex-mode-map "`" 'cdlatex-math-symbol)
 (org-defkey org-cdlatex-mode-map "'" 'org-cdlatex-math-modify)
-(org-defkey org-cdlatex-mode-map "\C-c{" 'cdlatex-environment)
+(org-defkey org-cdlatex-mode-map "\C-c{" 'org-cdlatex-environment-indent)
 
 (defvar org-cdlatex-texmathp-advice-is-done nil
   "Flag remembering if we have applied the advice to texmathp already.")
@@ -18483,6 +18483,13 @@ Revert to the normal definition outside of these fragments."
     (let (org-cdlatex-mode)
       (call-interactively (key-binding (vector last-input-event))))))
 
+(defun org-cdlatex-environment-indent (&optional environment item)
+  "Execute `cdlatex-environment' and indent the inserted environment."
+  (interactive)
+  (cdlatex-environment environment item)
+  (save-excursion
+    (org-mark-element)
+    (org-indent-region (point) (mark))))
 
 
 ;;;; LaTeX fragments
-- 
1.7.9

