From 2782cbad53e1f01a972adad1f2209c60cdc5a727 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Thu, 31 Jul 2014 11:08:44 +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 |   10 +++++++++-
 1 files changed, 9 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..5d4b5f7
--- 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,14 @@ 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)
+  (let ((element (org-element-at-point)))
+    (when element
+      (org-indent-region (org-element-property :begin element)
+                         (org-element-property :end element)))))
 
 
 ;;;; LaTeX fragments
-- 
1.7.9

