summary refs log tree commit diff stats
path: root/user/emacs
diff options
context:
space:
mode:
authorAlan Pearce2022-10-03 00:08:17 +0200
committerAlan Pearce2022-10-03 00:08:17 +0200
commite55ec214705492e8ac0baaca394b34cabbc23461 (patch)
treef2ccc6e9dd5ad22065d1fb908489e2b067bf3ff0 /user/emacs
parent3a292a23130db25932a6ceec755e1bb19487e5d3 (diff)
downloadnixfiles-e55ec214705492e8ac0baaca394b34cabbc23461.tar.lz
nixfiles-e55ec214705492e8ac0baaca394b34cabbc23461.tar.zst
nixfiles-e55ec214705492e8ac0baaca394b34cabbc23461.zip
Emacs: use dark/light theme on macos according to system
Diffstat (limited to 'user/emacs')
-rw-r--r--user/emacs/init.el31
1 files changed, 27 insertions, 4 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el
index 6d66cbee..00a3598f 100644
--- a/user/emacs/init.el
+++ b/user/emacs/init.el
@@ -72,7 +72,18 @@
                     modus-themes-hl-line 'nil
                     modus-themes-region '(bg-only)
                     modus-themes-diffs 'desaturated)
-              (load-theme 'modus-operandi t)))
+              (let ((light-mode-theme 'modus-operandi)
+                    (dark-mode-theme 'modus-vivendi))
+                (defun my/set-dark-or-light-theme ()
+                  (let ((appearance (plist-get (mac-application-state) :appearance)))
+                    (cond ((equal appearance "NSAppearanceNameAqua")
+                           (load-theme light-mode-theme t))
+                          ((equal appearance "NSAppearanceNameDarkAqua")
+                           (load-theme dark-mode-theme t)))))
+                (add-hook 'mac-effective-appearance-change-hook #'my/set-dark-or-light-theme)
+                (if (boundp 'mac-effective-appearance-change-hook)
+                    (my/set-dark-or-light-theme)
+                  (load-theme light-mode-theme t)))))
   (if (eq window-system 'x)
       (setq-default line-spacing 0.2))
   (setq frame-background-mode 'light)
@@ -100,12 +111,24 @@
 
 (add-to-list 'default-frame-alist '(width . 100))
 (add-to-list 'default-frame-alist '(height . 40))
+(setq-default display-line-numbers 'relative
+              display-line-numbers-widen t)
+
+(defun noct-relative ()
+  "Show relative line numbers."
+  (setq-local display-line-numbers 'relative))
+
+(defun noct-absolute ()
+  "Show absolute line numbers."
+  (setq-local display-line-numbers t))
+
+(add-hook 'evil-insert-state-entry-hook #'noct-absolute)
+(add-hook 'evil-insert-state-exit-hook #'noct-relative)
 
 ;;; Encoding
 
-(setq bidi-paragraph-direction 'left-to-right)
-(when (version<= "27.1" emacs-version)
-  (setq bidi-inhibit-bpa t))
+(setq-default bidi-paragraph-direction 'left-to-right)
+(setq bidi-inhibit-bpa t)
 
 ;;; Dates & Times