Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs could open huge file without any problem #29

Open
redguardtoo opened this issue Mar 20, 2018 · 0 comments
Open

emacs could open huge file without any problem #29

redguardtoo opened this issue Mar 20, 2018 · 0 comments

Comments

@redguardtoo
Copy link

redguardtoo commented Mar 20, 2018

The key point is to turn off inefficient linum-mode when file is too big.

Set up Emacs to turn off syntax highlight and linum-mode by adding below code into ~/.emacs:

(defun buffer-too-big-p ()
  (or (> (buffer-size) (* 5000 64))
      (> (line-number-at-pos (point-max)) 5000)))
(defun generic-setup ()
  ;; turn off `linum-mode' when there are more than 5000 lines
  (if (buffer-too-big-p) (linum-mode -1)))
(add-hook 'prog-mode-hook 'generic-setup)
(add-hook 'text-mode-hook 'generic-setup)

My complete Emacs setup is at https://github.com/redguardtoo/emacs.d

Linux cli to create huge 3g.txt:
base64 /dev/urandom | head -c 3000000000 > 3g.txt

Then run emacs -nw 3g.txt, here is the screenshot. I can edit this file without any problem.

230017-20_1024x768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant