Rearrange blocks and improve the way use-package is included
This commit is contained in:
@@ -14,11 +14,20 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
;;; Load pre-early-init.el
|
;;; Variables
|
||||||
(defvar minimal-emacs-debug nil
|
(defvar minimal-emacs-debug nil
|
||||||
"Non-nil to enable debug.")
|
"Non-nil to enable debug.")
|
||||||
|
|
||||||
|
(defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024)
|
||||||
|
"The value of `gc-cons-threshold' after Emacs startup.")
|
||||||
|
|
||||||
|
(defvar minimal-emacs-native-comp-reserved-cpus 2
|
||||||
|
"Number of CPUs to reserve and not use for `native-compile'.")
|
||||||
|
|
||||||
|
;;; Load pre-early-init.el
|
||||||
(defvar minimal-emacs--default-user-emacs-directory user-emacs-directory
|
(defvar minimal-emacs--default-user-emacs-directory user-emacs-directory
|
||||||
"The default value of the `user-emacs-directory' variable.")
|
"The default value of the `user-emacs-directory' variable.")
|
||||||
|
|
||||||
(defun minimal-emacs-load-user-init (filename)
|
(defun minimal-emacs-load-user-init (filename)
|
||||||
"Execute a file of Lisp code named FILENAME."
|
"Execute a file of Lisp code named FILENAME."
|
||||||
(let ((user-init-file
|
(let ((user-init-file
|
||||||
@@ -29,14 +38,6 @@
|
|||||||
|
|
||||||
(minimal-emacs-load-user-init "pre-early-init.el")
|
(minimal-emacs-load-user-init "pre-early-init.el")
|
||||||
|
|
||||||
;;; Variables
|
|
||||||
|
|
||||||
(defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024)
|
|
||||||
"The value of `gc-cons-threshold' after Emacs startup.")
|
|
||||||
|
|
||||||
(defvar minimal-emacs-native-comp-reserved-cpus 2
|
|
||||||
"Number of CPUs to reserve and not use for `native-compile'.")
|
|
||||||
|
|
||||||
;;; Misc
|
;;; Misc
|
||||||
|
|
||||||
(set-language-environment "UTF-8")
|
(set-language-environment "UTF-8")
|
||||||
@@ -49,7 +50,9 @@
|
|||||||
;; garbage collection during startup but will be reset later.
|
;; garbage collection during startup but will be reset later.
|
||||||
(defvar minimal-emacs-default-gc-cons-threshold gc-cons-threshold
|
(defvar minimal-emacs-default-gc-cons-threshold gc-cons-threshold
|
||||||
"The default value of `gc-cons-threshold'.")
|
"The default value of `gc-cons-threshold'.")
|
||||||
|
|
||||||
(setq gc-cons-threshold most-positive-fixnum)
|
(setq gc-cons-threshold most-positive-fixnum)
|
||||||
|
|
||||||
(add-hook 'emacs-startup-hook (lambda ()
|
(add-hook 'emacs-startup-hook (lambda ()
|
||||||
(setq gc-cons-threshold (* 16 1024 1024))))
|
(setq gc-cons-threshold (* 16 1024 1024))))
|
||||||
|
|
||||||
@@ -76,6 +79,16 @@
|
|||||||
;; Ignore warnings about "existing variables being aliased".
|
;; Ignore warnings about "existing variables being aliased".
|
||||||
(setq warning-suppress-types '((defvaralias) (lexical-binding)))
|
(setq warning-suppress-types '((defvaralias) (lexical-binding)))
|
||||||
|
|
||||||
|
;; Don't ping things that look like domain names.
|
||||||
|
(setq ffap-machine-p-known 'reject)
|
||||||
|
|
||||||
|
;; By default, Emacs "updates" its ui more often than it needs to
|
||||||
|
(setq idle-update-delay 1.0)
|
||||||
|
|
||||||
|
;; Font compacting can be very resource-intensive, especially when rendering
|
||||||
|
;; icon fonts on Windows. This will increase memory usage.
|
||||||
|
(setq inhibit-compacting-font-caches t)
|
||||||
|
|
||||||
(unless (daemonp)
|
(unless (daemonp)
|
||||||
(let ((old-value (default-toplevel-value 'file-name-handler-alist)))
|
(let ((old-value (default-toplevel-value 'file-name-handler-alist)))
|
||||||
(set-default-toplevel-value
|
(set-default-toplevel-value
|
||||||
@@ -91,10 +104,7 @@
|
|||||||
;; Ensure the new value persists through any current let-binding.
|
;; Ensure the new value persists through any current let-binding.
|
||||||
(set-default-toplevel-value 'file-name-handler-alist
|
(set-default-toplevel-value 'file-name-handler-alist
|
||||||
file-name-handler-alist)
|
file-name-handler-alist)
|
||||||
;; Remember the old value to reset it as needed. (put
|
;; Remember the old value to reset it as needed.
|
||||||
;; 'file-name-handler-alist 'initial-value old-value) Restore
|
|
||||||
;; `file-name-handler-alist' later for handling encrypted or compressed
|
|
||||||
;; files.
|
|
||||||
(add-hook 'emacs-startup-hook
|
(add-hook 'emacs-startup-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set-default-toplevel-value
|
(set-default-toplevel-value
|
||||||
@@ -106,6 +116,7 @@
|
|||||||
|
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
(progn
|
(progn
|
||||||
|
;; Disable mode-line-format during init
|
||||||
(defun minimal-emacs--reset-inhibited-vars-h ()
|
(defun minimal-emacs--reset-inhibited-vars-h ()
|
||||||
(setq-default inhibit-redisplay nil
|
(setq-default inhibit-redisplay nil
|
||||||
;; Inhibiting `message' only prevents redraws and
|
;; Inhibiting `message' only prevents redraws and
|
||||||
@@ -168,7 +179,7 @@
|
|||||||
(setq initial-major-mode 'fundamental-mode
|
(setq initial-major-mode 'fundamental-mode
|
||||||
initial-scratch-message nil)))
|
initial-scratch-message nil)))
|
||||||
|
|
||||||
;;; Native comp
|
;;; Native comp and Byte comp
|
||||||
(defun minimal-emacs-calculate-native-comp-async-jobs ()
|
(defun minimal-emacs-calculate-native-comp-async-jobs ()
|
||||||
"Set `native-comp-async-jobs-number' based on the available CPUs."
|
"Set `native-comp-async-jobs-number' based on the available CPUs."
|
||||||
;; The `num-processors' function is only available in Emacs >= 28.1
|
;; The `num-processors' function is only available in Emacs >= 28.1
|
||||||
@@ -209,8 +220,12 @@
|
|||||||
(push '(tool-bar-lines . 0) default-frame-alist)
|
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||||
(push '(vertical-scroll-bars) default-frame-alist)
|
(push '(vertical-scroll-bars) default-frame-alist)
|
||||||
(push '(horizontal-scroll-bars) default-frame-alist)
|
(push '(horizontal-scroll-bars) default-frame-alist)
|
||||||
(setq menu-bar-mode nil
|
|
||||||
tool-bar-mode nil
|
;; (when (fboundp 'tool-bar-mode)
|
||||||
|
;; (tool-bar-mode -1))
|
||||||
|
;; (when (fboundp 'scroll-bar-mode)
|
||||||
|
;; (scroll-bar-mode -1))
|
||||||
|
(setq tool-bar-mode nil
|
||||||
scroll-bar-mode nil)
|
scroll-bar-mode nil)
|
||||||
|
|
||||||
(when (bound-and-true-p tooltip-mode)
|
(when (bound-and-true-p tooltip-mode)
|
||||||
@@ -221,52 +236,42 @@
|
|||||||
(setq use-file-dialog nil)
|
(setq use-file-dialog nil)
|
||||||
(setq use-dialog-box nil)
|
(setq use-dialog-box nil)
|
||||||
|
|
||||||
;; (unless (memq window-system '(mac ns))
|
(unless (memq window-system '(mac ns))
|
||||||
;; (menu-bar-mode -1))
|
;; (menu-bar-mode -1)
|
||||||
;; (when (fboundp 'tool-bar-mode)
|
(setq menu-bar-mode nil))
|
||||||
;; (tool-bar-mode -1))
|
|
||||||
;; (when (fboundp 'scroll-bar-mode)
|
|
||||||
;; (scroll-bar-mode -1))
|
|
||||||
(when (fboundp 'horizontal-scroll-bar-mode)
|
(when (fboundp 'horizontal-scroll-bar-mode)
|
||||||
(horizontal-scroll-bar-mode -1))
|
(horizontal-scroll-bar-mode -1))
|
||||||
|
|
||||||
;;; package: Set package archives for package installation
|
;;; package: Set package archives for package installation
|
||||||
(progn
|
(require 'package)
|
||||||
(require 'package)
|
|
||||||
|
|
||||||
;; Since Emacs 27, package initialization occurs before `user-init-file' is
|
;; Since Emacs 27, package initialization occurs before `user-init-file' is
|
||||||
;; loaded, but after `early-init-file'.
|
;; loaded, but after `early-init-file'.
|
||||||
(setq package-enable-at-startup t)
|
(setq package-enable-at-startup t)
|
||||||
|
|
||||||
(setq package-quickstart nil)
|
(setq package-quickstart nil)
|
||||||
|
|
||||||
(when (version< emacs-version "28")
|
(when (version< emacs-version "28")
|
||||||
(add-to-list 'package-archives
|
(add-to-list 'package-archives
|
||||||
'("nongnu" . "https://elpa.nongnu.org/nongnu/")))
|
'("nongnu" . "https://elpa.nongnu.org/nongnu/")))
|
||||||
(add-to-list 'package-archives
|
(add-to-list 'package-archives
|
||||||
'("stable" . "https://stable.melpa.org/packages/"))
|
'("stable" . "https://stable.melpa.org/packages/"))
|
||||||
(add-to-list 'package-archives
|
(add-to-list 'package-archives
|
||||||
'("melpa" . "https://melpa.org/packages/"))
|
'("melpa" . "https://melpa.org/packages/"))
|
||||||
|
|
||||||
(customize-set-variable 'package-archive-priorities
|
(customize-set-variable 'package-archive-priorities
|
||||||
'(("gnu" . 99)
|
'(("gnu" . 99)
|
||||||
("nongnu" . 80)
|
("nongnu" . 80)
|
||||||
("stable" . 70)
|
("stable" . 70)
|
||||||
("melpa" . 0)))
|
("melpa" . 0)))
|
||||||
;; (when package-enable-at-startup
|
|
||||||
;; (package-initialize))
|
|
||||||
)
|
|
||||||
|
|
||||||
;;; use-package:
|
;;; use-package:
|
||||||
(progn
|
;; Always ensure packages are installed
|
||||||
;; Always ensure packages are installed
|
(setq use-package-always-ensure t)
|
||||||
(setq use-package-always-ensure t)
|
|
||||||
|
|
||||||
;; Ensure the 'use-package' package is installed
|
;; Load use-package for package configuration
|
||||||
(unless (package-installed-p 'use-package)
|
(when (package-installed-p 'use-package)
|
||||||
(package-install 'use-package))
|
|
||||||
|
|
||||||
;; Load use-package for package configuration
|
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'use-package)))
|
(require 'use-package)))
|
||||||
|
|
||||||
|
|||||||
53
init.el
53
init.el
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
;;; Install use-package
|
||||||
|
;; Ensure the 'use-package' package is installed and loaded
|
||||||
|
(unless (package-installed-p 'use-package)
|
||||||
|
(package-install 'use-package)
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'use-package)))
|
||||||
|
|
||||||
;;; Load user-pre-init.el and init packages
|
;;; Load user-pre-init.el and init packages
|
||||||
(minimal-emacs-load-user-init "pre-init.el")
|
(minimal-emacs-load-user-init "pre-init.el")
|
||||||
|
|
||||||
@@ -30,18 +37,6 @@
|
|||||||
:hook
|
:hook
|
||||||
(emacs-startup . gcmh-mode))
|
(emacs-startup . gcmh-mode))
|
||||||
|
|
||||||
;;; Performance
|
|
||||||
|
|
||||||
;; Don't ping things that look like domain names.
|
|
||||||
(setq ffap-machine-p-known 'reject)
|
|
||||||
|
|
||||||
;; By default, Emacs "updates" its ui more often than it needs to
|
|
||||||
(setq idle-update-delay 1.0)
|
|
||||||
|
|
||||||
;; Font compacting can be very resource-intensive, especially when rendering
|
|
||||||
;; icon fonts on Windows. This will increase memory usage.
|
|
||||||
(setq inhibit-compacting-font-caches t)
|
|
||||||
|
|
||||||
;;; Uniquify - Unique buffer name
|
;;; Uniquify - Unique buffer name
|
||||||
(progn
|
(progn
|
||||||
(setq uniquify-buffer-name-style 'reverse)
|
(setq uniquify-buffer-name-style 'reverse)
|
||||||
@@ -50,33 +45,30 @@
|
|||||||
(setq uniquify-ignore-buffers-re "^\\*"))
|
(setq uniquify-ignore-buffers-re "^\\*"))
|
||||||
|
|
||||||
;;; Files
|
;;; Files
|
||||||
(progn
|
;; Do not auto-disable auto-save after deleting large chunks of text. The
|
||||||
;; Do not auto-disable auto-save after deleting large chunks of text. The
|
;; purpose of auto-save is to provide a failsafe, and disabling it
|
||||||
;; purpose of auto-save is to provide a failsafe, and disabling it
|
;; contradicts this objective.
|
||||||
;; contradicts this objective.
|
(setq auto-save-include-big-deletions t)
|
||||||
(setq auto-save-include-big-deletions t)
|
|
||||||
|
|
||||||
;; Auto save options
|
;; Auto save options
|
||||||
(setq kill-buffer-delete-auto-save-files t)
|
(setq kill-buffer-delete-auto-save-files t)
|
||||||
|
|
||||||
;; Do not save BackupFiles under the original name with a tilde `~’
|
;; Do not save BackupFiles under the original name with a tilde `~’
|
||||||
(setq backup-by-copying t) ; Backup by copying rather renaming
|
(setq backup-by-copying t) ; Backup by copying rather renaming
|
||||||
(setq delete-old-versions t) ; Delete excess backup versions silently
|
(setq delete-old-versions t) ; Delete excess backup versions silently
|
||||||
(setq make-backup-files nil)
|
(setq make-backup-files nil)
|
||||||
(setq version-control t))
|
(setq version-control t)
|
||||||
|
|
||||||
;;; Subr
|
;;; Subr
|
||||||
(progn
|
;; Allow for shorter responses: "y" for yes and "n" for no.
|
||||||
;; Allow for shorter responses: "y" for yes and "n" for no.
|
(defalias #'yes-or-no-p 'y-or-n-p)
|
||||||
(defalias #'yes-or-no-p 'y-or-n-p)
|
;; Never show the hello file
|
||||||
;; Never show the hello file
|
(defalias #'view-hello-file #'ignore)
|
||||||
(defalias #'view-hello-file #'ignore))
|
|
||||||
|
|
||||||
;;; Mule-util
|
;;; Mule-util
|
||||||
(setq truncate-string-ellipsis "…")
|
(setq truncate-string-ellipsis "…")
|
||||||
|
|
||||||
;;; Frames and windows
|
;;; Frames and windows
|
||||||
|
|
||||||
(setq frame-title-format '("%b – Emacs")
|
(setq frame-title-format '("%b – Emacs")
|
||||||
icon-title-format frame-title-format)
|
icon-title-format frame-title-format)
|
||||||
|
|
||||||
@@ -100,7 +92,6 @@
|
|||||||
(setq-default word-wrap t)
|
(setq-default word-wrap t)
|
||||||
|
|
||||||
;;; Smooth scrolling
|
;;; Smooth scrolling
|
||||||
|
|
||||||
;; Enables faster scrolling through unfontified regions. This may result in
|
;; Enables faster scrolling through unfontified regions. This may result in
|
||||||
;; brief periods of inaccurate syntax highlighting immediately after scrolling,
|
;; brief periods of inaccurate syntax highlighting immediately after scrolling,
|
||||||
;; which should quickly self-correct.
|
;; which should quickly self-correct.
|
||||||
|
|||||||
Reference in New Issue
Block a user