3

I may have missed something somewhere but I can't make babel work !

I have installed and enabled correctly python-mode and in org mode I enter the begin_src section by completing .

Everything stay grey and it with no code indentation, it seems that python isn't recognize.

In my .emacs I have loaded python for babel :

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (python . t)
   ))

The org file section looks like this :

#+BEGIN_SRC: python
def hello( ):
    print "hello"
#+END_SRC

I haven't seen it working on my computer yet and I keep dreaming of it every night !

Is there any org hero in the area ?

1 Answer 1

2

try:

(setq org-src-fontify-natively t
    org-src-preserve-indentation t
    org-src-tab-acts-natively t)

in your init file. This should give you syntax highlighting, allow you to indent as you would in python-mode, and preserve those indents when if you export. Also, get rid of the : after BEGIN_SRC. So your example should be:

#+BEGIN_SRC python
def hello():
    print "hello"
#+END_SRC

On my computer, with those options it looks like:enter image description here

And notice, I am still in org-mode :) With your cursor at the end of the src block, you can hit C-x C-e to evaluate your hello function, and print the result in the echo area at the bottom of your frame!

3
  • So cool ! It works ! Thank you, you made my dream come true :D Commented Dec 10, 2015 at 21:57
  • I am glad it worked for you. Now that you can use source code blocks in org-mode the way you want, now it's time to do your whole init file in org-mode, haha! : )
    – elethan
    Commented Dec 10, 2015 at 22:02
  • I began to configure emacs since about two weeks, now it's like a hobby ! cheers Commented Dec 10, 2015 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.