From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: [PATCH] Indent code with TAB in Org buffer Date: Sun, 15 Aug 2010 02:43:57 -0400 Message-ID: <87mxsocr4i.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=37718 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OkWws-0005oO-LI for emacs-orgmode@gnu.org; Sun, 15 Aug 2010 02:44:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OkWwr-0001cd-Fm for emacs-orgmode@gnu.org; Sun, 15 Aug 2010 02:44:02 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:33366) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OkWwr-0001cZ-66 for emacs-orgmode@gnu.org; Sun, 15 Aug 2010 02:44:01 -0400 Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o7F6hxY9012706 for ; Sun, 15 Aug 2010 07:43:59 +0100 (BST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs org-mode mailing list --=-=-= With this patch TAB in a code block aligns the code according to the major mode. The macro could be used to do the same thing for other commands (i.e. allow other commands to be invoked in the Org buffer, but actually carried out in the code buffer.) Patch attached and in branch src-block-tab at git@github.com:dandavison/org-devel.git. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=src-block-tab.diff diff --git a/lisp/org-src.el b/lisp/org-src.el index baa2b11..fc15a83 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -435,6 +435,19 @@ the fragment in the Org-mode buffer." (message "%s" msg) t))) +(defmacro org-src-do-in-edit-buffer (&rest body) + "Evaluate BODY in edit buffer if there is a code block at point. +Return t if a code block was found at point, nil otherwise." + `(when (org-edit-src-code) + ,@body + (org-edit-src-exit) t)) + +(defun org-src-tab-command () + "Do what TAB does in the edit buffer for code block at point." + (org-src-do-in-edit-buffer + (funcall (key-binding (kbd "TAB"))))) + +(add-hook 'org-tab-first-hook 'org-src-tab-command) (defun org-edit-src-find-region-and-lang () "Find the region and language for a local edit. Return a list with beginning and end of the region, a string representing --=-=-= Dan --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--