I've been experimenting with the org-babel tutorial that describes how to put the bulk of your emacs init.el file into an org file. However, I would like to use org-mode 8 (mainly for the new exporter) and I'm on gnu emacs 24.3.1 (for windows) which comes with org-mode 7.9 built-in, so I have org-mode installed from the elpa package manager instead of using the built-in version.
My problem is that emacs loads the org-mode that comes with emacs rather than the one I have installed in elpa. Is there a way to load the elpa org-mode?
Here is my init.el, modified from the org-babel tutorial to point (I thought) to my org-mode distribution - but my emacs-lisp knowledge is minimal so I don't really know what it is doing.
;;; From http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming
;;; init.el --- Where all the magic begins
;;
;; This file loads Org-mode and then loads the rest of our Emacs initialization from Emacs lisp
;; embedded in literate Org-mode files.
;; Load up Org Mode and (now included) Org Babel for elisp embedded in Org Mode files
(setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
(let* ((org-dir (expand-file-name
"elpa" (expand-file-name
"org-plus-contrib-20130624" )))
(org-contrib-dir (expand-file-name
"lisp" (expand-file-name
"contrib" (expand-file-name
".." org-dir))))
(load-path (append (list org-dir org-contrib-dir)
(or load-path nil))))
;; load up Org-mode and Org-babel
(require 'org-install)
(require 'ob-tangle))
;; load up all literate org-mode files in this directory
(mapc #'org-babel-load-file (directory-files dotfiles-dir t "\\.org$"))
;;; init.el ends here
I use same kind of initialization and recently did two major changes:
Here's how my init.el looks now,
https://github.com/d4gg4d/my-emacs/blob/master/init.el
Also,
Though already solved and only somewhat related, I thought I would offer this for those who don't use package-based solutions but need to unload things like org and cedet/semantic, etc. without restarting emacs.
In general for unloading a set of features based on a starting name regexp, I would do something like this - which seems more complete than the hardcoded version from Andreas' answer, which doesn't seem to cover all loaded org features (at least in my case).
load-history
is a massive assoc list of files -> reqs,provides,defuns,...
(mapc
#'(lambda (f) (and (featurep f) (unload-feature f t)))
(loop for file-syms in load-history
for prov = (assoc 'provide file-syms)
with features
if (and prov (string-match "^org" (symbol-name (cdr prov))))
collect (cdr prov) into features
finally return features))
Replace the regexp "^org"
to suit your needs, or go wild and make it a defun.
This could also be modified to grab all loaded org features from load-history
, unload them, add the new load-path, and reload those same features from the new location.
Put (package-initialize)
before any calls to org-babel-load-file
or any other Org function, and you'll get the ELPA version.
I configure package repositories in an org-based configuration file as well, so, to adjust the load path I have this in my init.el prior to loading org:
;; remove org-mode shipped with emacs from the load-path
(setq custom-org-path (car (file-expand-wildcards
(concat my-init-dir "elpa/org-plus-contrib-20*"))))
(when custom-org-path
(setq load-path (remove-if (lambda (x) (string-match-p "org$" x)) load-path))
(add-to-list 'load-path custom-org-path))
Unloaded shipped org-mode and installed development version this way
(defun unload-org-mode ()
(interactive)
(and (featurep 'org-agenda)(unload-feature 'org-agenda t ))
(and (featurep 'org-bbdb)(unload-feature 'org-bbdb t ))
(and (featurep 'org-bibtex)(unload-feature 'org-bibtex t ))
(and (featurep 'org-compat)(unload-feature 'org-compat t ))
(and (featurep 'org-exp)(unload-feature 'org-exp t ))
(and (featurep 'org-exp-blocks)(unload-feature 'org-exp-blocks t ))
(and (featurep 'org-faces)(unload-feature 'org-faces t ))
(and (featurep 'org-footnote)(unload-feature 'org-footnote t ))
(and (featurep 'org-gnus)(unload-feature 'org-gnus t ))
(and (featurep 'org-html)(unload-feature 'org-html t ))
(and (featurep 'org-info)(unload-feature 'org-info t ))
(and (featurep 'org-infojs)(unload-feature 'org-infojs t ))
(and (featurep 'org-irc)(unload-feature 'org-irc t ))
(and (featurep 'org-jsinfo)(unload-feature 'org-jsinfo t ))
(and (featurep 'org-list)(unload-feature 'org-list t ))
(and (featurep 'org-macs)(unload-feature 'org-macs t ))
(and (featurep 'org-mew)(unload-feature 'org-mew t ))
(and (featurep 'org-mhe)(unload-feature 'org-mhe t ))
(and (featurep 'org-rmail)(unload-feature 'org-rmail t ))
(and (featurep 'org-src)(unload-feature 'org-src t ))
(and (featurep 'org-vm)(unload-feature 'org-vm t))
(and (featurep 'org-w3m)(unload-feature 'org-w3m t))
(and (featurep 'org-wl)(unload-feature 'org-wl t )))
(defun ar-load-PATH-TO-NEW-org-mode ()
(interactive)
(unload-org-mode)
(find-file "~/PATH-TO-NEW-org-mode/lisp/ob-python.el")
(add-to-list 'load-path "~/PATH-TO-NEW-org-mode")
(add-to-list 'load-path "~/PATH-TO-NEW-org-mode/lisp")
(load "~/PATH-TO-NEW-org-mode/lisp/ob-comint.el" nil t)
(load "~/PATH-TO-NEW-org-mode/lisp/ob-emacs-lisp.el" nil t)
(load "~/PATH-TO-NEW-org-mode/lisp/org.el" nil t)
(load "~/PATH-TO-NEW-org-mode/lisp/ob-eval.el" nil t)
(load "~/PATH-TO-NEW-org-mode/lisp/ob.el" nil t)
(load "~/PATH-TO-NEW-org-mode/lisp/ob-python.el")
;; (load "~/PATH-TO-NEW-org-mode/testing/org-test-ob-consts.el" nil t)
;; (load "~/PATH-TO-NEW-org-mode/testing/org-test.el" nil t)
(load-this-directory "~/PATH-TO-NEW-org-mode/lisp")
(org-babel-do-load-languages
'org-babel-load-languages
'(
(sh . t)
(python . t)
(emacs-lisp . t)
(perl . t)
(R . t)
))
)
(ar-load-PATH-TO-NEW-org-mode)
Replace PATH-TO-NEW-org-mode
with the directory your version whished resides.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With