X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/blobdiff_plain/4b4c2c1dcdd5b5dee2cb6265f17914d4581a09ef..5a96c38883409f1e2844e78ba8f9f3942244eceb:/init.org diff --git a/init.org b/init.org index cdc5ca2..36bcc59 100644 --- a/init.org +++ b/init.org @@ -76,7 +76,7 @@ file. ** License #+begin_src emacs-lisp :comments none -;; Copyright (C) 2018 Amin Bandali +;; Copyright (C) 2018 Amin Bandali ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -327,8 +327,11 @@ it it's own file. While at it, treat themes as safe. ** Secrets file +Load the secrets file if it exists, otherwise show a warning. + #+begin_src emacs-lisp -(load (no-littering-expand-etc-file-name "secrets")) +(with-demoted-errors + (load (no-littering-expand-etc-file-name "secrets"))) #+end_src ** Better =$PATH= handling @@ -416,6 +419,24 @@ Font stack with better unicode support, around =Ubuntu Mono= and (setq text-scale-mode-step 1.05) #+end_src +** Focus follows mouse + +I’d like focus to follow the mouse when I move the cursor from one +window to the next. + +#+begin_src emacs-lisp +(setq mouse-autoselect-window t) +#+end_src + +Let’s define a function to conveniently disable this for certain +buffers and/or modes. + +#+begin_src emacs-lisp +(defun amin--no-mouse-autoselect-window () + (make-local-variable 'mouse-autoselect-window) + (setq mouse-autoselect-window nil)) +#+end_src + ** Libraries #+begin_src emacs-lisp @@ -720,12 +741,15 @@ customizing it. (evil-mode 1) (general-swap-key nil '(normal motion) ";" ":") - (setq evil-want-visual-char-semi-exclusive t) + (setq evil-want-visual-char-semi-exclusive t + evil-cross-lines t) ;; custom mode state mappings - (dolist (mspair '((ebdb-mode . emacs) - (helpful-mode . motion) - (view-mode . motion))) + (dolist (mspair '((ebdb-mode . emacs) + (term-mode . emacs) + (helpful-mode . motion) + (magit-blame-mode . motion) + (view-mode . motion))) (evil-set-initial-state (car mspair) (cdr mspair))) ;; fix tab and indentation in src blocks inside org-mode buffer @@ -793,6 +817,8 @@ customizing it. "a" '(:ignore t :wk "apps") "a i" 'ielm + "a s" '(:ignore t :wk "shells/terms") + "b" '(:ignore t :wk "buffers") "b k" 'kill-this-buffer "b s" 'save-buffer @@ -845,7 +871,7 @@ In short, my favourite way of life. #+begin_src emacs-lisp (use-package org - :defer 3 + :defer 1 :general (amin--leader-keys :states 'normal @@ -989,8 +1015,11 @@ Not just how I do git, but /the/ way to do git. #+begin_src emacs-lisp (use-package magit - :defer 2 - :general (amin--leader-keys "g s" 'magit-status) + :defer 1 + :general + (amin--leader-keys + "g s" 'magit-status + "g l" 'magit-log-buffer-file) :bind ("s-g" . magit-status) :config (magit-add-section-hook 'magit-status-sections-hook @@ -1089,11 +1118,18 @@ There's no way I could top that, so I won't attempt to. (eshell-send-input)) (defun amin|eshell-setup () + (make-local-variable 'company-idle-delay) + (setq company-idle-delay nil) (bind-keys :map eshell-mode-map - ("C-d" . amin/eshell-quit-or-delete-char) - ("C-l" . amin/eshell-clear))) + ("C-d" . amin/eshell-quit-or-delete-char) + ("C-S-l" . amin/eshell-clear) + ("M-r" . counsel-esh-history) + ([tab] . company-complete))) - :hook (eshell-mode . amin|eshell-setup)) + :hook (eshell-mode . amin|eshell-setup) + :custom + (eshell-hist-ignoredups t) + (eshell-input-filter 'eshell-input-filter-initial-space)) #+end_src *** Ibuffer @@ -1251,7 +1287,8 @@ TODO: break this giant source block down into individual org sections. :config (column-number-mode)) (progn ; `text-mode' - (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left)) + (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left) + (add-hook 'text-mode-hook #'abbrev-mode)) (use-package tramp :defer t @@ -1278,13 +1315,12 @@ TODO: break this giant source block down into individual org sections. #+begin_src emacs-lisp (use-package company - :defer 2 + :defer 1 :bind (:map company-active-map ([tab] . company-complete-common-or-cycle) ([escape] . company-abort)) :custom - (company-idle-delay 0.3) (company-minimum-prefix-length 1) (company-selection-wrap-around t) (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") @@ -1717,16 +1753,6 @@ Emacs package that displays available keybindings in popup (load-theme 'tangomod t) #+end_src -** COMMENT [[https://github.com/Malabarba/smart-mode-line][smart-mode-line]] - -#+begin_src emacs-lisp -(use-package smart-mode-line - :config - (sml/setup) - (sml/apply-theme 'light) - (remove-hook 'display-time-hook 'sml/propertize-time-string)) -#+end_src - ** doom-modeline #+begin_src emacs-lisp @@ -1802,7 +1828,7 @@ Emacs package that displays available keybindings in popup #+begin_src emacs-lisp (use-package projectile - :defer 2 + :defer t :bind-keymap ("C-c p" . projectile-command-map) :config (projectile-mode) @@ -1839,7 +1865,7 @@ Emacs package that displays available keybindings in popup #+begin_src emacs-lisp (use-package shell-toggle :after eshell - :general (amin--leader-keys "a s" 'amin/shell-toggle) + :general (amin--leader-keys "a s e" 'amin/shell-toggle) :bind ("C-c e" . amin/shell-toggle) :config (defun amin/shell-toggle (make-cd) @@ -1892,6 +1918,7 @@ Make =*scratch*= and =*Messages*= unkillable. :config (unkillable-scratch 1) :custom + (unkillable-scratch-behavior 'do-nothing) (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))) #+end_src @@ -1985,7 +2012,47 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]]. :hook (text-mode . typo-mode)) #+end_src -** slack +** hl-todo + +#+begin_src emacs-lisp +(use-package hl-todo + :defer 4 + :config + (global-hl-todo-mode)) +#+end_src + +** shrink-path + +#+begin_src emacs-lisp +(use-package shrink-path + :after eshell + :config + (setq eshell-prompt-regexp "\\(.*\n\\)*λ " + eshell-prompt-function #'+eshell/prompt) + + (defun +eshell/prompt () + (let ((base/dir (shrink-path-prompt default-directory))) + (concat (propertize (car base/dir) + 'face 'font-lock-comment-face) + (propertize (cdr base/dir) + 'face 'font-lock-constant-face) + (propertize (+eshell--current-git-branch) + 'face 'font-lock-function-name-face) + "\n" + (propertize "λ" 'face 'eshell-prompt-face) + ;; needed for the input text to not have prompt face + (propertize " " 'face 'default)))) + + (defun +eshell--current-git-branch () + (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n") + when (string-match "^\*" match) + collect match)))) + (if (not (eq branch nil)) + (concat " " (substring branch 2)) + "")))) +#+end_src + +** COMMENT slack :ARCHIVE: Hopefully temporary. @@ -2050,47 +2117,7 @@ Hopefully temporary. (setq alert-default-style 'notifier)) #+end_src -** hl-todo - -#+begin_src emacs-lisp -(use-package hl-todo - :defer 4 - :config - (global-hl-todo-mode)) -#+end_src - -** shrink-path - -#+begin_src emacs-lisp -(use-package shrink-path - :after eshell - :config - (setq eshell-prompt-regexp "\\(.*\n\\)*λ " - eshell-prompt-function #'+eshell/prompt) - - (defun +eshell/prompt () - (let ((base/dir (shrink-path-prompt default-directory))) - (concat (propertize (car base/dir) - 'face 'font-lock-comment-face) - (propertize (cdr base/dir) - 'face 'font-lock-constant-face) - (propertize (+eshell--current-git-branch) - 'face 'font-lock-function-name-face) - "\n" - (propertize "λ" 'face 'eshell-prompt-face) - ;; needed for the input text to not have prompt face - (propertize " " 'face 'default)))) - - (defun +eshell--current-git-branch () - (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n") - when (string-match "^\*" match) - collect match)))) - (if (not (eq branch nil)) - (concat " " (substring branch 2)) - "")))) -#+end_src - -** magithub +** COMMENT magithub :ARCHIVE: For when I /have to/ use GH. @@ -2109,6 +2136,40 @@ For when I /have to/ use GH. :after eshell) #+end_src +** multi-term + +#+begin_src emacs-lisp +(use-package multi-term + :defer 1 + :general (amin--leader-keys + "a s m" 'multi-term + "a s p" 'multi-term-dedicated-toggle) + :bind ("C-c C-j" . term-line-mode) + :config + (setq multi-term-program "/bin/screen" + ;; TODO: add separate bindings for connecting to existing + ;; session vs. always creating a new one + multi-term-dedicated-select-after-open-p t + multi-term-dedicated-window-height 20 + multi-term-dedicated-max-window-height 30 + term-bind-key-alist + '(("C-c C-c" . term-interrupt-subjob) + ("C-c C-e" . term-send-esc) + ("C-k" . kill-line) + ("C-y" . term-paste) + ("M-f" . term-send-forward-word) + ("M-b" . term-send-backward-word) + ("M-p" . term-send-up) + ("M-n" . term-send-down) + ("" . term-send-backward-kill-word) + ("" . term-send-backward-kill-word) + ("M-d" . term-send-delete-word) + ("M-," . term-send-raw) + ("M-." . comint-dynamic-complete)) + term-unbind-key-alist + '("C-z" "C-x" "C-c" "C-h" "C-y" ""))) +#+end_src + * Email #+begin_src emacs-lisp @@ -2203,18 +2264,22 @@ For when I /have to/ use GH. :map gnus-summary-mode-map ("r" . gnus-summary-reply-with-original) ("R" . gnus-summary-wide-reply-with-original) - ("M-L" . org-store-link))) + ("M-L" . org-store-link)) + :hook (gnus-summary-mode . amin--no-mouse-autoselect-window)) (use-package gnus-msg :config (setq gnus-posting-styles '((".*" (address "amin@aminb.org") - (body "\nBest,\namin\n")) + (body "\nBest,\namin\n") + (eval (setq amin--message-cite-say-hi t))) ("gnu.*" (address "bandali@gnu.org")) ((header "subject" "ThankCRM") - (to "webmasters-comment@gnu.org")) + (to "webmasters-comment@gnu.org") + (body "\nAdded to 2018supporters.html.\n\nMoving to campaigns.\n\n-amin\n") + (eval (setq amin--message-cite-say-hi nil))) ("nnimap\\+uwaterloo:.*" (address "abandali@uwaterloo.ca") (gcc "\"nnimap+uwaterloo:Sent Items\""))))) @@ -2252,6 +2317,7 @@ For when I /have to/ use GH. #+begin_src emacs-lisp (use-package message :config + (defconst amin--message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:") (defconst message-cite-style-bandali '((message-cite-function 'message-cite-original) (message-citation-line-function 'message-insert-formatted-citation-line) @@ -2259,19 +2325,25 @@ For when I /have to/ use GH. (message-yank-prefix "> ") (message-yank-cited-prefix ">") (message-yank-empty-prefix ">") - (message-citation-line-format "Hi %F,\n\nOn %Y-%m-%d %l:%M %p, %N wrote:")) + (message-citation-line-format + (if amin--message-cite-say-hi + (concat "Hi %F,\n\n" amin--message-cite-style-format) + amin--message-cite-style-format))) "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.") (setq message-cite-style 'message-cite-style-bandali message-kill-buffer-on-exit t message-send-mail-function 'message-send-mail-with-sendmail message-sendmail-envelope-from 'header message-dont-reply-to-names - "\\(\\(.*@aminb\\.org\\)\\|\\(\\(aminb?\\|mab\\|bandali\\)@gnu\\.org\\)\\|\\(\\(m\\|a\\(min\\.\\)?\\)bandali@uwaterloo\\.ca\\)\\)" + "\\(\\(.*@aminb\\.org\\)\\|\\(amin@bandali\\.me\\)\\|\\(\\(aminb?\\|mab\\|bandali\\)@gnu\\.org\\)\\|\\(\\(m\\|a\\(min\\.\\)?\\)bandali@uwaterloo\\.ca\\)\\)" message-user-fqdn "aminb.org") :hook (;; (message-setup . mml-secure-message-sign-pgpmime) (message-mode . flyspell-mode) - (message-mode . (lambda () (setq fill-column 65 - message-fill-column 65)))) + (message-mode . (lambda () + ;; (setq fill-column 65 + ;; message-fill-column 65) + (make-local-variable 'company-idle-delay) + (setq company-idle-delay 0.2)))) ;; :custom-face ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold)))) ;; (message-header-to ((t (:foreground "#111" :weight normal)))) @@ -2307,92 +2379,37 @@ Convenient footnotes in =message-mode=. footnote-style 'unicode)) #+end_src -** COMMENT supercite - -#+begin_src emacs-lisp -(use-package supercite - :after message - :init - (setq sc-nested-citation-p t - ;; sc-cite-blank-lines-p t - sc-citation-leader "" - sc-reference-tag-string "" - sc-preferred-header-style 5 ; (sc-header-author-writes) - sc-auto-fill-region-p nil - sc-confirm-always-p nil) - :config - ;; (defun amin--sc-header-on-wrote () - ;; "\"On , wrote:\" unless: - ;; 1. the \"sc-author\" field cannot be found, in which case nothing is inserted; - ;; 2. the \"date\" field is missing in which case only the from part is printed." - ;; (let ((sc-mumble "") - ;; (whofrom (sc-whofrom))) - ;; (if whofrom - ;; (insert sc-reference-tag-string - ;; (sc-hdr "On " (sc-mail-field "date") ", ") - ;; (sc-hdr "" (sc-mail-field "sc-author")) " wrote:\n")))) - ;; (defun amin--sc-header () - ;; "Hi ,\n\n writes:" - ;; (let ((sc-mumble "") - ;; (whofrom (sc-whofrom))) - ;; (if whofrom - ;; (insert (sc-hdr "Hi " (sc-mail-field "sc-firstname") ",\n\n") - ;; sc-reference-tag-string - ;; whofrom - ;; " writes:\n")))) - ;; (add-to-list 'sc-rewrite-header-list '(amin--sc-header) t) - ;; (add-to-list 'sc-rewrite-header-list '(amin--sc-header-on-wrote) t) - ;; (setq sc-preferred-header-style (1- (length sc-rewrite-header-list))) - (add-hook 'mail-citation-hook 'sc-cite-original)) -#+end_src - -** ebdb - -#+begin_src emacs-lisp -(use-package ebdb - :defer 1 - :bind (:map gnus-group-mode-map ("e" . ebdb)) - :config - (setq ebdb-sources (no-littering-expand-var-file-name "ebdb"))) - -(use-package ebdb-com - :after ebdb) - -(use-package ebdb-complete - :after ebdb - :config - (ebdb-complete-enable)) - -(use-package ebdb-gnus - :after ebdb) - -(use-package ebdb-message - :after ebdb) +** bbdb -;; (use-package ebdb-vcard -;; :after ebdb) -#+end_src - -** COMMENT bbdb +Manually install bbdb (=lisp/bbdb= copied from an ELPA-based setup), +because installing it from source on Emacs 27 using the following +submodule configuration for some reason doesn’t work and results in +very strange errors when using any of the functions. -#+begin_comment +#+begin_src conf :tangle no [submodule "bbdb"] path = lib/bbdb url = https://git.savannah.nongnu.org/git/bbdb.git - load-path = lisp/elisp + load-path = lisp info-path = doc build-step = ./autogen.sh - build-step = ./configure --with-lispdir=elisp + build-step = ./configure build-step = make build-step = make install -#+end_comment +#+end_src + +I tried using =borg-elpa= instead of doing it like this, but it added +2 seconds to my startup time, which is unacceptable to me. #+begin_src emacs-lisp (use-package bbdb + :load-path "lisp/bbdb" :init - (bbdb-mua-auto-update-init 'message) - (setq bbdb-mua-auto-update-p 'query) - (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)) + (load (expand-file-name "lisp/bbdb/bbdb-autoloads.el" user-emacs-directory)) + ;; (bbdb-mua-auto-update-init 'message) + (setq bbdb-mua-auto-update-p 'query + bbdb-complete-mail nil) + (bbdb-initialize 'gnus 'message)) #+end_src ** COMMENT message-x @@ -2422,181 +2439,6 @@ Convenient footnotes in =message-mode=. (gnus-harvest-install))) #+end_src -** COMMENT gnus-alias :ARCHIVE: - -#+begin_src emacs-lisp -(use-package gnus-alias - :commands (gnus-alias-determine-identity - gnus-alias-select-identity) - :bind (:map message-mode-map - ("s-i" . gnus-alias-select-identity)) - :config - (setq - gnus-alias-default-identity "amin" - gnus-alias-identity-alist - '(("amin" - nil ;; Does not refer to any other identity - "Amin Bandali " - nil ;; Organization - nil ;; extra headers - nil ;; extra body text - nil) ;; signature file - ("gnu" - nil - "Amin Bandali " - nil - nil - nil - nil) - ("uw" - nil - "Amin Bandali " - nil - (("Gcc" . "\"nnimap+uwaterloo:Sent Items\"")) - nil - nil)) - gnus-alias-identity-rules - '(("amin" ("Delivered-To" "