When I open a large file in emacs, I get a message saying 'foo.bar file is large; really open?'
How do I stop emacs from asking me this question all the time? In other words, if I open the file, I want to open the file, no matter how big it is.
When I open a large file in emacs, I get a message saying 'foo.bar file is large; really open?'
How do I stop emacs from asking me this question all the time? In other words, if I open the file, I want to open the file, no matter how big it is.
In the manual (which you can browse inside Emacs in Info: C-h i m Emacs RET
): go to the chapter on files, then to the section on visiting (i.e. opening) files. Look for the word “large”:
If you try to visit a file larger than
large-file-warning-threshold
(the default is 10000000, which is about 10 megabytes), Emacs asks you for confirmation first. You can answer y to proceed with visiting the file.
This is not the whole story, you can find more information by looking at the documentation of large-file-warning-threshold
(C-h v large-file-warning-threshold RET
).
large-file-warning-threshold is a variable defined in
files.el
.
Its value is 10000000Maximum size of file above which a confirmation is requested.
When nil, never request confirmation.
To set the value, you can either use the Customize interface (there's a link in the help screen for the variable), or put the following statement in your .emacs
:
(setq large-file-warning-threshold nil)
Type C-M-x
while the point is on that line to execute it now.
Under “Files”, under “Find Files”, there is a setting “Large File Warning Threshold”. You can set it to a large value, though on a 32-bit machine you may run into Emacs's relatively small hard limit on integer sizes.
Look at the function to open files: C-h k C-x C-f
(or C-h f find-file RET
). Click on files.el
to browse the source file (you must have the Lisp sources installed). Don't read the code — it's pretty big — but search for parts of the message in that file. You'll find
(defun abort-if-file-too-large (size op-type filename)
"If file SIZE larger than `large-file-warning-threshold', allow user to abort.
OP-TYPE specifies the file operation being performed (for message to user)."
(when (and large-file-warning-threshold size
(> size large-file-warning-threshold)
(not (y-or-n-p
(format "File %s is large (%dMB), really %s? "
(file-name-nondirectory filename)
(/ size 1048576) op-type))))
(error "Aborted")))
The message is only displayed when some conditions are met. The first condition is large-file-warning-threshold
(interpreted as a boolean), i.e. large-file-warning-threshold
must be non-nil. So you can disable the message by setting that variable to nil
. (You can confirm that it's a global variable by looking at its definition in the same file — it's a customizable item, and the documentation explains how it's used if you aren't familiar enough with Lisp and only figured out that the variable mattered in some way.)
(setq large-file-warning-threshold nil)
– R Perrin Jan 07 '14 at 19:26