From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Barnier Subject: [PATCH] [babel] Add option to display process buffer when editing R source code blocks Date: Wed, 07 Apr 2010 16:41:55 +0200 Message-ID: <87sk77tjd8.fsf@z.nozav.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzWSN-0006yC-ME for emacs-orgmode@gnu.org; Wed, 07 Apr 2010 10:42:15 -0400 Received: from [140.186.70.92] (port=45921 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzWSL-0006xq-6l for emacs-orgmode@gnu.org; Wed, 07 Apr 2010 10:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzWSJ-00078p-SH for emacs-orgmode@gnu.org; Wed, 07 Apr 2010 10:42:13 -0400 Received: from lo.gmane.org ([80.91.229.12]:49443) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzWSJ-00078b-Ca for emacs-orgmode@gnu.org; Wed, 07 Apr 2010 10:42:11 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NzWSF-00081k-Od for emacs-orgmode@gnu.org; Wed, 07 Apr 2010 16:42:07 +0200 Received: from z.nozav.org ([91.121.121.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Apr 2010 16:42:07 +0200 Received: from julien by z.nozav.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Apr 2010 16:42:07 +0200 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-orgmode@gnu.org Hi, This is a small patch to org-babel-R.el which allows to automatically display the R process buffer when editing R source code blocks with org-edit-src-code. A custom variable allows to choose between no process buffer (default), only the source code block and the process buffer, or the org file, the source code block and the process buffer. As I'm quite new to git, I hope my patch is usable, because I generated it from a org-babel-R.el file which already had some modifications from master. Sincerely, -- Julien --- contrib/babel/lisp/langs/org-babel-R.el | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/contrib/babel/lisp/langs/org-babel-R.el b/contrib/babel/lisp/langs/org-babel-R.el index 8b333cc..3924089 100644 --- a/contrib/babel/lisp/langs/org-babel-R.el +++ b/contrib/babel/lisp/langs/org-babel-R.el @@ -218,7 +218,32 @@ Currently, insert hline if column names in output have been requested." (if column-names-p (cons (car result) (cons 'hline (cdr result))) result)) - + + +(defcustom org-babel-R-edit-src-show-process nil + "Layout of windows while editing R source blocks in org files" + :group 'org-babel + :type '(choice (const :tag "No process buffer" nil) + (const :tag "Show source block and process buffer" "full") + (const :tag "Show org file, source block and process buffer" "split"))) + +(defadvice org-edit-src-code (around org-edit-src-code-with-R-process activate) + "Display process buffer when eidting R source code blocks" + (if org-babel-R-edit-src-show-process + (let* ((info (org-babel-get-src-block-info)) + (lang (first info)) + (R-src-block (and info (string= (upcase lang) "R")))) + ad-do-it + (when R-src-block + (cond ((string= org-babel-R-edit-src-show-process "split") + (split-window-vertically) + (ess-switch-to-end-of-ESS) + (other-window -1)) + ((string= org-babel-R-edit-src-show-process "full") + (delete-other-windows) + (ess-switch-to-end-of-ESS) + (other-window 1))))) + ad-do-it)) (provide 'org-babel-R) ;;; org-babel-R.el ends here -- 1.7.0.4