2013-07-02 22 views
11

Tôi đã thử nghiệm với org-babel tutorial mô tả cách đặt phần lớn tệp emacs init.el của bạn vào tệp org. Tuy nhiên, tôi muốn sử dụng chế độ org 8 (chủ yếu cho nhà xuất khẩu mới) và tôi đang sử dụng gnu emacs 24.3.1 (dành cho cửa sổ) đi kèm với chế độ org-mode 7.9, vì vậy tôi đã cài đặt chế độ org từ elpa package manager thay vì sử dụng phiên bản tích hợp sẵn.Khởi tạo Emacs dưới dạng tệp org: làm cách nào tôi có thể nhận được phiên bản đúng của chế độ org?

Vấn đề của tôi là các emacs tải chế độ org đi kèm với emacs thay vì emacs mà tôi đã cài đặt trong elpa. Có cách nào để tải chế độ org của elpa không? Đây là init.el của tôi, được sửa đổi từ hướng dẫn org-babel thành điểm (tôi nghĩ) thành phân phối chế độ org của tôi - nhưng kiến ​​thức lác nhác của tôi là tối thiểu vì vậy tôi không thực sự biết nó đang làm gì .

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

Trả lời

8

Đặt (package-initialize) trước khi có bất kỳ cuộc gọi nào đến org-babel-load-file hoặc bất kỳ chức năng Org nào khác và bạn sẽ nhận được phiên bản ELPA.

+1

Thực ra bạn phải đảm bảo '(gói-khởi tạo)' xuất hiện trước bất kỳ lệnh gọi nào đến bất kỳ chức năng 'Org' nào có tự động tải. Đó có thể là 'org-babel-load-file' nhưng không được bảo đảm. –

+0

Điều này làm việc một điều trị. Tôi đặt (gói-khởi tạo) vào đầu của init.el và org-mode 8 của tôi được nạp. –

+0

@ JonathanLeech-Pepin: điểm tốt, được cập nhật. – legoscia

1

được nạp sẽ vận chuyển org-mode và cài đặt phiên bản phát triển theo cách này

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

Thay PATH-TO-NEW-org-mode với thư mục phiên bản của bạn xuống theo mong muốn cư trú.

2

nào để cấu hình các kho gói trong một tập tin cấu hình org-based là tốt, vì vậy, để điều chỉnh đường tải tôi có điều này trong init.el của tôi trước khi tải 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

Mặc dù đã được giải quyết và chỉ liên quan một phần, tôi nghĩ tôi sẽ cung cấp cho những người không sử dụng giải pháp dựa trên gói nhưng cần phải tải những thứ như org và cedet/semantic, vv wit hout khởi động lại emacs.

Nói chung để dỡ một tập hợp các tính năng dựa trên tên bắt đầu regexp, tôi sẽ làm một cái gì đó như thế này - có vẻ hoàn chỉnh hơn phiên bản hardcoded từ câu trả lời của Andreas, mà dường như không bao gồm tất cả các tính năng được tải (Ít nhất là trong trường hợp của tôi).

load-history là danh sách assoc file khổng lồ -> reqs, cung cấp, 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)) 

Thay regexp "^org" cho phù hợp với nhu cầu của bạn, hoặc đi hoang dã và làm cho nó một defun.

Điều này cũng có thể được sửa đổi để lấy tất cả các đối tượng địa lý được tải từ load-history, dỡ chúng, thêm đường dẫn tải mới và tải lại các tính năng tương tự từ vị trí mới.

+0

Cảm ơn! Hiểu rõ cách tiếp cận của tôi không phải là thông minh :) –

+0

Ngược lại! Cách tiếp cận và câu trả lời của bạn là của tôi cho đến nay =) – assem

Các vấn đề liên quan