5

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:

screenshot

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 Jul 17 '17 at 15:35
  • Can you post your init.el somewhere? I can take a look and see if I recognize the culprit – Tyler Nov 17 '17 at 20:09
  • My init.el is just the spacemacs init.el, which I think is on GitHub somewhere. – Jonathan Nov 24 '17 at 11:15
  • ok. I can confirm the problem using the default spacemacs install, so that's something – Tyler Nov 26 '17 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 Nov 26 '17 at 15:36
0

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)
    (buffer-disable-undo)
    (fundamental-mode)))

(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 Jul 23 '17 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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