init-package.el (10841B)
1 ;;; init-package.el --- some other packages -*- lexical-binding: t -*- 2 3 ;;; Commentary: 4 5 ;;; Code: 6 7 ;; keycast 8 (use-package keycast) 9 10 ;; hydra 11 (use-package hydra 12 :config 13 ;; multiple-cursors hydra 14 (defhydra hydra-multiple-cursors () 15 " 16 ^Mark^ ^Unmark^ ^Other^ 17 ------------------------------------------------------------------ 18 _p_ : prev line _P_ : previous _c_ : edit lines 19 _n_ : next line _N_ : next _._ : pop 20 _b_ : prev word _q_ : quit 21 _f_ : next word _i_ : insert numbers 22 _B_ : prev symbol 23 _F_ : next symbol 24 _s_ : in region 25 _a_ : all dwim 26 " 27 ("p" mc/mark-previous-like-this) 28 ("n" mc/mark-next-like-this) 29 ("b" mc/mark-previous-like-this-word) 30 ("f" mc/mark-next-like-this-word) 31 ("B" mc/mark-previous-like-this-symbol) 32 ("F" mc/mark-next-like-this-symbol) 33 ("P" mc/unmark-previous-like-this) 34 ("N" mc/unmark-next-like-this) 35 ("a" mc/mark-all-dwim) 36 ("s" mc/mark-all-in-region) 37 ("c" mc/edit-lines) 38 ("i" mc/insert-numbers) 39 ("." mc/mark-pop) 40 ("q" nil))) 41 42 ;; spell checker 43 (unless *is-windows* 44 (use-package jinx 45 :delight 46 (jinx-mode " Jinx" jinx) 47 :bind 48 ([remap ispell-word] . jinx-correct) 49 :config 50 (setq jinx-languages "en_US") 51 (add-to-list 'jinx-exclude-regexps '(t "\\cc")) 52 (dolist (range '((#x4E00 . #x9FFF) 53 (#x3400 . #x4DBF) 54 (#x3000 . #x303F) 55 (#xFF00 . #xFFEF) 56 (#x20000 . #x2A6DF))) 57 (let ((start (car range)) 58 (end (cdr range))) 59 (dotimes (i (- end start)) 60 (modify-syntax-entry (+ start i) "_" jinx--syntax-table))))) 61 62 (use-package consult-jinx 63 :straight 64 (consult-jinx 65 :type git 66 :repo "https://git.trogloxene.org/consult-jinx.git"))) 67 68 ;; terminal emulator 69 (use-package ghostel 70 :hook 71 (eshell-load . ghostel-eshell-visual-command-mode) 72 (ghostel-mode . (lambda () (cns-mode -1))) 73 :config 74 (defun my-ghostel-send-C-k-and-kill () 75 "Send `C-k' to ghostel. 76 Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring." 77 (interactive) 78 (kill-ring-save (point) (line-end-position)) 79 (ghostel-send-key "k" "ctrl")) 80 81 (setq eshell-destroy-buffer-when-process-dies t) 82 (defalias 'eshell/v 'eshell/ghostel)) 83 84 (use-package consult-ghostel 85 :straight 86 (consult-ghostel :type git 87 :files 88 ("extensions/consult-ghostel/") 89 :host github 90 :repo "dakra/ghostel")) 91 92 ;; eshell-syntax-highlighting 93 (use-package eshell-syntax-highlighting 94 :hook 95 (eshell-mode . eshell-syntax-highlighting-global-mode)) 96 97 ;; workspace 98 (use-package perspective 99 :bind 100 ("C-x M-b" . persp-list-buffers) 101 :custom 102 (persp-mode-prefix-key (kbd "C-c p")) 103 :hook 104 (after-init . persp-mode) 105 :config 106 (defun my-persp-remove-marked-ibuffers () 107 "Remove marked buffers from perspective." 108 (interactive) 109 (let ((buffers (ibuffer-get-marked-buffers))) 110 (dolist (buf buffers) 111 (persp-remove-buffer buf)))) 112 113 (defun my-persp-add-marked-ibuffers (persp-name) 114 "Add marked buffers to perspective." 115 (interactive 116 (list (completing-read "Perspective: " 117 (persp-names) 118 nil nil))) 119 (let ((buffers (ibuffer-get-marked-buffers))) 120 (persp-switch persp-name) 121 (dolist (buf buffers) 122 (persp-add-buffer buf)))) 123 124 (defun my-persp-set-marked-ibuffers (persp-name) 125 "Set marked buffers to perspective." 126 (interactive 127 (list (completing-read "Perspective: " 128 (persp-names) 129 nil nil))) 130 (let ((buffers (ibuffer-get-marked-buffers))) 131 (persp-switch persp-name) 132 (dolist (buf buffers) 133 (persp-set-buffer buf)))) 134 135 (setq persp-switch-to-buffer-behavior 'switch 136 persp-sort 'oldest) 137 (with-eval-after-load 'consult 138 (consult-customize consult-source-buffer :hidden t :default nil) 139 (add-to-list 'consult-buffer-sources persp-consult-source)) 140 (setq switch-to-prev-buffer-skip 141 (lambda (win buff bury-or-kill) 142 (or (not (persp-is-current-buffer buff)) 143 (cl-some (lambda (re) (string-match-p re (buffer-name buff))) 144 consult-buffer-filter)))) 145 (setq persp-initial-frame-name "main")) 146 147 ;; magit 148 (use-package magit 149 :config 150 (defun my-magit-toggle-parent-section () 151 "Toggle parent magit section." 152 (interactive) 153 (magit-section-up) 154 (magit-section-toggle (magit-section-at))) 155 156 (setq magit-bind-magit-project-status nil) 157 (unless *is-windows* 158 (setq magit-diff-refine-hunk 'all))) 159 160 ;; git-timemachine 161 (use-package git-timemachine) 162 163 ;; ediff 164 (use-package ediff 165 :straight nil 166 :config 167 (setq ediff-window-setup-function 'ediff-setup-windows-plain 168 ediff-split-window-function 'split-window-horizontally)) 169 170 ;; diff-hl 171 (use-package diff-hl 172 :hook 173 (diff-hl-mode . diff-hl-margin-mode) 174 (diff-hl-mode . global-diff-hl-show-hunk-mouse-mode) 175 (diff-hl-mode . diff-hl-flydiff-mode)) 176 177 ;; project 178 (use-package project 179 :straight nil 180 :config 181 (setq project-switch-commands (assq-delete-all 'project-vc-dir project-switch-commands)) 182 (setq project-switch-commands 183 (seq-uniq (append project-switch-commands 184 '((magit-project-status "Magit" ?v) 185 (ghostel-project "Ghostel" ?t) 186 (project-query-replace-regexp "Query Replace" ?q) 187 (consult-git-grep "Grep" ?g) 188 (consult-project-buffer "Buffers" ?b) 189 (project-ibuffer "Ibuffer" ?i) 190 (pi-coding-agent "Pi" ?a)))))) 191 192 (use-package project-ibuffer 193 :straight 194 (project-ibuffer :type git 195 :repo "https://git.trogloxene.org/project-ibuffer.git")) 196 197 ;; emms 198 (use-package emms 199 :commands 200 (emms-playlist-mode-switch-buffer) 201 :config 202 (emms-all) 203 (setq emms-player-list '(emms-player-vlc) 204 emms-info-functions '(emms-info-native)) 205 (emms-history-load)) 206 207 ;; tokei 208 (use-package tokei) 209 210 ;; helpful 211 (use-package helpful 212 :bind 213 (([remap describe-function] . helpful-callable) 214 ([remap describe-command] . helpful-command) 215 ([remap describe-variable] . helpful-variable) 216 ([remap describe-key] . helpful-key) 217 ([remap describe-symbol] . helpful-symbol) 218 :map helpful-mode-map 219 ("r" . remove-hook-at-point))) 220 221 ;; typing game 222 (use-package typit) 223 224 ;; z-machine interpreter 225 (use-package malyon 226 :straight 227 (malyon :fork (:host github :repo "cjennings/malyon"))) 228 229 ;; guix 230 (if *is-linux* 231 (use-package guix)) 232 233 ;; process manager 234 (use-package proced 235 :straight nil 236 :custom 237 (proced-auto-update-flag t) 238 (proced-goal-attribute nil) 239 (proced-show-remote-processes t) 240 (proced-enable-color-flag t) 241 (proced-format 'custom) 242 :config 243 (add-to-list 244 'proced-format-alist 245 '(custom user pid ppid sess tree pcpu pmem rss start time state (args comm))) 246 (setq proced-low-memory-usage-threshold 0.025 247 proced-medium-memory-usage-threshold 0.125)) 248 249 ;; syncthing 250 (use-package syncthing 251 :hook 252 (syncthing-mode . disable-truncate-lines)) 253 254 ;; pinentry 255 (if *is-linux* 256 (use-package pinentry 257 :hook 258 (after-init . pinentry-start))) 259 260 ;; pass 261 (use-package pass 262 :config 263 (defvar my-pass-meta-fields '("url" "username" "email") 264 "List of pass metadata fileds for completion.") 265 266 (defun my-password-store-append-field (entry field value) 267 "Append metadata to ENTRY." 268 (interactive 269 (let* ((entry (password-store--completing-read t)) 270 (field (completing-read "Field: " my-pass-meta-fields)) 271 (value (read-string (format "%s: " field)))) 272 (list entry field value))) 273 (let* ((old (string-trim-right (password-store--run-show entry))) 274 (new (format "%s\n%s: %s" old field value)) 275 (code (process-file-shell-command 276 (format "printf '%%s' %s | %s insert --multiline --force %s" 277 (shell-quote-argument new) 278 password-store-executable 279 (shell-quote-argument entry))))) 280 (unless (zerop code) (user-error "Update %s failed" entry)) 281 (message "Add %s: %s → %s" field value entry))) 282 283 (defun my-pass-append-field () 284 "Append metadata to the entry at point." 285 (interactive) 286 (pass--with-closest-entry 287 entry 288 (call-interactively 289 (lambda (field value) 290 (interactive 291 (let* ((f (completing-read "Field: " my-pass-meta-fields)) 292 (v (read-string (format "%s: " f)))) 293 (list f v))) 294 (my-password-store-append-field entry field value))))) 295 296 (defun my-pass-copy-email () 297 "Copy email of entry at piont to kill ring." 298 (interactive) 299 (pass-copy-field "email")) 300 301 (general-def pass-mode-map 302 "a" #'my-pass-append-field 303 "E" #'pass-edit 304 "e" #'my-pass-copy-email)) 305 306 ;; hyperbole 307 (use-package hyperbole 308 :defer 5 309 :bind 310 (("C-h h" . hyperbole) 311 ("M-RET" . my-hkey-either-lazy)) 312 :custom 313 (hsys-org-enable-smart-keys :buttons) 314 :init 315 (defun my-hkey-either-lazy (&optional arg) 316 (interactive "P") 317 (require 'hyperbole) 318 (hyperbole-mode 1) 319 (keymap-global-unset "M-RET") 320 (hkey-either arg))) 321 322 ;; elfeed 323 (use-package elfeed 324 :config 325 (defun my-elfeed-search-preview-other-window () 326 "Preview currently selected elfeed entry in another window." 327 (interactive) 328 (let ((display-buffer-alist '(("\\*elfeed-entry\\*" 329 (display-buffer-reuse-window 330 display-buffer-pop-up-window)))) 331 (current-prefix-arg '(4))) 332 (call-interactively #'elfeed-search-show-entry))) 333 334 (setq elfeed-curl-timeout 600) 335 (setq-default elfeed-search-filter "")) 336 337 ;; posframe 338 (use-package posframe) 339 340 ;; translator 341 (use-package gt 342 :bind 343 (([remap gt-buffer-render--keyboard-quit] . keyboard-quit)) 344 :config 345 (setq gt-default-translator 346 (gt-translator 347 :engines (gt-youdao-dict-engine) 348 :taker (gt-taker :text 'word :langs '(en zh)) 349 :render (gt-posframe-pin-render)))) 350 351 ;; thesaurus 352 (use-package synosaurus 353 :autoload my-synosaurus-lookup 354 :config 355 (defun my-synosaurus-lookup (arg) 356 "Lookup word in thesaurus. 357 With a prefix ARG replace the word under the cursor by a synonym." 358 (interactive "P") 359 (if arg 360 (call-interactively #'synosaurus-choose-and-replace) 361 (call-interactively #'synosaurus-lookup))) 362 363 (setq synosaurus-prefix nil 364 synosaurus-choose-method 'default)) 365 366 (provide 'init-package) 367 ;;; init-package.el ends here