I got a file(for instance, ~/.mozilla/firefox/xxx.default/sessionstore-backups/recovery.bak) that its content is one whole line
and size of over 1MB, if I open it in Emacs, Emacs will become very laggy, so I put some configuration in Emacs: if a buffer you are going to open is over 1MB, use fundamental-mode and disables some other minor modes such as font-lock-mode and linum-mode and other configs for high performance, but this configuration is only working for buffers that size is over 1MB AND contents is not very long lines(for example, /var/log/messages), IF the content of the file is long lines, the configuration is totally not working.
My configuration:
(defun check-large-file-hook ()
"If a file is over a given size, turn off minor modes"
(when (> (buffer-size) (* 1024 1024)) ;; 1 MB
(fundamental-mode)
(font-lock-mode -1)
(linum-mode -1)
(setq buffer-read-only t)
(buffer-disable-undo)
))
(add-hook 'find-file-hooks 'check-large-file-hook)
Is there any solution for this kind of problem?
NOTE:
Viewing long lines buffer is laggy is not my problem, so the VLF package would not be the solution to my post, my problem is configuration for lone lines buffer is not working.
linum-mode
has a bad reputation for a variety of reasons, including slow-down issues. How about trying Stefan'snlinum-mode
instead? http://elpa.gnu.org/packages/nlinum.html – lawlist Nov 09 '14 at 18:26longlines-mode
in those cases. – Stefan Nov 09 '14 at 23:13(setq truncate-lines t)
be an option to at least get the file loaded without a problem? Also,find-file-hooks
is obsolete and is an alias forfind-file-hook
. – lawlist Nov 10 '14 at 05:58(let ((auto-mode-alist nil)) . . .)
Theauto-mode-alist
generally controls what mode a particular file extension will open in (e.g.,*.org
) -- by setting it tonil
with a let-bound variable, you bypass theauto-mode-alist
regardless of the file extension. – lawlist Nov 10 '14 at 06:57find-file-hook
, notfind-file-hooks
(won't solve your problem, but that's the newer name - since Emacs 22.1). – Drew Nov 10 '14 at 17:09(debug)
in your hook function, then step through the debugger to see what is going on. – Drew Nov 10 '14 at 17:11