Function: abort-if-file-too-large

abort-if-file-too-large is a byte-compiled function defined in files.el.gz.

Signature

(abort-if-file-too-large SIZE OP-TYPE FILENAME &optional OFFER-RAW)

Documentation

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). If OFFER-RAW is true, give user the additional option to open the file literally. If the user chooses this option, abort-if-file-too-large returns the symbol raw. Otherwise, it returns nil or exits non-locally.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun abort-if-file-too-large (size op-type filename &optional offer-raw)
  "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).  If OFFER-RAW is true, give user the additional option
to open the file literally.  If the user chooses this option,
`abort-if-file-too-large' returns the symbol `raw'.  Otherwise,
it returns nil or exits non-locally."
  (let ((choice (and large-file-warning-threshold size
                     (> size large-file-warning-threshold)
                     ;; No point in warning if we can't read it.
                     (file-readable-p filename)
                     (files--ask-user-about-large-file
                      size op-type filename offer-raw))))
    (when (eq choice 'abort)
      (user-error "Aborted"))
    choice))