load frame-geometry only in gui mode

This commit is contained in:
2025-07-03 12:16:25 +02:00
parent 0325922dd3
commit 904dd985ea

View File

@@ -377,8 +377,6 @@ startup phase.")
(defvar my-frame-title-format "%b Emacs" (defvar my-frame-title-format "%b Emacs"
"Template for displaying the title bar of visible and iconified frame.") "Template for displaying the title bar of visible and iconified frame.")
;; `display-graphic-p' not working during early-init
(setq frame-title-format my-frame-title-format) (setq frame-title-format my-frame-title-format)
(setq icon-title-format my-frame-title-format) (setq icon-title-format my-frame-title-format)
@@ -437,9 +435,10 @@ startup phase.")
(add-to-list 'initial-frame-alist '(background-color . "#1e1e1e")) (add-to-list 'initial-frame-alist '(background-color . "#1e1e1e"))
(add-to-list 'initial-frame-alist '(foreground-color . "#b2b2b2")) (add-to-list 'initial-frame-alist '(foreground-color . "#b2b2b2"))
;; Custom functions/hooks for persisting/loading frame geometry upon save/load (when (display-graphic-p)
(defvar my-frame-geometry-file (concat user-cache-directory "frame-geometry.el")) ;; Custom functions/hooks for persisting/loading frame geometry upon save/load
(defun my-frame-geometry-save () (defvar 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'." "Gets the current frame's geometry and save it to `my-frame-geometry-file'."
(let (;; (frameg-font (frame-parameter (selected-frame) 'font)) (let (;; (frameg-font (frame-parameter (selected-frame) 'font))
(frameg-top (frame-parameter (selected-frame) 'top)) (frameg-top (frame-parameter (selected-frame) 'top))
@@ -452,7 +451,7 @@ startup phase.")
;; Turn off backup for this file ;; Turn off backup for this file
(make-local-variable 'make-backup-files) (make-local-variable 'make-backup-files)
(setq make-backup-files nil) (setq make-backup-files nil)
(when (featurep 'scroll-bar) ;; for terminal scroll-bar ist not loaded (when (featurep 'scroll-bar) ;; for terminal scroll-bar is not loaded
(scroll-bar-mode -1)) (scroll-bar-mode -1))
(insert (insert
";;; " (file-name-nondirectory frameg-file) " --- Frame configuration -*- no-byte-compile: t; lexical-binding: t; -*-" ";;; " (file-name-nondirectory frameg-file) " --- Frame configuration -*- no-byte-compile: t; lexical-binding: t; -*-"
@@ -465,14 +464,14 @@ startup phase.")
) )
(when (file-writable-p frameg-file) (when (file-writable-p frameg-file)
(write-file frameg-file))))) (write-file frameg-file)))))
(defun my-frame-geometry-load () (defun my-frame-geometry-load ()
"Load `my-frame-geometry-file' which should load the previous frame's geometry." "Load `my-frame-geometry-file' which should load the previous frame's geometry."
(let ((frameg-file my-frame-geometry-file)) (let ((frameg-file my-frame-geometry-file))
(when (file-readable-p frameg-file) (when (file-readable-p frameg-file)
;; (load-file frameg-file) ;; (load-file frameg-file)
(load (expand-file-name frameg-file) nil (not my-debug) t)))) (load (expand-file-name frameg-file) nil (not my-debug) t))))
(my-frame-geometry-load) (my-frame-geometry-load)
(add-hook 'kill-emacs-hook 'my-frame-geometry-save) (add-hook 'kill-emacs-hook 'my-frame-geometry-save))
;;; Security ;;; Security