Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to improve emacs performance when view large file?

Tags:

emacs

Emacs sometimes hangs when viewing large file. But it is fast with (global-font-lock-mode -1).

I'm using a fork of Prelude.

Emacs version: 24.3 cocoa System: OS X 10.8.4

Update: I found (setq jit-lock-defer-time 0.05) is a method to improve the scrolling speed.

like image 750
goofansu Avatar asked Aug 19 '13 14:08

goofansu


2 Answers

To help with large files, I've installed my own find-file-hook which turns on fundamental mode (avoids font-lock), turns off undo, and makes the buffer read-only just to avoid any accidental changes (making unnecessary backups of large files).

(defun my-find-file-check-make-large-file-read-only-hook ()   "If a file is over a given size, make the buffer read only."   (when (> (buffer-size) (* 1024 1024))     (setq buffer-read-only t)     (buffer-disable-undo)     (fundamental-mode)))  (add-hook 'find-file-hook 'my-find-file-check-make-large-file-read-only-hook) 

Obviously adjust the threshold value as you see fit.

like image 195
Trey Jackson Avatar answered Oct 04 '22 08:10

Trey Jackson


If you need to work with really large files, you can use the View Large Files package which allows "viewing, editing and searching in large files in chunks." After requireing the package open large files with M-x vlfi.

like image 31
Alex Vorobiev Avatar answered Oct 04 '22 09:10

Alex Vorobiev