繁体   English   中英

Emacs初始化为org文件:如何获得正确版本的org-mode?

[英]Emacs initialization as org file: how can I get the right version of org-mode?

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

我的问题是,emacs加载了emacs附带的组织模式,而不是我在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

在调用org-babel-load-file或任何其他Org函数之前放(package-initialize) ,你就会得到ELPA版本。

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

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

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

也,

  • 我删除了随ubuntu一起提供的.deb打包的org-mode

我也在基于组织的配置文件中配置软件包存储库,因此,在加载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))

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

一般来说,基于起始名称regexp卸载一组功能,我会做这样的事情 - 这似乎比安德烈亚斯答案的硬编码版本更完整,这似乎并不涵盖所有加载的组织功能(至少在我的情况)。

load-history是一个庞大的文件关联列表 - > reqs,provide,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获取所有已加载的组织功能,卸载它们,添加新的加载路径,并从新位置重新加载这些相同的功能。

以这种方式卸载已发布的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替换为您所使用的版本所在的目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM