Prompt to open file literally when opening large files.

This commit is contained in:
ralesi 2015-10-30 09:20:02 -07:00 committed by syl20bnr
parent b97b61c01c
commit 3f376a431b
4 changed files with 19 additions and 0 deletions

View File

@ -176,6 +176,10 @@ start.")
(defvar dotspacemacs-helm-position 'bottom
"Position in which to show the `helm' mini-buffer.")
(defvar dotspacemacs-large-file-size 1
"Size (in MB) above which spacemacs will prompt to open literally to avoid
performance issues.")
(defvar dotspacemacs-auto-save-file-location 'cache
"Location where to auto-save files. Possible values are `original' to
auto-save the file in-place, `cache' to auto-save the file to another

View File

@ -149,6 +149,9 @@ values."
;; If non nil then the last auto saved layouts are resume automatically upon
;; start. (default nil)
dotspacemacs-auto-resume-layouts nil
;; Buffer file size (in MB), above which spacemacs will prompt to open the
;; buffer literally to improve performance. (default 1)
dotspacemacs-large-file-size 1
;; Location where to auto-save files. Possible values are `original' to
;; auto-save the file in-place, `cache' to auto-save the file to another
;; file stored in the cache directory and `nil' to disable auto-saving.

View File

@ -161,6 +161,9 @@ It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."
(with-eval-after-load 'comint
(define-key comint-mode-map (kbd "C-d") nil))
;; Prompt to open file literally if large file.
(add-hook 'find-file-hook 'spacemacs/check-large-file)
;; whitespace-cleanup configuration
(pcase dotspacemacs-whitespace-cleanup
(`all (add-hook 'before-save-hook 'whitespace-cleanup))

View File

@ -327,6 +327,15 @@ argument takes the kindows rotate backwards."
(buffer-string)))
(t (concat "/sudo:root@localhost:" fname))))))
;; check when opening large files - literal file open
(defun spacemacs/check-large-file ()
(when (> (nth 7 (file-attributes (buffer-file-name)))
(* 1024 1024 dotspacemacs-large-file-size))
(when (y-or-n-p "This is a large file, open literally to avoid performance issues?")
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode))))
;; found at http://emacswiki.org/emacs/KillingBuffers
(defun spacemacs/kill-other-buffers ()
"Kill all other buffers."