在init.el一个一个注释掉引用后发现是一个ELPA.EL的问题.这个文件就是配置一下源,加载几个包,新手+编程小白,看不太懂
;;; Code:
;;; settings for package archives
(require 'package)
(setq package-check-signature nil
load-prefer-newer t)
(setq package-archives '(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("nongnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/")
("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
;;; initialize the packages, avoiding a re-initialization
(unless (bound-and-true-p package--initialized) ;; To avoid warnings on 27
(package-initialize))
(unless package-archive-contents
(package-refresh-contents))
;; settings for use-package package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; configure use-package prior to loading it
(eval-and-compile
(setq use-package-always-ensure t
use-package-always-defer t
use-package-expand-minimally t)
(require 'use-package))
(use-package gnu-elpa-keyring-update
:defer 4)
(use-package diminish
:defer 4)
(use-package delight
:defer 4)
(provide 'init-elpa)
这个占用了1秒多.大神看看哪里能修改一下,我用的很轻量的配置,没几个包.都要3秒多
(unless package-archive-contents
(package-refresh-contents))
这个注释掉看一下
2 个赞
M-x use-package-report 能够大体列出各个包的加载时间:
如果某个包加载的时间过长,可以考虑优化下。
1 个赞
抱歉这几天有事才回复,我试了一下并没什么效果 ::
;;; initialize the packages, avoiding a re-initialization
(unless (bound-and-true-p package--initialized) ;; To avoid warnings on 27
(package-initialize))
那就是 (package-initialize)
这句花了 1s 多,注释掉试试
emacs27+ 不需要package-initialize
.
建议还是使用成熟的第三方配置,自己优化工作量很大.
例如我的设置代码考虑了从命令行启动emacs的可能, 还设置package-quickstart
为t
, 这些技巧你自己摸索要很长时间,
(defun my-initialize-package ()
"Package loading optimization. No need to activate all the packages so early."
;; @see https://www.gnu.org/software/emacs/news/NEWS.27.1
;; ** Installed packages are now activated *before* loading the init file.
;; As a result of this change, it is no longer necessary to call
;; `package-initialize' in your init file.
;; Previously, a call to `package-initialize' was automatically inserted
;; into the init file when Emacs was started. This call can now safely
;; be removed. Alternatively, if you want to ensure that your init file
;; is still compatible with earlier versions of Emacs, change it to:
;; However, if your init file changes the values of `package-load-list'
;; or `package-user-dir', or sets `package-enable-at-startup' to nil then
;; it won't work right without some adjustment:
;; - You can move that code to the early init file (see above), so those
;; settings apply before Emacs tries to activate the packages.
;; - You can use the new `package-quickstart' so activation of packages
;; does not need to pay attention to `package-load-list' or
;; `package-user-dir' any more.
;; "package-quickstart.el" converts path in `load-path' into
;; os dependent path, make it impossible to share same emacs.d between
;; Windows and Cygwin.
(unless (or *win64* *cygwin*)
;; you need run `M-x package-quickstart-refresh' at least once
;; to generate file "package-quickstart.el'.
;; It contains the `autoload' statements for all packages.
(setq package-quickstart t))
;; esup need call `package-initialize'
;; @see https://github.com/jschaf/esup/issues/84
(when (or (featurep 'esup-child)
(fboundp 'profile-dotemacs)
(daemonp)
my-lightweight-mode-p
noninteractive)
(package-initialize)))
(my-initialize-package)
3 个赞
感谢大神亲自回复,其实我最开始就是用你的配置,无奈英文太差加上刚接触EMACS,想删减一些包都不懂,所以从GitHub找个一个简单的配置,等我在试试不行还是用你的吧
删减包没必要。想要添加包参考init-elpa.el
。我的包管理策略是默认stable-melpa的包都可以安装。这是强调配置稳定性的结果。懂一点lisp代码的话默认设置都可以改写。实际上没有任何限制。