move more settings to the early init file
This commit is contained in:
@@ -20,7 +20,10 @@ a bunch of online resources.
|
||||
|
||||
# Installation
|
||||
|
||||
Run one of the following install script commands (using curl, wget or fetch).
|
||||
Download repo and point the emacs `init` (and `early-init.el`) file to
|
||||
this configuration.
|
||||
|
||||
Or run one of the following install script commands (using curl, wget or fetch).
|
||||
|
||||
sh -c "$(curl -fsSL http://gitea.weseng.de/daniel/emacs/raw/master/scripts/install.sh)"
|
||||
sh -c "$(wget -O- http://gitea.weseng.de/daniel/emacs/raw/master/scripts/install.sh)"
|
||||
|
||||
@@ -9,13 +9,15 @@ a bunch of online resources.
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: installation
|
||||
:END:
|
||||
Run one of the following install script commands (using curl, wget or fetch).
|
||||
Download repo and point the emacs =init= (and =early-init.el=) file to
|
||||
this configuration.
|
||||
|
||||
Or run one of the following install script commands (using curl, wget or fetch).
|
||||
#+begin_src sh
|
||||
sh -c "$(curl -fsSL http://gitea.weseng.de/daniel/emacs/raw/master/scripts/install.sh)"
|
||||
sh -c "$(wget -O- http://gitea.weseng.de/daniel/emacs/raw/master/scripts/install.sh)"
|
||||
sh -c "$(fetch -o - http://gitea.weseng.de/daniel/emacs/raw/master/scripts/install.sh)"
|
||||
#+end_src
|
||||
|
||||
Installation path is =~/.config/emacs=. See details and other
|
||||
installed linux packages as requirements inside =sripts/install.sh=.
|
||||
|
||||
|
||||
@@ -1,4 +1,44 @@
|
||||
;;; early-init.el --- Early initialization file for Emacs -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
;; Emacs 27.1 introduced early-init.el, which is run before init.el, before
|
||||
;; package and UI initialization happens, and before site files are loaded.
|
||||
|
||||
;;; Code:
|
||||
;; A big contributor to startup times is garbage collection. We up the gc
|
||||
;; threshold to temporarily prevent it from running, then reset it later by
|
||||
;; enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
|
||||
(setq gc-cons-threshold (* 50 1000 1000)) ;; Make startup faster by reducing the frequency of garbage collection. The default is 800 kilobytes. Measured in bytes. Will be decreased again at the end.
|
||||
|
||||
;; make UTF-8 the default coding system:
|
||||
(set-language-environment "UTF-8")
|
||||
;; `set-language-enviornment' sets `default-input-method', which is unwanted
|
||||
(setq default-input-method nil)
|
||||
|
||||
(setq config-dir (file-name-directory (file-truename user-init-file))) ;; user-init-file: ~/.config/emacs/init, file-truename: /opt/emacs-conf/init
|
||||
(setq user-emacs-directory "~/.config/emacs/") ;; for cache etc.
|
||||
(defconst user-cache-directory
|
||||
(file-name-as-directory (concat user-emacs-directory ".cache"))
|
||||
"My Emacs storage area for persistent files.")
|
||||
;; create the `user-cache-directory' if not exists
|
||||
(make-directory user-cache-directory t)
|
||||
|
||||
(mapc (lambda (item) (add-to-list 'load-path item))
|
||||
(list
|
||||
(concat config-dir "settings") ;; path where settings files are kept
|
||||
(concat config-dir "lisp") ;; personal elisp lib dir, for manually installed packages
|
||||
(concat config-dir "lisp/adaptive-wrap") ;; https://elpa.gnu.org/packages/adaptive-wrap.html
|
||||
(concat config-dir "lisp/dash")
|
||||
(concat config-dir "lisp/with-editor")
|
||||
(concat config-dir "lisp/hydra") ;; required by treemacs org-ref
|
||||
(concat config-dir "lisp/async") ;; https://melpa.org/#/async required by ob-async
|
||||
(concat config-dir "lisp/persist") ;; https://elpa.gnu.org/packages/persist.html required by org-drill
|
||||
(concat config-dir "lisp/use-package") ;; https://melpa.org/#/use-package
|
||||
))
|
||||
|
||||
;;
|
||||
;; FRAME
|
||||
;;
|
||||
;; (add-to-list 'default-frame-alist '(fullscreen . maximized)) ;; restore saved geometry, see gui-settings.el my-frame-geometry-
|
||||
(add-to-list 'default-frame-alist '(tool-bar-position . left))
|
||||
;; (add-to-list 'default-frame-alist '(horizontal-scroll-bars . t)) ;; see gui-settings
|
||||
@@ -6,3 +46,44 @@
|
||||
;; transparency
|
||||
(set-frame-parameter (selected-frame) 'alpha '(95 . 95)) ;; VALUE: '(<active> . <inactive>) / <both>
|
||||
(add-to-list 'default-frame-alist '(alpha . (95 . 95)))
|
||||
|
||||
;; Custom functions/hooks for persisting/loading frame geometry upon save/load
|
||||
(setq my-frame-geometry-file (concat user-cache-directory "frame-geometry.el"))
|
||||
(defun my-frame-geometry-save ()
|
||||
"Gets the current frame's geometry and save it to `my-frame-geometry-file'."
|
||||
(let ((frameg-font (frame-parameter (selected-frame) 'font))
|
||||
(frameg-left (frame-parameter (selected-frame) 'left))
|
||||
(frameg-top (frame-parameter (selected-frame) 'top))
|
||||
(frameg-width (frame-parameter (selected-frame) 'width))
|
||||
(frameg-height (frame-parameter (selected-frame) 'height))
|
||||
(frameg-file my-frame-geometry-file))
|
||||
(with-temp-buffer
|
||||
;; Turn off backup for this file
|
||||
(make-local-variable 'make-backup-files)
|
||||
(setq make-backup-files nil)
|
||||
(insert
|
||||
";;; This file stores the previous emacs frame's geometry.\n"
|
||||
";;; Last generated " (current-time-string) ".\n"
|
||||
"(setq initial-frame-alist\n"
|
||||
;; " '((font . \"" frameg-font "\")\n"
|
||||
" '("
|
||||
(format " (top . %d)\n" (max frameg-top 0))
|
||||
(format " (left . %d)\n" (max frameg-left 0))
|
||||
(format " (width . %d)\n" (max frameg-width 0))
|
||||
(format " (height . %d)))\n" (max frameg-height 0)))
|
||||
(when (file-writable-p frameg-file)
|
||||
(write-file frameg-file)))))
|
||||
(defun my-frame-geometry-load ()
|
||||
"Load `my-frame-geometry-file' which should load the previous frame's geometry."
|
||||
(let ((frameg-file my-frame-geometry-file))
|
||||
(when (file-readable-p frameg-file)
|
||||
(load-file frameg-file))))
|
||||
;; Special work to do ONLY when there is a window system being used
|
||||
;; (if (display-graphic-p)
|
||||
;; (progn
|
||||
;; (add-hook 'kill-emacs-hook 'my-frame-geometry-save)))
|
||||
(my-frame-geometry-load)
|
||||
(add-hook 'window-setup-hook
|
||||
(lambda ()
|
||||
(if (display-graphic-p)
|
||||
(add-hook 'kill-emacs-hook 'my-frame-geometry-save))))
|
||||
|
||||
10
init
10
init
@@ -7,8 +7,14 @@
|
||||
;; Requirements: git gnuplot ledger
|
||||
|
||||
;;; Code:
|
||||
(setq config-dir (file-name-directory (file-truename user-init-file))) ;; user-init-file: ~/.config/emacs/init, file-truename: /opt/emacs-conf/init
|
||||
(require 'pre-settings (concat config-dir "settings/pre-settings.el")) ;; use-package delight functions variables
|
||||
;; Emacs 27.1 introduced early-init.el, which is run before init.el, before
|
||||
;; package and UI initialization happens, and before site files are loaded.
|
||||
;; In the case that early-init.el wasn't loaded (e.g. using old emacs? Or this
|
||||
;; file directly loaded?), we do it explicitly:
|
||||
(unless (version<= "27.1" emacs-version)
|
||||
(load (concat (file-name-directory (file-truename user-init-file)) "early-init.el")
|
||||
nil t))
|
||||
(require 'pre-settings) ;; use-package delight functions variables
|
||||
(require 'which-key-settings) ;; https://melpa.org/#/which-key
|
||||
(require 'general-settings) ;; requires which-key
|
||||
(require 'my-settings)
|
||||
|
||||
@@ -425,42 +425,5 @@ See also `dashboard-insert-section' for the sequence of elements."
|
||||
;;:hook (help-mode . virtual-auto-fill-mode)
|
||||
)
|
||||
|
||||
;; Custom functions/hooks for persisting/loading frame geometry upon save/load
|
||||
(setq my-frame-geometry-file (concat user-cache-directory "frame-geometry.el"))
|
||||
(defun my-frame-geometry-save ()
|
||||
"Gets the current frame's geometry and save it to `my-frame-geometry-file'."
|
||||
(let ((frameg-font (frame-parameter (selected-frame) 'font))
|
||||
(frameg-left (frame-parameter (selected-frame) 'left))
|
||||
(frameg-top (frame-parameter (selected-frame) 'top))
|
||||
(frameg-width (frame-parameter (selected-frame) 'width))
|
||||
(frameg-height (frame-parameter (selected-frame) 'height))
|
||||
(frameg-file my-frame-geometry-file))
|
||||
(with-temp-buffer
|
||||
;; Turn off backup for this file
|
||||
(make-local-variable 'make-backup-files)
|
||||
(setq make-backup-files nil)
|
||||
(insert
|
||||
";;; This file stores the previous emacs frame's geometry.\n"
|
||||
";;; Last generated " (current-time-string) ".\n"
|
||||
"(setq initial-frame-alist\n"
|
||||
;; " '((font . \"" frameg-font "\")\n"
|
||||
" '("
|
||||
(format " (top . %d)\n" (max frameg-top 0))
|
||||
(format " (left . %d)\n" (max frameg-left 0))
|
||||
(format " (width . %d)\n" (max frameg-width 0))
|
||||
(format " (height . %d)))\n" (max frameg-height 0)))
|
||||
(when (file-writable-p frameg-file)
|
||||
(write-file frameg-file)))))
|
||||
(defun my-frame-geometry-load ()
|
||||
"Load `my-frame-geometry-file' which should load the previous frame's geometry."
|
||||
(let ((frameg-file my-frame-geometry-file))
|
||||
(when (file-readable-p frameg-file)
|
||||
(load-file frameg-file))))
|
||||
;; Special work to do ONLY when there is a window system being used
|
||||
(if (display-graphic-p)
|
||||
(progn
|
||||
(add-hook 'after-init-hook 'my-frame-geometry-load)
|
||||
(add-hook 'kill-emacs-hook 'my-frame-geometry-save)))
|
||||
|
||||
(provide 'gui-settings)
|
||||
;;; gui-settings.el ends here
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
(concat config-dir "lisp/use-package") ;; https://melpa.org/#/use-package
|
||||
))
|
||||
|
||||
(setq gc-cons-threshold (* 50 1000 1000)) ;; Make startup faster by reducing the frequency of garbage collection. The default is 800 kilobytes. Measured in bytes. Will be decreased again at the end.
|
||||
;; count startup time
|
||||
(add-hook 'emacs-startup-hook ;; Use a hook so the message doesn't get clobbered by other messages.
|
||||
(lambda ()
|
||||
@@ -50,12 +49,6 @@ Both Win32 and Cygwin count.")
|
||||
(shell-command-to-string
|
||||
"uname -a | sed -n 's/.*\\( *Microsoft *\\).*/\\1/ip'"))
|
||||
"Microsoft"))
|
||||
(setq user-emacs-directory "~/.config/emacs/") ;; for cache etc.
|
||||
(defconst user-cache-directory
|
||||
(file-name-as-directory (concat user-emacs-directory ".cache"))
|
||||
"My Emacs storage area for persistent files.")
|
||||
;; create the `user-cache-directory' if not exists
|
||||
(make-directory user-cache-directory t)
|
||||
(defvar my-dbusp
|
||||
(and (boundp 'dbus-compiled-version) ;; t on WSL Debian machine
|
||||
(if (require 'dbus) (dbus-ping :session "org.freedesktop.Notifications"))) ;; is not enough
|
||||
|
||||
Reference in New Issue
Block a user