summaryrefslogtreecommitdiff
path: root/.emacs.d/init-spw.el
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-01-28 14:36:21 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-01-28 14:38:10 -0700
commite5305ce8dad60bfdbc08229249f03b41843a0ae3 (patch)
treee35a85c35fb3f864489b387764cd002caf39854b /.emacs.d/init-spw.el
parenta83a47089dd31af40a818dcd9b2d9c8e69ec6f0e (diff)
downloaddotfiles-e5305ce8dad60bfdbc08229249f03b41843a0ae3.tar.gz
attempt to optimise dynamic font changes
Diffstat (limited to '.emacs.d/init-spw.el')
-rw-r--r--.emacs.d/init-spw.el35
1 files changed, 17 insertions, 18 deletions
diff --git a/.emacs.d/init-spw.el b/.emacs.d/init-spw.el
index f6bcbc76..05792631 100644
--- a/.emacs.d/init-spw.el
+++ b/.emacs.d/init-spw.el
@@ -245,6 +245,11 @@ add places the library might be available to `load-path'."
(when-let ((hangul-font
(spw/first-available-font spw/preferred-hangul-fonts)))
(set-fontset-font t 'hangul hangul-font))
+ (when (and (not (spw/use-tabs-not-frames))
+ (find-font (font-spec :name "Cousine-10"))
+ (find-font (font-spec :name "Inconsolata-13")))
+ (add-to-list 'window-size-change-functions
+ #'spw/maybe-change-frame-font))
;; again on laptop, need to fit a bit more in these windows than can
;; with Inconsolata
@@ -263,24 +268,18 @@ add places the library might be available to `load-path'."
(spw/do-font-setup))
(defun spw/maybe-change-frame-font (frame)
- (when (and (not (spw/use-tabs-not-frames))
- (frame-size-changed-p frame)
- (find-font (font-spec :name "Cousine-10"))
- (find-font (font-spec :name "Inconsolata-13")))
- (set-frame-font
- (font-spec :name
- ;; Between these pixel widths is roughly where we can get two
- ;; vertical windows in if we shrink our font a bit; if much
- ;; larger, we can get two without shrinking, and if much
- ;; smaller, shrinking will not help. Mainly used with my
- ;; C-i - i3 binding
- (if (and (> (frame-pixel-width frame) 1300)
- (< (frame-pixel-width frame) 1485))
- "Cousine-10"
- "Inconsolata-13"))
- nil
- (list frame))))
-(add-to-list 'window-size-change-functions #'spw/maybe-change-frame-font)
+ (when (frame-size-changed-p frame)
+ (let ((wanted-font
+ ;; Between these pixel widths is roughly where we can get two
+ ;; vertical windows in if we shrink our font a bit; if much larger,
+ ;; we can get two without shrinking, and if much smaller, shrinking
+ ;; will not help. Mainly used with my C-i - i3 binding
+ (if (and (> (frame-pixel-width frame) 1300)
+ (< (frame-pixel-width frame) 1485))
+ "Cousine-10"
+ "Inconsolata-13")))
+ (unless (string= (frame-parameter frame 'font-parameter) wanted-font)
+ (set-frame-font (font-spec :name wanted-font))))))
(when (fboundp 'set-scroll-bar-mode) (set-scroll-bar-mode nil))
(when (fboundp 'tool-bar-mode) (tool-bar-mode 0))