Emacs:不能通过MELPA安装自动启动射弹

时间:2014-07-07 12:46:01

标签: emacs autostart melpa

我对emacs相当新鲜。事实上,我正在学习编辑器,并尝试设置一些可以复制的东西,然后转到项目内的文件中。从Code :: Blocks或记事本++的某些插件中获知的功能。

'弹'满足了这个需求,我通过MELPA安装了它。正确安装包,因为我可以通过M-x projectile-global-modeC-c p命令启动它。

但是,如果我将它放入我的.emacs文件中,Emacs会以错误开头:

Symbol's function definition is void: projectile-global-mode

我的.emacs文件的内容如下:

(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.
 )
(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.
 )
(global-whitespace-mode 1)
(global-linum-mode 1)

(require 'package)
(add-to-list 'package-archives
  '("melpa" . "http://melpa.milkbox.net/packages/") t)

(projectile-global-mode 1)

当我首先尝试(require 'projectile)时,我最终只会遇到另一个错误:

 'File error: Cannot open load file, projectile'

我正在使用Emacs 24.3.1。

如何正确地将其置于自动启动?

3 个答案:

答案 0 :(得分:7)

默认情况下,Emacs在评估init.el之后初始化包。因此,在标准设置中,在评估init时,包尚不可用。

仅在初始化软件包后使用(add-hook 'after-init-hook #'projectile-global-mode)启用Projectile,或使用以下代码在init.el的开头显式初始化软件包:

(require 'package)
(setq package-enable-at-startup nil) ; To avoid initializing twice
(package-initialize)

答案 1 :(得分:0)

你可以添加

'(initial-major-mode (quote projectile-global-mode))

到自定义设置变量部分中的.emacs(或init.el或任何调用文件的文件)文件。

或者,在较新版本的emacs中,菜单选项|自定义Emacs |特定选项您可以键入“initial-major-mode”,这将带您进入emacs可以使用该设置自定义的界面。只记得申请并保存

答案 2 :(得分:-1)

你必须首先加载射弹,例如使用这个:

(require 'projectile)
(projectile-global-mode)