Emacs无法在启动时加载包

3

Emacs无法加载软件包window-number我在我的.emacs文件中有以下内容:

;;;windows                                                                  
(require 'window-number)                                                    
(window-number-mode) 

然而,一旦启动emacs,如果我输入:M-x load-file RETURN .emacs,那么window-number-mode将被加载。为什么window-number不能在启动时加载?请注意,我从elpa下载了window-number
编辑:window-number-mode可以工作,但它不会在emacs启动时自动启动。我必须输入M-x window-number-mode。我尝试将(window-number-mode)插入到我的.emacs文件中,但这并没有解决我的问题。

你尝试过使用文档建议的(window-number-mode 1)吗?(注意与你当前操作不同之处,即没有1) - Malabarba
2个回答

2
如果您从elpa加载软件包,请确保在使用软件包之前有(package-initialize)。这个函数(除其他外)会更新load-path以包括下载软件包的目录。
"require"可能是不必要的,因为elpa软件包通常具有自动加载功能,但它不会造成任何伤害。

(package-initialize) 是什么意思? - CodeKingPlusPlus
这是一个elisp函数,就像window-number-mode一样。只需将其放在(require 'window-number)之前即可。 - juanleon

1
在.el文件中,你看到过这个吗?
;; Installation
;; ============

;; Drop this file into your load path.  C-h v load-path RET or F1 v
;; load-path RET will help.  Then place the following lines into your
;; .emacs or ~/.xemacs/init.el and uncomment them.

;; ----------------------------------------------------------------------------

;; (autoload 'window-number-mode "window-number"
;;   "A global minor mode that enables selection of windows according to
;; numbers with the C-x C-j prefix.  Another mode,
;; `window-number-meta-mode' enables the use of the M- prefix."
;;   t)

;; (autoload 'window-number-meta-mode "window-number"
;;   "A global minor mode that enables use of the M- prefix to select
;; windows, use `window-number-mode' to display the window numbers in
;; the mode-line."
;;   t)

;; ----------------------------------------------------------------------------

;; Then you can use M-x window-number-mode RET to turn the mode on, or
;; place (window-number-mode 1) and (window-number-meta-mode 1) into
;; your .emacs or ~/.xemacs/init.el.

它可以工作,只是不自动启动。当Emacs启动时,如何启动window-number-mode? - CodeKingPlusPlus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接