So I have a long papers.bib bibtex file that I edit with emacs (spacemacs bibtex layer), but the syntax highlighting only ever goes about halfway down. Here it is at about line 790:


Other times this happens elsewhere: line 10,000, line 900, etc. At first I thought this happens because of some incorrect syntax in the Bibtex, but I can't see any errors, actually. What's going on here, and how can I get it to syntax highlight the whole file?

  • This used to happen to me all the time, and it drove me nuts. I eventually sorted it out, and I think it was due to a bad interaction with one of my add-on packages. Unfortunately I can't remember which. Or it might have been resolved when moving to a newer Emacs. Sorry I can't be more specific, but I feel your pain!
    – Tyler
    Commented Jul 17, 2017 at 15:35
  • Can you post your init.el somewhere? I can take a look and see if I recognize the culprit
    – Tyler
    Commented Nov 17, 2017 at 20:09
  • My init.el is just the spacemacs init.el, which I think is on GitHub somewhere.
    – Jonathan
    Commented Nov 24, 2017 at 11:15
  • ok. I can confirm the problem using the default spacemacs install, so that's something
    – Tyler
    Commented Nov 26, 2017 at 15:01
  • Hadn't looked at spacemacs before - it's very slick! However, it's also enormous, and I'm not sure how to go about debugging it. Perhaps there's a spacemacs-specific forum for dealing with config bugs?
    – Tyler
    Commented Nov 26, 2017 at 15:36

1 Answer 1


When that happens to me, this helps :

(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) (* 30 1024 1024))
    (setq buffer-read-only t)

(add-hook 'find-file-hooks 'my-find-file-check-make-large-file-read-only-hook)

OK, you can't edit the file, but at least you can read it without crashing Emacs.

Combine it with

(setq large-file-warning-threshold (* 35 1024 1024))

And finally, maybe vlfi can help.

  • 1
    If I understand this correctly, this is the opposite of what I want to do, since fundamental-mode will disable highlighting of the file altogether, whereas I want syntax highlighting to work. I'm also not having problems with emacs crashing. It's not that I want to view a file, (I can do that with less or something), but edit it, so disabling editing is a bad idea.
    – Jonathan
    Commented Jul 23, 2017 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.