refactoring code
This commit is contained in:
parent
4177899f78
commit
df9488c745
140
init.el
140
init.el
@ -1,60 +1,114 @@
|
||||
;;; init.el --- .Emacs Configuration -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Emacs!!!
|
||||
|
||||
(package-initialize)
|
||||
;;; Code:
|
||||
;; Without this comment emacs25 adds (package-initialize) here
|
||||
;; (package-initialize)
|
||||
|
||||
(when (version<= emacs-version "24")
|
||||
(error "This is made form Emacs >=24"))
|
||||
;;; Time Mark
|
||||
(setq emacs-load-start-time (current-time))
|
||||
|
||||
(defconst emacs-start-time (current-time))
|
||||
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/" user-emacs-directory))
|
||||
(setq package-check-signature 'allow-unsigned)
|
||||
|
||||
;;; Raise garbage collection threshold after init
|
||||
(add-hook 'after-init-hook
|
||||
(lambda () (setq gc-cons-threshold local/gc-cons-threshold)))
|
||||
;;; Fix TLS emacs 26.x
|
||||
(if (version<= emacs-version "26.2")
|
||||
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
||||
|
||||
;;; Custom variables
|
||||
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
||||
;;; Custom settings
|
||||
(setq settings-file (expand-file-name "settings.el" user-emacs-directory))
|
||||
;;; Welcome message
|
||||
(setq-default initial-scratch-message
|
||||
(concat ";; Happy hacking, " user-login-name " - Emacs loves you!\n\n"))
|
||||
|
||||
(defvar before-user-init-time (current-time)
|
||||
"Value of `current-time' when Emacs begins loading `user-init-file'.")
|
||||
|
||||
;;; Garbage Collector
|
||||
(progn
|
||||
;; Set this to true to find GC issues.
|
||||
(setq garbage-collection-messages nil)
|
||||
|
||||
;; Increase the gc-cons-threshold to a very high number to decrease
|
||||
;; the load and compile time. The value will be decreased
|
||||
;; significantly after initialization to avoid long GC pauses during
|
||||
;; normal usage.
|
||||
(setq gc-cons-threshold 402653184
|
||||
gc-cons-percentage 0.6)
|
||||
|
||||
(setq read-process-output-max (* 1024 1024)) ;; 1mb
|
||||
|
||||
;; Reset GC to normal values.
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(message
|
||||
"[STARTUP] Loading %s...done (%.3fs)" user-init-file
|
||||
(float-time (time-subtract (current-time)
|
||||
before-user-init-time)))
|
||||
|
||||
(when init-file-debug
|
||||
(message "Rolling back GC settings to sane values."))
|
||||
(setq gc-cons-threshold 16777216
|
||||
gc-cons-percentage 0.1))))
|
||||
|
||||
;;; Modules directory
|
||||
(push (concat user-emacs-directory "lisp") load-path)
|
||||
|
||||
;;; Loads settings file
|
||||
(when (file-exists-p custom-file)
|
||||
(load settings-file))
|
||||
;;;------------------------------
|
||||
;;; Features
|
||||
;;;------------------------------
|
||||
(require 'init-security)
|
||||
(require 'init-elpa)
|
||||
;; theme
|
||||
(require 'init-theme)
|
||||
;; Utils
|
||||
(require 'init-utils)
|
||||
;; GUI
|
||||
(require 'init-nlinum)
|
||||
(require 'init-gui)
|
||||
(require 'init-editing-utils)
|
||||
(require 'init-modeline)
|
||||
(require 'init-indent-guides)
|
||||
;; Tools
|
||||
(require 'init-flycheck)
|
||||
;; Languages
|
||||
(require 'init-markdown)
|
||||
(require 'init-python)
|
||||
(require 'init-pkgbuild)
|
||||
(require 'init-php)
|
||||
(require 'init-less)
|
||||
(require 'init-sass)
|
||||
(require 'init-scss)
|
||||
;; Plus
|
||||
(require 'init-rainbow)
|
||||
;;; https://stackoverflow.com/questions/2816019/in-lisp-avoid-cannot-open-load-file-when-using-require
|
||||
|
||||
;; @see https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/
|
||||
;; Normally file-name-handler-alist is set to
|
||||
;; (("\\`/[^/]*\\'" . tramp-completion-file-name-handler)
|
||||
;; ("\\`/[^/|:][^/|]*:" . tramp-file-name-handler)
|
||||
;; ("\\`/:" . file-name-non-special))
|
||||
;; Which means on every .el and .elc file loaded during start up, it has to runs those regexps against the filename.
|
||||
(let* ((file-name-handler-alist nil))
|
||||
;; package-initialize' takes 35% of startup time
|
||||
;; need check https://github.com/hlissner/doom-emacs/wiki/FAQ#how-is-dooms-startup-so-fast for solution
|
||||
(require 'init-security)
|
||||
(require 'init-elpa)
|
||||
;; theme
|
||||
(require 'init-theme)
|
||||
;; Utils
|
||||
(require 'init-utils)
|
||||
;; GUI
|
||||
(require 'init-nlinum)
|
||||
(require 'init-gui)
|
||||
(require 'init-editing-utils)
|
||||
(require 'init-modeline)
|
||||
(require 'init-indent-guides)
|
||||
;; Tools
|
||||
(require 'init-flycheck)
|
||||
;; Languages
|
||||
(require 'init-markdown)
|
||||
(require 'init-python)
|
||||
(require 'init-pkgbuild)
|
||||
(require 'init-php)
|
||||
(require 'init-less)
|
||||
(require 'init-sass)
|
||||
(require 'init-scss)
|
||||
;; Plus
|
||||
(require 'init-rainbow))
|
||||
|
||||
;;; Custom variables
|
||||
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
||||
;;; Loads custom file
|
||||
(when (file-exists-p custom-file)
|
||||
(load custom-file))
|
||||
|
||||
(when window-system
|
||||
(let ((elapsed (float-time (time-subtract (current-time)
|
||||
emacs-start-time))))
|
||||
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))
|
||||
;;; Settings
|
||||
(setq settings-file (expand-file-name "settings.el" user-emacs-directory))
|
||||
;;; Loads settings file
|
||||
(when (file-exists-p custom-file)
|
||||
(load settings-file))
|
||||
|
||||
;; enable erase-buffer command
|
||||
(put 'erase-buffer 'disabled nil)
|
||||
|
||||
(provide 'init)
|
||||
;; Local Variables:
|
||||
;; byte-compile-warnings: (not free-vars)
|
||||
;; End:
|
||||
;;; init.el ends here
|
||||
|
@ -32,5 +32,4 @@
|
||||
(setq-default
|
||||
indent-tabs-mode nil)
|
||||
|
||||
(myemacs/elapsed-time)
|
||||
(provide 'init-editing-utils)
|
||||
|
@ -12,23 +12,18 @@
|
||||
;; Repositories
|
||||
;; ================
|
||||
(setq package-archives
|
||||
'(("melpa" . "https://melpa.org/packages/")
|
||||
;;("melpa-stable" . "https://stable.melpa.org/packages/")
|
||||
("gnu" . "https://elpa.gnu.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")))
|
||||
'(("GNU ELPA" . "https://elpa.gnu.org/packages/")
|
||||
("MELPA Stable" . "https://stable.melpa.org/packages/")
|
||||
("ORG" . "https://orgmode.org/elpa/")
|
||||
("MELPA" . "https://melpa.org/packages/"))
|
||||
package-archive-priorities
|
||||
'(("MELPA Stable" . 10)
|
||||
("GNU ELPA" . 5)
|
||||
("ORG" . 3)
|
||||
("MELPA" . 0)))
|
||||
|
||||
(setq package-archive-priorities
|
||||
'(("melpa" . 4)
|
||||
("melpa-stable" . 0)
|
||||
("gnu" . 1)
|
||||
("org" . 3)))
|
||||
;; =================
|
||||
|
||||
;; Refresh packages in Emacs
|
||||
;; ==========================
|
||||
(when (not package-archive-contents)
|
||||
(package-refresh-contents))
|
||||
|
||||
;;; Find packages if not installed
|
||||
;; ================================
|
||||
;;; On-demand installation of packages
|
||||
|
@ -42,5 +42,4 @@
|
||||
(global-set-key (kbd "M-%") 'anzu-query-replace)
|
||||
(global-set-key (kbd "s-<SPC>") 'anzu-query-replace)
|
||||
|
||||
(myemacs/elapsed-time)
|
||||
(provide 'init-modeline)
|
||||
|
@ -60,5 +60,4 @@
|
||||
|
||||
(add-hook 'php-mode-hook 'my/php-mode-stuff)
|
||||
|
||||
(myemacs/elapsed-time)
|
||||
(provide 'init-php)
|
||||
|
@ -18,7 +18,4 @@
|
||||
'(eval-after-load ,feature
|
||||
'(progn ,@body))))
|
||||
|
||||
;; Elapsed time
|
||||
(myemacs/elapsed-time)
|
||||
|
||||
(provide 'init-utils)
|
||||
|
@ -1,18 +0,0 @@
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Some cool functions
|
||||
;;----------------------------------------------------------------------------
|
||||
;; These functions are made by me (Quitter: @heckyel) or
|
||||
;; heavily modified by me
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Toggles fullscreen
|
||||
;;----------------------------------------------------------------------------
|
||||
(defun myemacs/toggle-fullscreen ()
|
||||
(interactive)
|
||||
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
|
||||
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
|
||||
|
||||
(defun myemacs/elapsed-time ()
|
||||
(let ((elapsed (float-time (time-subtract (current-time)
|
||||
emacs-start-time))))
|
||||
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))
|
Loading…
x
Reference in New Issue
Block a user