emacs启动缓慢
我的emacs每次启动都需要几秒钟,这比我预期的要慢。在这段时间里,上面写着“联系主持人:”果酱回购和melpa 我目前的配置合理吗?有没有一种方法可以加快速度,同时在需要时仍然能够安装软件包emacs启动缓慢,emacs,Emacs,我的emacs每次启动都需要几秒钟,这比我预期的要慢。在这段时间里,上面写着“联系主持人:”果酱回购和melpa 我目前的配置合理吗?有没有一种方法可以加快速度,同时在需要时仍然能够安装软件包 ;; init.el --- Emacs configuration ;; INSTALL PACKAGES ;; -------------------------------------- (require 'package) (add-to-list 'package-archives '("
;; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; --------------------------------------
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar myPackages
'(better-defaults
paredit
idle-highlight-mode
ido-ubiquitous
find-file-in-project
smex
scpaste
ein
elpy
flycheck
material-theme
py-autopep8))
(package-refresh-contents)
(mapc #'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
myPackages)
;; BASIC CUSTOMIZATION
;; --------------------------------------
(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally
;; PYTHON CONFIGURATION
;; --------------------------------------
(elpy-enable)
(elpy-use-ipython)
;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
;; enable electric pair minor mode
(defun electric-pair ()
"If at end of line, insert character pair without surrounding spaces.
Otherwise, just insert the typed character."
(interactive)
(if (eolp) (let (parens-require-spaces) (insert-pair)) (self-insert-command 1)))
(add-hook 'python-mode-hook
(lambda ()
(define-key python-mode-map "\"" 'electric-pair)
(define-key python-mode-map "\'" 'electric-pair)
(define-key python-mode-map "(" 'electric-pair)
(define-key python-mode-map "[" 'electric-pair)
(define-key python-mode-map "{" 'electric-pair)))
;; Send line from code buffer
;; http://stackoverflow.com/questions/27777133/change-the-emacs-send-code-to-interpreter-c-c-c-r-command-in-ipython-mode/30774439#30774439
(defun my-python-line ()
(interactive)
(save-excursion
(setq the_script_buffer (format (buffer-name)))
(end-of-line)
(kill-region (point) (progn (back-to-indentation) (point)))
(if (get-buffer "*Python*")
(message "")
(run-python "ipython" nil nil))
;; (setq the_py_buffer (format "*Python[%s]*" (buffer-file-name)))
(setq the_py_buffer "*Python*")
(switch-to-buffer-other-window the_py_buffer)
(goto-char (buffer-end 1))
(yank)
(comint-send-input)
(switch-to-buffer-other-window the_script_buffer)
(yank))
(end-of-line)
(next-line)
)
(add-hook 'python-mode-hook
(lambda ()
(define-key python-mode-map "\C-cn" 'my-python-line)))
最近,从MELPA加载包的速度非常慢,我不太清楚为什么。为了避免这种情况(或者至少确保这种情况只发生一次),您可以在守护程序模式下运行Emacs,然后在需要编辑文件时连接到它。这意味着装载成本只发生一次。它只需在启动时运行
emacs--daemon
。然后通过emacsclient
键入M-x description function RET package refresh contents RET
进行连接,并有意识地决定是否真的需要在每次启动Emacs时都进行此操作。如果你需要它,那就接受等待时间吧。如果不需要它,则删除这两个引用。删除第一次出现的(当(不是包存档内容)(包刷新内容))
并进一步删除第二次出现的(包刷新内容)
。而且,除非您的软件包每天都有蒸发成稀薄空气的趋势,否则请删除软件包安装
中以mapc
@lawlist Super开头的内容。即使只是注释掉添加到列表中
实例,也会大大加快速度。谢谢@Hatshepsut:如果您指的是添加到列表
调用包存档
,那么当然这会加快速度——代价是不包括那些包存档,所以可能不是您想要的。看见