diff options
author | Jesus E <heckyel@riseup.net> | 2023-05-12 23:08:14 -0400 |
---|---|---|
committer | Jesus E <heckyel@riseup.net> | 2023-05-12 23:08:14 -0400 |
commit | df9488c7459effbbd35e08ae110aa44e624a64e1 (patch) | |
tree | 967d4e4ded2dcb5fd229c6d6ef045c3793f227ba | |
parent | 4177899f78cdbf3d8d2270b1ff06dc36ff66e50e (diff) | |
download | emacs-base-df9488c7459effbbd35e08ae110aa44e624a64e1.tar.lz emacs-base-df9488c7459effbbd35e08ae110aa44e624a64e1.tar.xz emacs-base-df9488c7459effbbd35e08ae110aa44e624a64e1.zip |
refactoring code
-rw-r--r-- | init.el | 140 | ||||
-rw-r--r-- | lisp/init-editing-utils.el | 1 | ||||
-rw-r--r-- | lisp/init-elpa.el | 23 | ||||
-rw-r--r-- | lisp/init-modeline.el | 1 | ||||
-rw-r--r-- | lisp/init-php.el | 1 | ||||
-rw-r--r-- | lisp/init-utils.el | 3 | ||||
-rw-r--r-- | lisp/lib/myemacs.el | 18 |
7 files changed, 106 insertions, 81 deletions
@@ -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 diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 5f65ef7..433ef69 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -32,5 +32,4 @@ (setq-default indent-tabs-mode nil) -(myemacs/elapsed-time) (provide 'init-editing-utils) diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el index 5ba04d2..7fa39aa 100644 --- a/lisp/init-elpa.el +++ b/lisp/init-elpa.el @@ -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 diff --git a/lisp/init-modeline.el b/lisp/init-modeline.el index b0db030..daf25b3 100644 --- a/lisp/init-modeline.el +++ b/lisp/init-modeline.el @@ -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) diff --git a/lisp/init-php.el b/lisp/init-php.el index d4fa09b..a16dd00 100644 --- a/lisp/init-php.el +++ b/lisp/init-php.el @@ -60,5 +60,4 @@ (add-hook 'php-mode-hook 'my/php-mode-stuff) -(myemacs/elapsed-time) (provide 'init-php) diff --git a/lisp/init-utils.el b/lisp/init-utils.el index 64dadc6..0490986 100644 --- a/lisp/init-utils.el +++ b/lisp/init-utils.el @@ -18,7 +18,4 @@ '(eval-after-load ,feature '(progn ,@body)))) -;; Elapsed time -(myemacs/elapsed-time) - (provide 'init-utils) diff --git a/lisp/lib/myemacs.el b/lisp/lib/myemacs.el deleted file mode 100644 index 6846bdc..0000000 --- a/lisp/lib/myemacs.el +++ /dev/null @@ -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)))
\ No newline at end of file |