summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/init.el27
1 files changed, 18 insertions, 9 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 0ba5c8c0..8c864913 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -116,15 +116,24 @@ windows side-by-side in the 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
-;; dark background. But if we're in tmux then I can always have dark-on-light
-;; by typing C-\ W (see ~/.tmux.conf).
-(defun spw/set-tmux-background-mode (frame)
- (when (cl-find-if (apply-partially #'string-prefix-p "TMUX=")
- (frame-parameter frame 'environment))
- (let ((frame-background-mode 'light))
- (frame-set-background-mode frame))))
-(add-to-list 'after-make-frame-functions #'spw/set-tmux-background-mode)
+;;; `frame--current-backround-mode' assumes that TERM=screen-256color means a
+;;; dark background. But if we're in tmux then I can always have a light
+;;; background by typing C-\ W (see ~/.tmux.conf).
+
+;; Handle 'emacs -nw' initial frames.
+(when (and (framep terminal-frame)
+ (cl-find-if
+ (apply-partially #'string-prefix-p "TMUX=") initial-environment))
+ (set-terminal-parameter terminal-frame 'background-mode 'light))
+
+;; Handle 'emacsclient -tc' frames.
+;; Require that TMUX is set in the frame's own environment parameter.
+;; The hook is run with the new tty frame selected.
+(defun spw/set-tmux-background-mode ()
+ (when (and (frame-parameter nil 'environment) ; check it has one
+ (getenv "TMUX" (selected-frame)))
+ (set-terminal-parameter nil 'background-mode 'light)))
+(add-hook 'tty-setup-hook #'spw/set-tmux-background-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.