Last active
August 2, 2020 07:32
-
-
Save jidaikobo-shibata/96e00bd843c838f45ab8183e286150ec to your computer and use it in GitHub Desktop.
Emacs(Elisp): Open large file quickly. 大きいファイルを早く開きたい
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; ------------------------------------------------------------ | |
;;; 大きいファイルを早く開きたい | |
;; gist-description: Emacs(Elisp): Open large file quickly. 大きいファイルを早く開きたい | |
;; gist-id: 96e00bd843c838f45ab8183e286150ec | |
;; gist-name: open-large-file-quickly.el | |
;; gist-private: nil | |
(defun open-large-file-quickly() | |
"To read large file." | |
(interactive) | |
(progn | |
(when (file-exists-p (buffer-file-name)) | |
(let* ((file-name (buffer-file-name (current-buffer))) | |
(f-attr (file-attributes file-name)) | |
(f-size (nth 7 f-attr)) | |
(is-large (>= f-size 2000000))) | |
(if (not (string= (substring (buffer-file-name) 0 1) "*")) | |
(progn | |
(setq-local ac-auto-start (not is-large)) | |
(setq-local show-paren-mode (not is-large)) | |
(setq-local linum-mode (not is-large)) | |
(when is-large | |
(message "File Size: %s Bytes, Opened by less function mode" f-size)))))))) | |
(add-hook 'find-file-hooks 'open-large-file-quickly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment