如何安装 org-drill?

How to install org-drill?

我是 Emacs 新手,完成了 Emacs 和基本组织模式教程。 现在我想安装 org-drill。以下是我在 Emacs 上安装 org-drill 的失败尝试。

来自http://orgmode.org/worg/org-contrib/org-drill.html

Installation

The easiest way is to customise the variable 'org-modules' (M-x customize-variables RET org-modules) and make sure 'drill' is ticked.

我打开 spanish.org 文件并在 Emacs 中输入 "Meta-x customize-variables" 并且回显区域显示:

M-x customize-variables [No match]

所以我试试"Meta-x customize-variable"单数:

M-x customize-variable <RET> org-modules

自定义菜单对组织模块开放。 所以要么 "M-x customize-variables" 末尾的 's' 是说明中的错字,要么我做错了。

在自定义菜单中,我选中 "drill" 并单击 "Apply and Save" 按钮。

退出并重新启动 Emacs。

打开 spanish.org 文件。

在 Emacs 中键入 "M-x org-drill ",回显区域显示:

M-x org-drill-table-

为什么没有"org-drill"? 我输入:

M-x customize-variable <RET> org-modules

"Drill" 仍在检查中。

然后我尝试了手动安装说明:

For manual installation, put the following in your .emacs. You will also need to make sure that Org's "contrib/lisp" directory is in the emacs load-path.

(require 'org-drill)

我从 http://orgmode.org/cgit.cgi/org-mode.git/tree/contrib/lisp/org-drill.el 下载了 org-drill.el 并将其复制到 ~/emacsLoad/org-drill.el,然后将这些行添加到我的 .emacs 文件中:

(add-to-list 'load-path "~/emacsLoad/")
(require 'org-drill)

重新启动 Emacs 和*警告* window 说:

Warning (initialization): An error occurred while loading `/home/wolfv/.emacs':

Symbol's function definition is void: copy-list

因此,我使用 `--debug-init' 选项启动 Emacs 以查看完整的错误回溯。 *Backtrace* window 说:

Debugger entered--Lisp error: (void-function copy-list)
  copy-list((1 (quote org-drill-visible-cloze-face) nil))
  org-drill--compute-cloze-keywords()
  (defvar org-drill-cloze-keywords (org-drill--compute-cloze-keywords) nil)
  require(org-drill)
  eval-buffer(#<buffer  *load*> nil "/home/wolfv/.emacs" nil t)  ; Reading at buffer position 1727
  load-with-code-conversion("/home/wolfv/.emacs" "/home/wolfv/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "52

这是什么意思?我不懂 Lisp.

我输入:

M-x customize-variable <RET> org-modules

"Drill" 不再检查。

我很难过。如何在 Emacs 上安装 drill-org?

我正在使用 GNU Emacs 24.5.1(x86_64-redhat-linux-gnu,GTK+ 版本 3.16.6) 2015-09-14 于 buildvm-10。phx2.fedoraproject.org

这是我的 .emacs 文件:

;; load the built-in package manager
(require 'package)

;; add Emacs package repositories to the list of available repositories
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))

(add-to-list 'load-path "~/emacsLoad/")

;; disable automatic package loading
(setq package-enable-at-startup nil)

;; from  > RNA
(defun ensure-package-installed (&rest packages)
  "Assure every package is installed, ask for installation if it’s not.

Return a list of installed packages or nil for every skipped package."
  (mapcar
   (lambda (package)
     (if (package-installed-p package)
     nil
       (if (y-or-n-p (format "Package %s is missing. Install it? " package))
       (package-install package)
     package)))
   packages))

;; make sure to have downloaded archive description
(or (file-exists-p package-user-dir)
    (package-refresh-contents))

;; load installed packages
(package-initialize)

;; make sure these packages are installed
(ensure-package-installed 'evil)
;;(ensure-package-installed 'evil 'org-drill)

;; load the package into memory and call the main mode function
(require 'evil)
(evil-mode t)

(require 'org-drill)
;;(org-drill t)

;; display cursor's (row,col) position in mode line
(setq column-number-mode t)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(org-modules
   (quote
    (org-bbdb org-bibtex org-docview org-gnus org-info org-irc org-mhe org-rmail org-w3m org-drill))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

org-mode 使用此 init.el 文件:

(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'load-path "~/emacsLoad/")
(package-initialize) ;; load all elpa packages before require 'org-drill

(require 'cl)
(require 'package)
(require 'org-drill)

已从 http://orgmode.org/cgit.cgi/org-mode.git/tree/contrib/lisp/org-drill.el 下载 org-drill.el 并将其复制到 ~/emacsLoad/org-drill.el,

启动 Emacs。

打开文件spanish.org。

类型:M-x org-drill

按照屏幕底部的提示进行操作。

我对 Emacs 或 Org Mode(或 Elisp)几乎一无所知,但这就是我让它工作的方式。

首先,当 Emacs 在回溯中说 (void-function xxx) 时,这意味着 xxx 还没有被定义。经过多次谷歌搜索,我发现 copy-list 定义在一个名为 cl 的模块中,需要加载该模块。

org-drill.el 实际上在顶部注明了这种依赖关系:

(eval-when-compile (require 'cl))

所以我不知道为什么这不起作用。值得庆幸的是,我们可以自己加载它。

Org Drill 有很多其他依赖项,因此您不想自己管理它们。添加 Org Mode 的 elpa repository,然后安装包含 Org Drill 的 org-plus-contrib 包。

在您的 .emacs / .emacs.d/init.el 中,在顶部添加

(package-initialize)

这将加载您已安装的所有 elpa 包。通常,Emacs 在 init.el 之后加载 elpa 包,但我们想从 org-plus-contrib 包加载内容。

在此之后,您可以加载 clorg-drill:

(require 'cl)
(require 'org-drill)

参考资料

我所做的(在为此花费数小时之后)是:

mkdir --parents ~/.emacs.d/pkgs
cd !$
git clone git://orgmode.org/org-mode.git

然后我将其添加到 ~/.emacs:

(add-to-list 'load-path "~/.emacs.d/pkgs/org-mode/contrib/lisp/")       
(require 'org-drill)

在此之后,它就可以正常工作了。

*nix 发行版上的默认 emacs 似乎不提供 org-mode 的 contrib 包,而来自 git 存储库的那个则捆绑了“一切”。

official org-mode repository 中的 Org-drill 已过时(2015 年),这似乎是从 BitBucket 安装顶级版本的最佳决定。

先决条件:

首先请输入以下内容检查 Emacs 加载路径:

C-h v load-path <RET>

Emacs 应该输出您本地主机上所有路径的列表,它习惯性地从中寻找要加载的包。随意选择其中任何一个来分配扩展 Emacs 的可选包。

在我的特殊情况下,最相关的是 /usr/local/share/emacs/site-lisp/ 默认情况下它具有有限的访问权限,因此请确保您能够在那里写入:

$ ls -la /usr/local/share/emacs-lisp/

并可能添加此功能:

$ sudo chmod 777 /usr/local/share/emacs-lisp/

安装:

假设您的附加包的容器已准备好使用。因此:

  1. 在那里下载必要的包:

    $ cd /usr/local/share/emacs/site-lisp/

    $ wget https://bitbucket.org/eeeickythump/org-drill/raw/01b05cd7561ad69e5ec9c1200414d4fa128c9a17/org-drill.el

    $ wget http://orgmode.org/cgit.cgi/org-mode.git/plain/contrib/lisp/org-learn.el # org-learn 需要 org-drill

  2. (require 'org-drill) 添加到您的 Emacs 配置文件中

  3. 重新启动 Emacs

  4. 打开spanish.org

  5. 请欣赏!

以下是使用 use-package 自动加载 org-drill 以避免增加启动时间的方法:

(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)

(use-package org-drill
  :defer t
  :ensure org-plus-contrib
  :commands (org-drill)
  :config
  ;; Config options
  )

:ensure org-plus-contrib 将确保 Emacs 下载 org-plus-contrib,这是捆绑 org-drill 的地方。

:commands (org-drill)org-drill 命令创建自动加载。