diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-05-04 17:57:54 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-05-04 22:23:32 -0700 |
commit | 635c455a655066777575564aaf8f53b7b431d0c8 (patch) | |
tree | c3f1d18e01d2e1404fb67c8b221fe7ef078f0c91 /.emacs.d | |
parent | e500f19f2d5a5fc84b84a89944f07976d853cfa2 (diff) | |
download | dotfiles-635c455a655066777575564aaf8f53b7b431d0c8.tar.gz |
scale down if frame has moved to smaller monitor & use backquote
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/init.el | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 5048ce5d..8bb84d18 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -98,30 +98,36 @@ always go via `after-focus-change-function'." 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." - (when (frame-size-changed-p frame) - (let* ((wide-monitor-p - (> (cadddr (assoc 'geometry (frame-monitor-attributes frame))) - 1635)) - ;; 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-window-p (> 1635 (frame-pixel-width frame) 1315)) - (scale-up-p (and wide-monitor-p (not medium-window-p)))) - ;; We can only fit the two 80-col windows if we disable the scroll bars. - (modify-frame-parameters - frame (list (cons 'vertical-scroll-bars - (and (not (and wide-monitor-p medium-window-p)) - scroll-bar-mode)))) - ;; Check Emacs found the relevant font on this window system, else our - ;; height values might be invalid. - (when (and (string= "SRC" (face-attribute 'default :foundry frame)) - (string= "Hack" (face-attribute 'default :family frame))) - (set-face-attribute 'default frame :height (if scale-up-p 120 105))) - (when (and (string= "bitstream" - (face-attribute 'variable-pitch :foundry frame)) - (string= "Bitstream Charter" - (face-attribute 'variable-pitch :family frame))) - (set-face-attribute 'variable-pitch frame - :height (if scale-up-p 151 120)))))) + (let ((wide-monitor-p + (> (cadddr (assoc 'geometry (frame-monitor-attributes frame))) 1635))) + (when (and (frame-size-changed-p frame) + (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 (and (string= "SRC" (face-attribute 'default :foundry frame)) + (string= "Hack" (face-attribute 'default :family frame))) + (set-face-attribute 'default frame :height (if scale-up-p 120 105))) + (when (and (string= "bitstream" + (face-attribute 'variable-pitch :foundry frame)) + (string= "Bitstream Charter" + (face-attribute 'variable-pitch :family 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) (custom-set-variables |