.emacs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. (add-to-list 'default-frame-alist '(width . 120))
  2. (add-to-list 'default-frame-alist '(height . 40))
  3. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  4. (package-initialize)
  5. (setq custom-file "~/.emacs.custom.el")
  6. (load-file custom-file)
  7. (load-file "~/.emacs.orgconf.el")
  8. ;; fallback to this if dbus doesn't work
  9. ;; (defun my/set-theme-based-on-time ()
  10. ;; (let ((hour (string-to-number (format-time-string "%H"))))
  11. ;; (if (or (< hour 7) (> hour 19) )
  12. ;; (load-theme 'modus-vivendi-tinted t)
  13. ;; (load-theme 'modus-operandi-tinted t))))
  14. ;; (my/set-theme-based-on-time)
  15. ;; (run-at-time "1 min" 3600 'my/set-theme-based-on-time)
  16. (require 'dbus)
  17. (defun my/system-dark-mode-p ()
  18. "Return non-nil if GNOME prefers dark mode."
  19. (string=
  20. (string-trim
  21. (shell-command-to-string
  22. "gsettings get org.gnome.desktop.interface color-scheme"))
  23. "'prefer-dark'"))
  24. (defvar my/current-theme nil)
  25. (defun my/set-theme-based-on-system (&rest _)
  26. "Load Emacs theme matching system appearance."
  27. (let ((theme (if (my/system-dark-mode-p)
  28. 'modus-vivendi-tinted
  29. 'modus-operandi-tinted)))
  30. (unless (eq theme my/current-theme)
  31. (mapc #'disable-theme custom-enabled-themes)
  32. (load-theme theme t)
  33. (setq my/current-theme theme))))
  34. ;; Apply theme at startup
  35. (my/set-theme-based-on-system)
  36. ;; Update immediately when GNOME theme changes
  37. (dbus-register-signal
  38. :session
  39. "org.freedesktop.portal.Desktop"
  40. "/org/freedesktop/portal/desktop"
  41. "org.freedesktop.portal.Settings"
  42. "SettingChanged"
  43. #'my/set-theme-based-on-system)
  44. (add-hook 'prog-mode-hook #'display-line-numbers-mode)
  45. (add-hook 'prog-mode-hook #'completion-preview-mode)
  46. (setq completion-preview-minimum-symbol-length 2)
  47. (setq completion-preview-idle-delay 0.2)
  48. (setq column-number-mode t)
  49. (add-hook 'c-mode-hook #'eglot-ensure)
  50. (add-hook 'c++-mode-hook #'eglot-ensure)
  51. (add-hook 'rust-mode-hook #'eglot-ensure)
  52. (spacious-padding-mode 1)
  53. (use-package all-the-icons
  54. :if (display-graphic-p))
  55. (use-package all-the-icons-dired
  56. :hook (dired-mode . all-the-icons-dired-mode)
  57. :config
  58. (setq all-the-icons-dired-monochrome nil))
  59. (use-package doom-modeline
  60. :init
  61. (doom-modeline-mode 1))
  62. (use-package vertico
  63. :init (vertico-mode))
  64. (use-package orderless
  65. :custom
  66. (completion-styles '(orderless basic)))
  67. (use-package marginalia
  68. :init (marginalia-mode))
  69. (use-package consult)
  70. (global-set-key (kbd "C-x b") #'consult-buffer)
  71. (global-set-key (kbd "C-s") #'consult-line)
  72. (add-hook 'prog-mode-hook #'outline-minor-mode)
  73. ;;(golden-ratio-mode 1)
  74. (add-hook 'org-mode-hook #'visual-line-mode)
  75. (add-hook 'org-mode-hook #'flyspell-mode)
  76. (move-text-default-bindings)
  77. ;; Avoid performance issues in files with very long lines.
  78. (global-so-long-mode 1)
  79. (require 'multiple-cursors)
  80. (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
  81. (global-set-key (kbd "C-§") 'mc/mark-next-like-this)
  82. (global-set-key (kbd "C-M-!") 'mc/mark-all-like-this)
  83. (global-set-key (kbd "C-d") 'duplicate-line)
  84. (put 'scroll-left 'disabled nil)