2013-07-02 9 views
11

Ich habe experimentiert mit der org-babel tutorial, die beschreibt, wie Sie den Großteil Ihrer Emacs init.EL-Datei in eine Organisationsdatei legen. Allerdings würde ich gerne org-mode 8 (hauptsächlich für den neuen exporter) verwenden und ich bin auf gnu emacs 24.3.1 (für windows), das mit org-mode 7.9 kommt, also habe ich org-mode installiert von der elpa package manager anstelle der eingebauten Version.Emacs Initialisierung als Org-Datei: Wie bekomme ich die richtige Version des Org-Modus?

Mein Problem ist, dass Emacs lädt den Org-Modus, der mit Emacs kommt, anstatt die, die ich in Elpa installiert habe. Gibt es eine Möglichkeit den elpa org-Modus zu laden?

Hier ist meine init.el, modifiziert von der org-babel Tutorial zu zeigen (ich dachte) zu meinem org-Modus Verteilung - aber meine Emacs-Lisp Wissen ist minimal, so dass ich nicht wirklich weiß, was es tut .

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

Antwort

8

Setzen Sie (package-initialize) vor allen Aufrufen an org-babel-load-file oder eine andere Org-Funktion, und Sie erhalten die ELPA-Version.

+1

Eigentlich muss man sicherstellen, dass '(package-initialize)' vor jedem Aufruf einer 'Org'-Funktion mit Autoloads steht. Das ist wahrscheinlich "org-babel-load-file", aber nicht garantiert. –

+0

Das hat gut funktioniert. Ich habe (package-initialize) am Anfang von meinem init.el und org-mode 8 geladen. –

+0

@ JonathanLeech-Pepin: guter Punkt, aktualisiert. – legoscia

1

Unloaded ausgeliefert org-Modus und installiert Entwicklungsversion auf diese Weise

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

PATH-TO-NEW-org-mode Ersetzen mit dem Verzeichnis Ihrer Version wohnt whished.

2

ich konfigurieren Paket-Depots in einem org-basierte Konfigurationsdatei als auch, so die Laststrecke einstellen I haben dies in meinem init.el vor dem Laden 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)) 
2

Obwohl bereits gelöst und nur ein wenig verwandt, ich dachte, dass ich dies für diejenigen anbieten würde, die nicht über Paket-basierte Lösungen nutzen, müssen aber entladen Dinge wie org und cedet/semantisch, etc. wit hout Neustart Emacs.

Im Allgemeinen zum Entladen einer Reihe von Funktionen basierend auf einem Startnamen regexp, würde ich so etwas tun - das scheint vollständiger als die hardcoded Version von Andreas 'Antwort, die nicht alle geladenen org Funktionen abdecken scheint (zumindest in meinem Fall).

load-history ist eine massive Assoc Liste der Dateien -> reqs liefert, 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)) 

Ersetzen Sie die regexp "^org" an Ihre Bedürfnisse anzupassen, oder wild gehen und es ein defun zu machen.

Dies könnte auch geändert werden, um alle geladenen Organisationsfeatures von load-history zu übernehmen, sie zu entladen, den neuen Ladepfad hinzuzufügen und dieselben Funktionen von dem neuen Speicherort erneut zu laden.

+0

Danke! Gut zu wissen, dass mein Ansatz nicht so schlau war :) –

+0

Im Gegenteil! Dein Ansatz & Antwort war mein bisheriger =) – assem

Verwandte Themen