From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernd Weiss Subject: Re: [org-babel] Using the power of ESS inside an R source code block Date: Tue, 26 Oct 2010 20:35:59 -0400 Message-ID: <4CC773EF.3010202@uni-koeln.de> References: <4CC40000.3090508@uni-koeln.de> <4CC40673.6030403@uni-koeln.de> <87r5feuz0y.fsf@gmail.com> <87tyk9f3sb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=36408 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAtzw-0000Db-D5 for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 20:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAtzv-000774-2Y for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 20:36:12 -0400 Received: from smtp-out.rrz.uni-koeln.de ([134.95.19.53]:46284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAtzu-00076b-Pt for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 20:36:11 -0400 In-Reply-To: <87tyk9f3sb.fsf@gmail.com> 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: Dan Davison Cc: emacs-orgmode@gnu.org Am 26.10.2010 10:05, schrieb Dan Davison: [...] >>> Am 24.10.2010 05:44, schrieb Bernd Weiss: [...] >>>> Dear all, >>>> >>>> Yesterday, I spent some time (re-)discovering the power of org-babel >>>> and R. Everything works well but there is one issue that I find >>>> somewhat annoying (I apologise if this word is too rude). > > Not at all. Good to know what drawbacks users are encountering. I'm > happy to report that all three of the things you mention are now > possible in the Org buffer. You will need to be using a recent version > of Org-mode (i.e. from within the last few weeks). Hi Dan & Eric, Again (and now on-list), thanks a lot for your reply and your help! >>>> As a >>>> long-time ESS user I wish that I could use things like ESS syntax >>>> highlighting, > > This, as Eric mentioned, is turned on with > `org-src-fontify-natively'. However from your config below it seems you > have set this variable. So that requires some explanation -- please let > us know if syntax highlighting in the Org buffer is working for you or > not. Yes, syntax highlighting seems to be work as expected. >>>> indentation > > Setting `org-src-tab-acts-natively' causes TAB to have the indenting > effect that you would get in an ESS buffer.[2] That also works. I only have a very (very) basic knowledge of elips. So, I guess it is possible to change the "depth" of indentation. The current indentation behaviour is as follows: #+BEGIN_SRC R :results output :exports results library(MASS) plot(1,1) for(i in 1:10){ print(i) } [...] However, I would prefer... #+BEGIN_SRC R :results output :exports results library(MASS) plot(1,1) for(i in 1:10){ print(i) } [...] > Beyond these two variables, there is a general method that addresses the > issues you are raising. It involves using the function > `org-babel-do-key-sequence-in-edit-buffer'. For example, here is how to > make C-M-\ perform language-specific indentation on the active region in > the source block: > > (defun dan/org-indent-region () > (interactive) > (or (org-babel-do-key-sequence-in-edit-buffer "\C-\M-\\") > (indent-region))) > > (define-key org-mode-map "\C-\M-\\" 'dan/org-indent-region) > > >>>> or some keybindings (e.g. for "<-") inside >>>> an R source code block. > > This one can be done with > > (defun dan/org-underscore-command () > (interactive) > (or (org-babel-do-key-sequence-in-edit-buffer "_") > (org-self-insert-command 1))) > > (define-key org-mode-map "_" 'dan/org-underscore-command) > > And another one that you may like is for commenting code: > > (defun dan/org-comment-dwim (&optional arg) > (interactive "P") > (or (org-babel-do-key-sequence-in-edit-buffer "\M-;") > (comment-dwim arg))) > > (define-key org-mode-map "\M-;" 'dan/org-comment-dwim) > > > I hope the above supplies the missing functionality. > > Dan Puh, as I told you I only have a very basic understanding of elisp... If I do a simple copy and paste, I see this error: "Symbol's value as variable is void: org-mode-map". I also guess that I should change "dan/org-underscore-command"... However, you should not care about my little elips problems. You were really helpful in solving my most important problems! Thanks, Bernd