Emacs打开最近的文件很慢!

8

当我直接打开一个文件时速度很快,但是当我通过在我的.emacs中添加以下行来打开最近访问的文件时,速度就变慢了:

(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

打开需要大约2秒钟的时间。

这种行为正常吗?我可以做些什么来解决它吗?

我用来打开最近文件的命令:

我的整个.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.
 '(tool-bar-mode nil))
(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.
 '(default ((t (:inherit nil :stipple nil :background "Grey15" :foreground "Grey" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 92 :width normal :foundry "outline" :family "Monaco")))))

  ;;colot theme plugin
(add-to-list 'load-path "~/.emacs.d/")
(require 'color-theme)
(eval-after-load "color-theme"
  '(progn
     (color-theme-initialize)
     (color-theme-charcoal-black)))

  ;;YASnippets
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
    (require 'yasnippet) ;; not yasnippet-bundle
    (yas/initialize)
    (yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets")

;; disable splash screen and startup message
(setq inhibit-startup-message t)

;; set yasnippet no indent
(setq yas/indent-line 'none)

;; set the tab width
(setq default-tab-width 4)
(setq tab-width 4)
(setq c-basic-indent 4)

;; set open recent files

(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

;; set line number
(global-linum-mode 1)

;; prevent emacs from making backup files
(setq make-backup-files nil) 

;; same syntax hightlight for all languages
(global-font-lock-mode 1)

;; remove bold and underline
 (mapc
  (lambda (face)
    (set-face-attribute face nil :weight 'normal :underline nil))
  (face-list))

什么版本的emacs?我发现23.1在Windows上速度不太好。 - luapyad
请尝试访问https://dev59.com/43I-5IYBdhLWcg3wHUjP,了解一些可尝试的方法。 - luapyad
我最近也遇到了同样的问题。你解决了吗? - cgogolin
2个回答

11

最近我在使用recentf和远程文件时遇到了问题,当远程主机不可用时。

(setq recentf-keep '(file-remote-p file-readable-p))

这可能解决你的问题(远程文件将被保留,但不会测试它们是否仍然存在)。


2

这不应该花费太长时间。

一个方法是清理最近文件列表。

ALT+x recentf-cleanup

另一件事是确保您的 .emacs 文件已经重新编译,即使只更改了一个或两个字符,Emacs 也会看到您的 .emacs 文件比已编译的版本更新,它不会使用已编译的版本。

运行以下命令:

ALT+x byte-compile-file

然后导航到您的 .emacs 文件并按 Enter 键,它将创建一个名为 .emacs.elc 的文件。

只要 .emacs.elc 不比您的 .emacs 文件旧,Emacs 将使用它。


谢谢,但是没有起作用。我觉得我的.emacs文件太小了,看不到编译后的效果。它只从3kb变成了2kb。 - alexchenco

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