emacs: fix overlapping crux and counsel bindings
[~bandali/configs] / .emacs.d / init.el
index 31fd3e5..bfc9d28 100644 (file)
@@ -345,7 +345,7 @@ For disabling the behaviour for certain buffers and/or modes."
   ;; i don't need the default hint
   (initial-scratch-message nil)
   ;; use customizable text-mode as major mode for *scratch*
-  (initial-major-mode 'text-mode)
+  ;; (initial-major-mode 'text-mode)
   ;; inhibit buffer list when more than 2 files are loaded
   (inhibit-startup-buffer-menu t)
   ;; don't need to see the startup screen or echo area message
@@ -513,22 +513,24 @@ For disabling the behaviour for certain buffers and/or modes."
 
 (bind-keys
  ;; for back and forward mouse keys
+ ("<XF86Back>"     . previous-buffer)
  ("<mouse-8>"      . previous-buffer)
  ("<drag-mouse-8>" . previous-buffer)
+ ("<XF86Forward>"  . next-buffer)
  ("<mouse-9>"      . next-buffer)
  ("<drag-mouse-9>" . next-buffer)
  ("<drag-mouse-2>" . kill-this-buffer)
  ("<drag-mouse-3>" . ivy-switch-buffer))
 
 (bind-keys
- :prefix-map mab/straight-prefix-map
+ :prefix-map b/straight-prefix-map
  :prefix "C-c p s"
  ("u" . straight-use-package)
  ("f" . straight-freeze-versions)
  ("t" . straight-thaw-versions)
  ("P" . straight-prune-build)
  ("g" . straight-get-recipe)
- ("r" . mab/reload-init)
+ ("r" . b/reload-init)
  ;; M-x ^straight-.*-all$
  ("a c" . straight-check-all)
  ("a f" . straight-fetch-all)
@@ -549,6 +551,176 @@ For disabling the behaviour for certain buffers and/or modes."
 \f
 ;;; Essential packages
 
+(use-package exwm
+  :disabled
+  :demand
+  :config
+  (require 'exwm-config)
+
+  ;; Set the initial workspace number.
+  (setq exwm-workspace-number 4)
+
+  ;; Make class name the buffer name, truncating beyond 50 characters
+  (defun exwm-rename-buffer ()
+    (interactive)
+    (exwm-workspace-rename-buffer
+     (concat exwm-class-name ":"
+             (if (<= (length exwm-title) 50) exwm-title
+               (concat (substring exwm-title 0 49) "...")))))
+  (add-hook 'exwm-update-class-hook 'exwm-rename-buffer)
+  (add-hook 'exwm-update-title-hook 'exwm-rename-buffer)
+
+  ;; 's-R': Reset
+  (exwm-input-set-key (kbd "s-R") #'exwm-reset)
+  ;; 's-\': Switch workspace
+  (exwm-input-set-key (kbd "s-\\") #'exwm-workspace-switch)
+  ;; 's-N': Switch to certain workspace
+  (dotimes (i 10)
+    (exwm-input-set-key
+     (kbd (format "s-%d" i))
+     (lambda ()
+       (interactive)
+       (exwm-workspace-switch-create i))))
+  ;; 's-SPC': Launch application
+  ;; (exwm-input-set-key
+  ;;  (kbd "s-SPC")
+  ;;  (lambda (command)
+  ;;    (interactive (list (read-shell-command "➜ ")))
+  ;;    (start-process-shell-command command nil command)))
+
+  (exwm-input-set-key (kbd "M-s-SPC") #'counsel-linux-app)
+
+  ;; Shorten 'C-c C-q' to 'C-q'
+  (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
+
+  ;; Line-editing shortcuts
+  (setq exwm-input-simulation-keys
+       '(;; movement
+          ([?\C-b] . [left])
+          ([?\M-b] . [C-left])
+          ([?\C-f] . [right])
+          ([?\M-f] . [C-right])
+          ([?\C-p] . [up])
+          ([?\C-n] . [down])
+          ([?\C-a] . [home])
+          ([?\C-e] . [end])
+          ([?\M-v] . [prior])
+          ([?\C-v] . [next])
+          ([?\C-d] . [delete])
+          ([?\C-k] . [S-end delete])
+          ;; cut/copy/paste
+          ;; ([?\C-w] . [?\C-x])
+          ([?\M-w] . [?\C-c])
+          ([?\C-y] . [?\C-v])
+          ;; search
+          ([?\C-s] . [?\C-f])))
+
+  ;; Enable EXWM
+  (exwm-enable)
+
+  (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame)
+
+  (require 'exwm-systemtray)
+  (exwm-systemtray-enable)
+
+  (require 'exwm-randr)
+  (exwm-randr-enable)
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "s-<return>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process "urxvt" nil "urxvt")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "s-SPC")  ;; rofi doesn't properly launch programs when started from emacs
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "rofi-run" nil "rofi -show run -display-run '> ' -display-window ' 🗔 '")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "s-/")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "rofi-win" nil "rofi -show window  -display-run '> ' -display-window ' 🗔 '")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "M-SPC")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process "rofi-pass" nil "rofi-pass")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioMute>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "pamixer" nil "pamixer --toggle-mute")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioLowerVolume>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "pamixer" nil "pamixer --allow-boost --decrease 5")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioRaiseVolume>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "pamixer" nil "pamixer --allow-boost --increase 5")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioPlay>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "mpc" nil "mpc toggle")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioPrev>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "mpc" nil "mpc prev")))
+
+  ;; (exwm-input-set-key
+  ;;  (kbd "<XF86AudioNext>")
+  ;;  (lambda ()
+  ;;    (interactive)
+  ;;    (start-process-shell-command "mpc" nil "mpv next")))
+
+  (defun b/exwm-pasystray ()
+    "A command used to start pasystray."
+    (interactive)
+    (if (executable-find "pasystray")
+       (progn
+          (message "EXWM: starting pasystray ...")
+          (start-process-shell-command "pasystray" nil "pasystray --notify=all"))
+      (message "EXWM: pasystray is not installed, abort!")))
+
+  (add-hook 'exwm-init-hook #'b/exwm-pasystray)
+
+  (exwm-input-set-key
+   (kbd "s-t")
+   (lambda ()
+     (interactive)
+     (exwm-floating-toggle-floating)))
+
+  (exwm-input-set-key
+   (kbd "s-f")
+   (lambda ()
+     (interactive)
+     (exwm-layout-toggle-fullscreen)))
+
+  (exwm-input-set-key
+   (kbd "s-w")
+   (lambda ()
+     (interactive)
+     (kill-buffer (current-buffer))))
+
+  (exwm-input-set-key
+   (kbd "s-q")
+   (lambda ()
+     (interactive)
+     (exwm-manage--kill-client))))
+
 ;; use the org-plus-contrib package to get the whole deal
 (use-package org-plus-contrib)
 
@@ -1270,8 +1442,7 @@ This function is intended for use with `ivy-ignore-buffers'."
    (lambda (p) (string-match "^---?" (car p)))
    tex--prettify-symbols-alist)
   :hook ((tex-mode . auto-fill-mode)
-         (tex-mode . flyspell-mode)
-         (tex-mode . (lambda () (electric-indent-local-mode -1)))))
+         (tex-mode . flyspell-mode)))
 
 \f
 ;;; Theme
@@ -1309,7 +1480,7 @@ This function is intended for use with `ivy-ignore-buffers'."
   "Go dark."
   (interactive)
   (mapc #'disable-theme custom-enabled-themes)
-  ;; (load-theme 'doom-tomorrow-night t)
+  (load-theme 'doom-tomorrow-night t)
   (sml/apply-theme 'automatic)
   (font-lock-add-keywords
    'org-mode b/org-mode-font-lock-keywords t))
@@ -1364,7 +1535,7 @@ This function is intended for use with `ivy-ignore-buffers'."
 
   ;; prefixes for major modes
   (which-key-add-major-mode-key-based-replacements 'message-mode
-    "C-c f"   "footnote")
+    "C-c f n" "footnote")
   (which-key-add-major-mode-key-based-replacements 'org-mode
     "C-c C-v" "org-babel")
   (which-key-add-major-mode-key-based-replacements 'web-mode
@@ -1383,9 +1554,9 @@ This function is intended for use with `ivy-ignore-buffers'."
   :defer 0.4
   :bind (("C-c d"   . crux-duplicate-current-line-or-region)
          ("C-c D"   . crux-duplicate-and-comment-current-line-or-region)
-         ("C-c f c" . crux-copy-file-preserve-attributes)
-         ("C-c f d" . crux-delete-file-and-buffer)
-         ("C-c f r" . crux-rename-file-and-buffer)
+         ("C-c f C" . crux-copy-file-preserve-attributes)
+         ("C-c f D" . crux-delete-file-and-buffer)
+         ("C-c f R" . crux-rename-file-and-buffer)
          ("C-c j"   . crux-top-join-line)
          ("C-S-j"   . crux-top-join-line)))
 
@@ -1665,9 +1836,13 @@ This function is intended for use with `ivy-ignore-buffers'."
 (use-package pdf-tools
   :defer 0.5
   :bind (:map pdf-view-mode-map
-              ("<XF86Back>"    . pdf-history-backward)
-              ("<XF86Forward>" . pdf-history-forward)
-              ("M-RET"         . image-previous-line))
+              ("<C-XF86Back>"    . pdf-history-backward)
+              ("<mouse-8>"       . pdf-history-backward)
+              ("<drag-mouse-8>"  . pdf-history-backward)
+              ("<C-XF86Forward>" . pdf-history-forward)
+              ("<mouse-9>"       . pdf-history-forward)
+              ("<drag-mouse-9>"  . pdf-history-forward)
+              ("M-RET"           . image-previous-line))
   :config (pdf-tools-install nil t)
   :custom (pdf-view-resize-factor 1.05))
 
@@ -1967,7 +2142,11 @@ This function is intended for use with `ivy-ignore-buffers'."
   (bind-keys
    :map gnus-summary-mode-map
    ("M-L" . org-store-link))
-  :hook (gnus-summary-mode . b/no-mouse-autoselect-window))
+  :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
+  :custom
+  (gnus-thread-sort-functions '(gnus-thread-sort-by-number
+                                gnus-thread-sort-by-subject
+                                gnus-thread-sort-by-date)))
 
 (use-feature gnus-msg
   :config
@@ -2041,6 +2220,11 @@ https://csclub.uwaterloo.ca/~abandali")
         mm-decrypt-option 'known
         mm-verify-option 'known))
 
+(use-feature mm-uu
+  :custom
+  (mm-uu-diff-groups-regexp
+   "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
+
 (use-feature sendmail
   :config
   (setq sendmail-program (executable-find "msmtp")
@@ -2093,7 +2277,8 @@ https://csclub.uwaterloo.ca/~abandali")
   ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
   ;; (message-header-to      ((t (:foreground "#111" :weight normal))))
   ;; (message-header-cc      ((t (:foreground "#333" :weight normal))))
-  )
+  :custom
+  (message-elide-ellipsis "[...]\n"))
 
 (use-feature mml
   :delight " mml")
@@ -2112,7 +2297,7 @@ https://csclub.uwaterloo.ca/~abandali")
   :bind
   (:map message-mode-map
         :prefix-map b/footnote-prefix-map
-        :prefix "C-c f"
+        :prefix "C-c f n"
         ("a" . footnote-add-footnote)
         ("b" . footnote-back-to-message)
         ("c" . footnote-cycle-style)
@@ -2144,13 +2329,7 @@ https://csclub.uwaterloo.ca/~abandali")
 (use-feature ebdb-gnus
   :after ebdb
   :custom
-  (ebdb-gnus-window-configuration
-   '(article
-     (vertical 1.0
-               (summary 0.25 point)
-               (horizontal 1.0
-                           (article 1.0)
-                           (ebdb-gnus 0.3))))))
+  (ebdb-gnus-window-size 0.3))
 
 (use-feature ebdb-mua
   :after ebdb
@@ -2186,6 +2365,16 @@ https://csclub.uwaterloo.ca/~abandali")
         (gnus-harvest-install 'message-x)
       (gnus-harvest-install))))
 
+(use-feature gnus-article-treat-patch
+  :disabled
+  :demand
+  :load-path "lisp/"
+  :config
+  ;; note: be sure to customize faces with `:foreground "white"' when
+  ;; using a theme with a white/light background :)
+  (setq ft/gnus-article-patch-conditions
+        '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
+
 \f
 ;;; IRC (with ERC and ZNC)