move more settings to the early init file

This commit is contained in:
2022-01-16 15:27:42 +01:00
parent c65ffe449e
commit 306a7fc2a4
6 changed files with 97 additions and 49 deletions

View File

@@ -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

View File

@@ -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