Emacs:无法通过MELPA自动启动弹丸

Zal*_*aPL 5 emacs autostart melpa

我是emacs的新手.事实上,我正在学习编辑器并尝试设置一些可以复制"转到项目内部的文件"的功能,这些功能可以从Code :: Blocks或记事本++的某些插件中获知.

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

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

Symbol's function definition is void: projectile-global-mode
Run Code Online (Sandbox Code Playgroud)

我的.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)
Run Code Online (Sandbox Code Playgroud)

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

 'File error: Cannot open load file, projectile'
Run Code Online (Sandbox Code Playgroud)

我正在使用Emacs 24.3.1.

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

lun*_*orn 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)
Run Code Online (Sandbox Code Playgroud)

  • @ZalewaPL您可能应该向Github上的Projectile报告.对我来说看起来像个错误.您还可以使用`(setq inhibit-startup-screen t)`禁用欢迎屏幕,以使Emacs立即切换到`*scratch*`缓冲区. (2认同)