我一直在试验org-babel tutorial,它描述了如何将大量emacs init.el文件放入组织文件中。但是,我想使用org-mode 8(主要用于新的导出器),而且我在内置org-mode 7.9的gnu emacs 24.3.1(对于windows),所以我安装了org-mode来自elpa package manager,而不是使用内置版本。
我的问题是emacs加载了emacs附带的org-mode而不是我在elpa中安装的org-mode。有没有办法加载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
答案 0 :(得分:8)
在调用(package-initialize)
或任何其他组织函数之前放置org-babel-load-file
,您将获得ELPA版本。
答案 1 :(得分:2)
我使用相同类型的初始化,最近做了两个主要更改:
以下是我的init.el现在的样子,
https://github.com/d4gg4d/my-emacs/blob/master/init.el
此外,
答案 2 :(得分:2)
我也在基于组织的配置文件中配置软件包存储库,因此,在加载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))
答案 3 :(得分:2)
虽然已经解决并且只是有些相关,但我认为我会为那些不使用基于包的解决方案但需要卸载org和cedet / semantic等内容而不重新启动emacs的人提供此功能。
一般来说,基于起始名称regexp卸载一组功能,我会做这样的事情 - 这似乎比Andreas的答案中的硬编码版本更完整,这似乎并不涵盖所有加载的组织功能(至少在我的情况下)。
load-history
是一个庞大的文件关联列表 - >请求数,提供,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"
以满足您的需求,或者狂野使其成为一种模式。
这也可以修改为从load-history
获取所有已加载的组织功能,卸载它们,添加新的加载路径,然后从新位置重新加载这些相同的功能。
答案 4 :(得分: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
替换为您所使用的版本所在的目录。