Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jidaikobo-shibata
Last active August 2, 2020 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jidaikobo-shibata/96e00bd843c838f45ab8183e286150ec to your computer and use it in GitHub Desktop.
Save jidaikobo-shibata/96e00bd843c838f45ab8183e286150ec to your computer and use it in GitHub Desktop.
Emacs(Elisp): Open large file quickly. 大きいファイルを早く開きたい
;;; ------------------------------------------------------------
;;; 大きいファイルを早く開きたい
;; 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