Sporadically when I open a large file in emacs it will hang forever, except the GUI will remain responsive! I can move my mouse between frames and the cursor will fill in, hovering over files in dired mode still highlights them, etc. but clicking doesn't cause any action to actually be performed. Ideally of course whatever bug is in emacs will get fixed eventually, but for now, is there anyway I can interrupt emacs loading the file, or change my .emacs to make it interruptible? Ctrl+G doesn't work.

Clarification: I'm trying not to lose my work -- so I mean interrupt emacs without killing it, as in, have it return to just how it was before I tried opening the file.

  • Have you tried escape 3 times? ESC ESC ESC – kjfletch Oct 30 '10 at 19:33
  • yes, doesn't help. – momeara Feb 4 '14 at 2:53

I use the following hook to force Emacs to open large files in fundamental mode, read only, and without undo. This does speed up viewing large files as avoids any time spent during fontification. I've found this to be helpful behavior, and I can always turn on any of those features easily if I want. UPDATE - fixed typo with find-file-hook.

(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) (* 10 1024 1024))
    (setq buffer-read-only t)
    ; (message "Buffer is set to read-only because it is large.  Undo also disabled.")

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

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.