emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [org-babel] Using the power of ESS inside an R source code


From: Dan Davison
Subject: [Orgmode] Re: [org-babel] Using the power of ESS inside an R source code block
Date: Wed, 27 Oct 2010 09:54:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Bernd Weiss <address@hidden> writes:

[...]

>>>>> 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.
>

Hi Bernd,

> 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)
> }

This should do that:

(setq org-edit-src-content-indentation 0)

Note that even if that variable has a value greater than zero, the
initial spaces are automatically removed when you go to the edit buffer
with C-c ', and also in tangled output.

>> 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)
>>

[...]

> 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".

That doesn't seem right. The above code needs to be evaluated /after/
Org-mode has loaded. But, once Org is loaded, that variable should
exist. For example, you should be able to call up the documentation for
the variable using

C-h v org-mode-map RET

Or alternatively, place the cursor immediately after the "p" of map, and
use C-x C-e to see the value displayed in the minibuffer. Do those work
for you?

How are you evaluating the above code? If you are putting it in your
.emacs and restarting emacs, then make sure it is after the part that
loads Org-mode. As a test, you could also try evaluating it with emacs
and Org-mode running: to evaluate an expression, place the cursor
immediately after the final parenthesis and use C-x C-e.

> I also guess that I should
> change "dan/org-underscore-command"...

As long as the names used in the function definition [the expression
starting "(defun ..."] match the names used in the corresponding
define-key expression then it'll be OK. There's no problem leaving the
names as they are. It tends to be a good idea to reserve names starting
with org- for things that are officially part of Org-mode.

Dan

>
> However, you should not care about my little elips problems. You were
> really helpful in solving my most important problems!
>
> Thanks,
>
> Bernd
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]