11

我一直在尝试org-babel 教程,该教程描述了如何将大部分 emacs init.el 文件放入 org 文件中。但是,我想使用 org-mode 8(主要用于新的导出器)并且我使用的是 gnu emacs 24.3.1(用于 windows),它内置了 org-mode 7.9,所以我安装了 org-mode从elpa 包管理器,而不是使用内置版本。

我的问题是emacs加载了emacs附带的org-mode,而不是我在elpa中安装的。有没有办法加载 elpa 组织模式?

这是我的 init.el,从 org-babel 教程修改为(我认为)指向我的 org-mode 发行版 - 但我的 emacs-lisp 知识很少,所以我真的不知道它在做什么。

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

5 回答 5

9

放在对任何其他 Org 函数的(package-initialize)调用之前,您将获得 ELPA 版本。org-babel-load-file

于 2013-07-02T09:58:43.250 回答
3

我使用相同类型的初始化,最近做了两个主要更改:

这是我的 init.el 现在的样子,

https://github.com/d4gg4d/my-emacs/blob/master/init.el

还,

  • 我删除了 ubuntu 附带的 .deb 打包的 org-mode
于 2013-07-02T11:41:55.073 回答
3

虽然已经解决并且只是有些相关,但我想我会为那些不使用基于包的解决方案但需要在不重新启动 emacs 的情况下卸载 org 和 cedet/semantic 等内容的人提供这个。

一般来说,对于基于起始名称正则表达式卸载一组功能,我会做这样的事情 - 这似乎比 Andreas 的答案中的硬编码版本更完整,它似乎没有涵盖所有加载的 org 功能(至少在我的情况)。

load-history是一个庞大的文件关联列表 -> 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))

替换正则表达式"^org"以满足您的需要,或者疯狂并使其成为一个defun。

这也可以修改为从 中获取所有已加载的组织功能load-history,卸载它们,添加新的加载路径,并从新位置重新加载这些相同的功能。

于 2013-07-04T03:38:12.133 回答
2

我也在基于 org 的配置文件中配置包存储库,因此,为了调整加载路径,我在加载 org 之前在我的 init.el 中有这个:

;; 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))
于 2013-07-02T13:33:50.107 回答
1

以这种方式卸载了已发布的 org-mode 并安装了开发版本

(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为您希望的版本所在的目录。

于 2013-07-02T06:01:17.870 回答