You are not logged in.

#1 2010-10-26 14:59:19

Ben9250
Member
From: Bath - England
Registered: 2010-06-10
Posts: 208
Website

Emacs and babel [SOLVED]

This is not so much a programming question more an Emacs and R one.

I'm wanting to use babel and org mode with R to export to PDF and the code chunks I put in, be processed and then the results put in the final pdf - like what Sweave does in LyX or latex.

I've been reading around the documentation for org-mode but to my understanding everything is on Emacs on Emacs23. I followed the instructions at this page:http://orgmode.org/manual/Languages.html#Languages and similar ones to do with the different languages from R to C++, so far nothing explicit other than "Evaluate you .emacs file" (Very helpful). Eventually I managed to find a bit that said to put the following in my .emacs file at the end:

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

I did that and then I get the following error from EMACS:

Warning (initialization): An error occurred while loading `/home/ben/.emacs':

Symbol's function definition is void: org-babel-do-load-languages

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

Now I'm a bit stuck as to what to do - considering how cryptic the instructions are being about setting up org-mode and babel. There's lots on how to write documents with it once it's set up, but little on actually getting set up.

My current .emacs file contains:

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(display-mm-dimensions-alist (quote ((t 0 . 0))))
 '(sql-sqlite-program "sqlite3"))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file s͂7hould contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(border ((t (:height 2)))))
(defun org-mode-reftex-setup ()
(load-library "reftex")
(and (buffer-file-name)
(file-exists-p (buffer-file-name))
(reftex-parse-all))
(define-key org-mode-map (kbd "C-c )") 'reftex-citation)
)
(org-babel-do-load-languages
      'org-babel-load-languages
      '((emacs-lisp . nil)
        (R . t)))

I use Emacs for ESS and sql-mode already but the lack of instruction is beginning to wear down on me. Does anybody know what I need to do? I have a basic Emacs from package manager with ESS added on. No other real customisation or settings.

Thanks to anyone who can help in advance,
Ben.

Last edited by Ben9250 (2010-10-26 19:54:16)


"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
  - H. G. Wells

Offline

#2 2010-10-26 15:47:27

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 462
Website

Re: Emacs and babel [SOLVED]

Well, Emacs is being pretty clear - there's no such function as 'org-babel-do-load-languages' currently defined in your emacs. I'm not familiar with that function, but it evaluates fine in my Emacs. If you copy'n'paste the elisp for it, and evalute it in your *scratch* buffer, does it work?

Offline

#3 2010-10-26 18:52:07

Ben9250
Member
From: Bath - England
Registered: 2010-06-10
Posts: 208
Website

Re: Emacs and babel [SOLVED]

I just got some instruction from my lecturer to install the latest version, and try it from there.

# Name of your emacs binary
EMACS=emacs

# Where local software is found
prefix=/usr/local

# Where local lisp files go.
lispdir   = $(prefix)/share/emacs/site-lisp

# Where info files go.
infodir = $(prefix)/share/info

This is currently what I have the Makefile set to, as I understand it according to the manual, this, and "make install", will copy everything and set it up in the system directory. And if I wanted it to be local I could direct emacs just to read from the Org distribution with:

(setq load-path (cons "~/path/to/orgdir/lisp" load-path))

In the .emacs file. I'm going for the first option though.


"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
  - H. G. Wells

Offline

#4 2010-10-26 19:02:58

Ben9250
Member
From: Bath - England
Registered: 2010-06-10
Posts: 208
Website

Re: Emacs and babel [SOLVED]

Ok I've installed everything and put the following into the .emacs file:

(require 'org-install)

;; The following lines are always needed. Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

(global-font-lock-mode 1)
; for all buffers

;;;orgbabel;;;;

(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)
    ))

The last part being the bit about babel - the business end for R. Now I don't need to install anything else? Or any other lisp's for babel? But! The .emacs file is not producing any errors now when I start emacs up.

[EDIT] Everything work's now I've installed an external - more up to date distribution of Org!

Last edited by Ben9250 (2010-10-26 19:53:54)


"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
  - H. G. Wells

Offline

Board footer

Powered by FluxBB