From ac74bd759b1e63c622572e604733d8e5ca5944b4 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 22 Mar 2023 18:12:17 -0700 Subject: spw/maybe-scale-basic-faces: don't try to do anything to text frames --- .emacs.d/init.el | 57 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 97a04e21..f3347e0c 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -113,33 +113,36 @@ from those set by `custom-set-faces' for frames on wide monitors, except where doing so would itself prevent fitting two 80-column windows side-by-side in the frame." - (let ((wide-monitor-p - (> (cadddr (assoc 'geometry (frame-monitor-attributes frame))) 1635))) - (when (or wide-monitor-p - ;; Check whether a previous call made any changes we might need - ;; to undo if FRAME has moved to a smaller display. - (not (eq scroll-bar-mode - (frame-parameter frame 'vertical-scroll-bars))) - (= (face-attribute 'default :height frame) 120) - (= (face-attribute 'variable-pitch :height frame) 151)) - (let* (;; Above 1635 you can scale up and still fit two 80-col windows. - ;; Below 1315 you can't fit the two windows even w/o scaling up. - (medium-p (> 1635 (frame-pixel-width frame) 1315)) - (scale-up-p (and wide-monitor-p (not medium-p)))) - (modify-frame-parameters - frame - `(;; Can fit two 80-col windows only if we disable scroll bars. - (vertical-scroll-bars . ,(and (not (and wide-monitor-p medium-p)) - scroll-bar-mode)))) - ;; Check Emacs found the relevant font on this window system, else our - ;; height values might be invalid. - (when (find-font (font-spec :foundry "SRC" :family "Hack") frame) - (set-face-attribute 'default frame :height (if scale-up-p 120 105))) - (when (find-font (font-spec :foundry "bitstream" - :family "Bitstream Charter") - frame) - (set-face-attribute 'variable-pitch frame - :height (if scale-up-p 151 120))))))) + (when (display-graphic-p frame) + (let ((wide-monitor-p (> (cadddr (assoc 'geometry + (frame-monitor-attributes frame))) + 1635))) + (when (or wide-monitor-p + ;; Check whether a previous call made any changes we might need + ;; to undo if FRAME has moved to a smaller display. + (not (eq scroll-bar-mode + (frame-parameter frame 'vertical-scroll-bars))) + (= (face-attribute 'default :height frame) 120) + (= (face-attribute 'variable-pitch :height frame) 151)) + (let* (;; Above 1635 you can scale up and still fit two 80-col windows. + ;; Below 1315 you can't fit the two windows even w/o scaling up. + (medium-p (> 1635 (frame-pixel-width frame) 1315)) + (scale-up-p (and wide-monitor-p (not medium-p)))) + (modify-frame-parameters + frame + `(;; Can fit two 80-col windows only if we disable scroll bars. + (vertical-scroll-bars . ,(and (not (and wide-monitor-p medium-p)) + scroll-bar-mode)))) + ;; Check Emacs found the relevant font on this window system, else + ;; our height values might be invalid. + (when (find-font (font-spec :foundry "SRC" :family "Hack") frame) + (set-face-attribute 'default frame + :height (if scale-up-p 120 105))) + (when (find-font (font-spec :foundry "bitstream" + :family "Bitstream Charter") + frame) + (set-face-attribute 'variable-pitch frame + :height (if scale-up-p 151 120)))))))) (add-to-list 'window-size-change-functions #'spw/maybe-scale-basic-faces) ;;; `frame--current-backround-mode' assumes that TERM=screen-256color means a -- cgit v1.2.3