I usually unroll long lines and indent by tags (like HTML, XML, JSON).
In order to make such operation possible I add:
(setq line-number-display-limit large-file-warning-threshold)
(setq line-number-display-limit-width 200)
(defun my--is-file-large ()
"If buffer too large and my cause performance issue."
(< large-file-warning-threshold (buffer-size)))
(define-derived-mode my-large-file-mode fundamental-mode "LargeFile"
"Fixes performance issues in Emacs for large files."
;; (setq buffer-read-only t)
(setq bidi-display-reordering nil)
(jit-lock-mode nil)
(buffer-disable-undo)
(set (make-variable-buffer-local 'global-hl-line-mode) nil)
(set (make-variable-buffer-local 'line-number-mode) nil)
(set (make-variable-buffer-local 'column-number-mode) nil) )
(add-to-list 'magic-mode-alist (cons #'my--is-file-large #'my-large-file-mode))
Note that I don't use find-file-hooks
as magic-mode-alist
usually empty and have priority. If I add find-file-hooks
it first validate XML file by nxml-mode
and then switch to fundamental-mode
.
I split line by regex, for XML it: C-M-% >< RET >NL< RET !
.
After Emacs split long lines - it is possible to enable many *-modes
and re-indent code.
find-file-literally
is good since it puts you in fundamental mode.font-lock-mode
?find-file-literally
. It disables not only font-lock, but also the major-mode. I can call it from dired when I see that the file size is large.