Refactoring and cleanup code

Linum-mode is disabled for default (can be activated with F6 key), and improves the handling of large files.
This commit is contained in:
Jesús
2019-11-06 17:20:55 -05:00
parent 2de9f0c2ef
commit c3a5ae44b0
3 changed files with 56 additions and 159 deletions

45
init.el
View File

@@ -7,9 +7,8 @@
;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)
(let* ((minver "24.4"))
(when (version< emacs-version minver)
(error "Emacs v%s or higher is required" minver)))
;;; Time Mark
(setq emacs-load-start-time (current-time))
;;; Welcome message
(setq-default initial-scratch-message
@@ -18,41 +17,6 @@
;;; Modules directory
(push (concat user-emacs-directory "modules") load-path)
;;; Raise garbage collection threshold after init
(defvar best-gc-cons-threshold
4000000
"Best default gc threshold value. Should NOT be too big!")
;; don't GC during startup to save time
(setq gc-cons-threshold most-positive-fixnum)
(setq emacs-load-start-time (current-time))
;;----------------------------------------------------------------------------
;; Which functionality to enable (use t or nil for true and false)
;;----------------------------------------------------------------------------
(setq *is-a-mac* (eq system-type 'darwin))
(setq *win64* (eq system-type 'windows-nt))
(setq *cygwin* (eq system-type 'cygwin) )
(setq *linux* (or (eq system-type 'gnu/linux) (eq system-type 'linux)) )
(setq *unix* (or *linux* (eq system-type 'usg-unix-v) (eq system-type 'berkeley-unix)) )
(setq *emacs24* (>= emacs-major-version 24))
(setq *emacs25* (>= emacs-major-version 25))
(setq *emacs26* (>= emacs-major-version 26))
(setq *no-memory* (cond
(*is-a-mac*
(< (string-to-number (nth 1 (split-string (shell-command-to-string "sysctl hw.physmem")))) 4000000000))
(*linux* nil)
(t nil)))
;; @see https://www.reddit.com/r/emacs/comments/55ork0/is_emacs_251_noticeably_slower_than_245_on_windows/
;; Emacs 25 does gc too frequently
(when *emacs25*
;; (setq garbage-collection-messages t) ; for debug
(setq best-gc-cons-threshold (* 64 1024 1024))
(setq gc-cons-percentage 0.5)
(run-with-idle-timer 5 t #'garbage-collect))
;;;------------------------------
;;; Features
;;;------------------------------
@@ -74,7 +38,7 @@
;; Utils
(require 'init-utils)
;; GUI
(require 'init-nlinum)
(require 'init-linum)
(require 'init-gui)
(require 'init-editing-utils)
(require 'init-diminish)
@@ -127,8 +91,7 @@
(when (file-exists-p custom-file)
(load settings-file))
(setq gc-cons-threshold best-gc-cons-threshold)
;; Time Output
(when window-system
(let ((elapsed (float-time (time-subtract (current-time)
emacs-load-start-time))))