Allow language-native TAB command in code blocks.

* org-src.el (org-src-tab-indents-natively): New variable controlling
    whether language-native TAB action should be performed
    (org-src-native-tab-command-maybe): New function to perform
    language-native TAB action.
    (org-tab-first-hook): Add `org-src-native-tab-command-maybe'
This commit is contained in:
Dan Davison 2010-09-02 11:57:03 -07:00
parent 7b188f7da5
commit 0d5791e7b7
1 changed files with 13 additions and 0 deletions

View File

@ -715,6 +715,19 @@ Org-babel commands."
(call-interactively
(lookup-key org-babel-map key)))))
(defvar org-src-tab-acts-natively nil
"If non-nil, the effect of TAB in a code block is as if it were
issued in the language major mode buffer.")
(defun org-src-native-tab-command-maybe ()
"Perform language-specific TAB action.
Alter code block according to effect of TAB in the language major
mode."
(and org-src-tab-acts-natively
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB"))))
(add-hook 'org-tab-first-hook 'org-src-native-tab-command-maybe)
(defun org-src-font-lock-fontify-block (lang start end)
"Fontify code block.
This function is called by emacs automatic fontification, as long