From 4cc84e6223a06bd1a5d9cd4aca3f943dda26f23d Mon Sep 17 00:00:00 2001 From: noa@gaiwan.org Date: Thu, 13 Jun 2024 23:00:17 +0000 Subject: Don't use use-package except to install packages --- emacs/init.el | 345 ++++++++++++++++++++++++---------------------------------- 1 file changed, 141 insertions(+), 204 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index dc50c79..ad98f0d 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -18,10 +18,8 @@ ;; properly distinguish these chords from their ascii legacy (define-key input-decode-map [?\C-m] [C-m]) -(use-package tubthumping-theme - :config - (load-theme 'tubthumping t)) - +(require 'tubthumping-theme) +(load-theme 'tubthumping t) ;; I make my caps lock a menu key, so i can open the command palette with it (define-key context-menu-mode-map (kbd "") nil) @@ -60,14 +58,10 @@ (setopt read-file-name-completion-ignore-case t) (setopt completion-ignore-case t) - - -(use-package orderless - :ensure t - :custom - (completion-styles '(orderless basic)) - (completion-category-defaults nil) - (completion-category-overrides '((file (styles partial-completion))))) +(use-package orderless :ensure t) +(setopt completion-styles '(orderless basic)) +(setopt completion-category-defaults nil) +(setopt completion-category-overrides '((file (styles partial-completion)))) (setopt confirm-nonexistent-file-or-buffer 'after-completion) @@ -98,7 +92,6 @@ (defun pulse-line (&rest _) "Pulse the current line." (pulse-momentary-highlight-one-line (point))) - (dolist (command '(scroll-up-command scroll-down-command recenter-top-bottom other-window)) (advice-add command :after #'pulse-line)) @@ -107,7 +100,6 @@ (use-package jabber :ensure t) ;; I don't actually use xmpp as xmpp that much. But i do use it to connect to irc, and this package lets me do that. Unfortunately, it's not a particularly well-behaved package; by default it clobbers some keybindings and floods the echo area with unhelpful messages. - (setopt jabber-account-list '(("noa@hmm.st"))) ;; So now what we're going to do is get it to stop showing a bunch of channels in the mode line, because there will always be new activity and i want to drop in when i feel like it, and not always have a reminder of that fact. The defun below is copied from jabber-activity-show-p-default but with an extra condition plopped in. @@ -152,11 +144,8 @@ and when JID is not in `jabber-activity-banned'." ;; Finally, have a binding to jump to a buffer in which there's been some new activity. Better than always using switch-to-buffer to get there. (keymap-global-set "C-c C-j" #'jabber-activity-switch-to) -(use-package nov - :ensure t - :mode ("\\.epub\\'" . nov-mode)) - - +(use-package nov :ensure t) +(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)) ;; also check out jinx https://github.com/minad/jinx (use-package spell-fu :ensure t) @@ -212,13 +201,10 @@ and when JID is not in `jabber-activity-banned'." ;; I also want to make the completion at point function a bit more friendly than the default, so i ask consult to provide the completion functionality. (setopt completion-in-region-function 'consult-completion-in-region) -(use-package org-contacts - :ensure t - :pin gnu - :custom - (org-contacts-files org-agenda-files) - ;; Org contacts seems to require birthdays to have a year. However, i don't know the year of a lot of people's birthdays, so i set the year to 0000. This looks bad when the birthday comes up in the agenda. I figured that i don't usually need to know how old someone is going to be, so i change the format of how the birthday appears in the agenda so that i don't get the wrong age. - (org-contacts-birthday-format "Birthday: %l")) +(use-package org-contacts :ensure t :pin gnu) +(setopt org-contacts-files org-agenda-files) +;; Org contacts seems to require birthdays to have a year. However, i don't know the year of a lot of people's birthdays, so i set the year to 0000. This looks bad when the birthday comes up in the agenda. I figured that i don't usually need to know how old someone is going to be, so i change the format of how the birthday appears in the agenda so that i don't get the wrong age. +(setopt org-contacts-birthday-format "Birthday: %l") ;; select the help window so that i can easily close it again with q (setopt help-window-select t) @@ -232,88 +218,72 @@ and when JID is not in `jabber-activity-banned'." ("C-c C-d" . helpful-at-point) ("C-h F" . helpful-function))) -(use-package window - :custom - (switch-to-buffer-obey-display-actions t)) - - -(use-package org-fc - :disabled - :ensure t - :custom - (org-fc-directories (expand-file-name "~/data/notes/"))) - -(use-package artbollocks-mode - :disabled t - :ensure t) - -(use-package org - :custom - (org-use-sub-superscripts "{}") - ;; If we enable this, emphasis markers will be hidden for a more word processor feel. This has the downside of meaning you have to delete a hidden character to get rid of bold or italic text. I don't have much of a problem with seeing the emphasis markers so i'm willing to put up with any aesthetic shortcomings for a better user experience. The package org-appear solves this by hiding them, but showing them when the point is over them, but i don't think having a whole package just for that is worth it. - (org-hide-emphasis-markers nil) - (org-startup-with-inline-images t) - (org-image-actual-width '(300)) - (org-auto-align-tags nil) - (org-tags-column 0) - (org-catch-invisible-edits 'show-and-error) - (org-special-ctrl-a/e t) - (org-insert-heading-respect-content t) - (org-ellipsis "…") - (org-display-custom-times t) - (org-time-stamp-custom-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")) - (org-extend-today-until 4) - (org-adapt-indentation nil) - (org-log-done 'time) - (org-return-follows-link t) - (org-agenda-files '("~/data/notes/notes.org")) - (org-capture-templates `(("j" "Journal" entry (file+datetree "~/data/notes/notes.org") "* %?\n" :empty-lines 1) - ("w" "Website" entry (file+datetree "~/data/notes/notes.org") "* %a\n%?\n" :empty-lines 1) - ("c" "Contact" entry (file+datetree "~/data/notes/notes.org") - "* %^{Name} +(setopt switch-to-buffer-obey-display-actions t) + +;; (use-package org-fc +;; :disabled +;; :ensure t +;; :custom +;; (org-fc-directories (expand-file-name "~/data/notes/"))) + +(setopt org-use-sub-superscripts "{}") +;; If we enable this, emphasis markers will be hidden for a more word processor feel. This has the downside of meaning you have to delete a hidden character to get rid of bold or italic text. I don't have much of a problem with seeing the emphasis markers so i'm willing to put up with any aesthetic shortcomings for a better user experience. The package org-appear solves this by hiding them, but showing them when the point is over them, but i don't think having a whole package just for that is worth it. +(setopt org-hide-emphasis-markers nil) +(setopt org-startup-with-inline-images t) +(setopt org-image-actual-width '(300)) +(setopt org-auto-align-tags nil) +(setopt org-tags-column 0) +(setopt org-catch-invisible-edits 'show-and-error) +(setopt org-special-ctrl-a/e t) +(setopt org-insert-heading-respect-content t) +(setopt org-ellipsis "…") +(setopt org-display-custom-times t) +(setopt org-time-stamp-custom-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")) +(setopt org-extend-today-until 4) +(setopt org-adapt-indentation nil) +(setopt org-log-done 'time) +(setopt org-return-follows-link t) +(setopt org-agenda-files '("~/data/notes/notes.org")) +(setopt org-capture-templates `(("j" "Journal" entry (file+datetree "~/data/notes/notes.org") "* %?\n" :empty-lines 1) + ("w" "Website" entry (file+datetree "~/data/notes/notes.org") "* %a\n%?\n" :empty-lines 1) + ("c" "Contact" entry (file+datetree "~/data/notes/notes.org") + "* %^{Name} :PROPERTIES: :ADDRESS: %^{Address} :BIRTHDAY: %^{yyyy-mm-dd} :EMAIL: %^{EMAIL}p :NOTE: %^{NOTE} :END:" - :empty-lines 1))) - - (org-agenda-tags-column t) - (org-agenda-block-separator ?─) - (org-agenda-time-grid - '((daily today require-timed) - (800 1000 1200 1400 1600 1800 2000) - " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")) - (org-agenda-current-time-string - "◀── now ─────────────────────────────────────────────────") - - :custom-face - ;;(org-ellipsis ((t (:inherit default :box nil)))) - - :bind (("C-c c" . org-capture) - ("C-c a" . org-agenda))) - -(use-package org-modern - :ensure t - :after org - :hook (org-mode . org-modern-mode) - (org-agenda-finalize . org-modern-agenda) - :custom - ;; There are three ways to make bullet lists in org mode, which seems a bit excessive to me. I almost always only use the hyphen, but i like my bullet points to look like bullets, so here i overwrite the hyphen display to show a bullet point. While i'm at it, i overwrite the others too, because they are functionally identical so should probably look the same too. - (org-modern-list '((?+ . " • ") - (?- . " • ") - (?* . " • "))) - (org-modern-timestamp nil) - (org-modern-star nil) - (org-modern-keyword nil) - (org-modern-checkbox '((88 . "☑") - (45 . - #("□–" 0 2 - (composition - ((2))))) - (32 . "□"))) - (org-modern-table nil)) + :empty-lines 1))) + +(setopt org-agenda-tags-column t) +(setopt org-agenda-block-separator ?─) +(setopt org-agenda-time-grid '((daily today require-timed) + (800 1000 1200 1400 1600 1800 2000) + " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")) +(setopt org-agenda-current-time-string + "◀── now ─────────────────────────────────────────────────") + +(global-set-key (kbd "C-c c") #'org-capture) +(global-set-key (kbd "C-c a") #'org-agenda) + +(use-package org-modern :ensure t) +(add-hook 'org-mode-hook #'org-modern-mode) +;; (add-hook 'org-agenda-finalize-hook #'org-modern-agenda) + +;; There are three ways to make bullet lists in org mode, which seems a bit excessive to me. I almost always only use the hyphen, but i like my bullet points to look like bullets, so here i overwrite the hyphen display to show a bullet point. While i'm at it, i overwrite the others too, because they are functionally identical so should probably look the same too. +(setopt org-modern-list '((?+ . " • ") + (?- . " • ") + (?* . " • "))) +(setopt org-modern-timestamp nil) +(setopt org-modern-star nil) +(setopt org-modern-keyword nil) +(setopt org-modern-checkbox '((88 . "☑") + (45 . #("□–" 0 2 + (composition + ((2))))) + (32 . "□"))) +(setopt org-modern-table nil) (defun read-file-as-string (filename) "Read file contents from FILENAME." @@ -474,19 +444,15 @@ and when JID is not in `jabber-activity-banned'." eww-auto-rename-buffer 'title) ;; Goto address mode makes urls and email address in a buffer clickable. I want these clickable links to look like links, because that's what they are. The two mouse face variables are what face is used on hover, which at the moment i ignore. It might also be worth setting them to 'highlight. -(use-package goto-addr - :custom - (global-goto-address-mode t) - (goto-address-mail-face 'link) - (goto-address-mail-mouse-face 'link) - (goto-address-url-face 'link) - (goto-address-url-mouse-face 'link)) +(setopt global-goto-address-mode t) +(setopt goto-address-mail-face 'link) +(setopt goto-address-mail-mouse-face 'link) +(setopt goto-address-url-face 'link) +(setopt goto-address-url-mouse-face 'link) ;; Abbrev mode expands one string into another string. I use it as a simple autocorrect mode. If i misspell a word, i run C-x a i g which will prompt me for what to expand the previous word into. I type the correct spelling, and whenever i make that mistake again, it will automatically be corrected. It's important to be careful not to set something that could be a typo for two words though, because otherwise it gets even more annoying. Luckily it's easy to update the abbrevs which are stored in ~/.config/emacs/abbrev_defs. M-x list-abbrevs is also a nice command which shows all the saved abbrevs and how many times they've been expanded. (add-hook 'text-mode-hook #'abbrev-mode) - -(use-package eldoc) (setopt global-eldoc-mode t) ;; use a bar cursor and blink it and don't stop blinking it. i don't know how i feel about this yet to be honest, but it helps me know which window is active so for now i'm keeping it @@ -496,20 +462,18 @@ and when JID is not in `jabber-activity-banned'." blink-cursor-interval 0.7) ;; Dired is a really nice package which, as with a lot of emacs, has some dodgy defaults. Here we round off some of the sharp edges to make it more enjoyable to use. -(use-package dired - :custom - ;; By default, dired permanently deletes files. But i have quite a bit of storage and also make bad decisions regularly, so it seems fitting to make use of the wonderful invention that is the trash. People who have used systems from the last forty years or so will likely be familiar with this innovation. - (delete-by-moving-to-trash t) - ;; It's not fun to be asked every time whether we want to delete a directory recursively. It's an understandable default for safety reasons, but because we are not deleting permanently but rather just moving to the trash, it's not such a concern. - (dired-recursive-deletes 'always) - ;; Recursive copying isn't even destructive, so i definitely don't want to be asked about that. - (dired-recursive-copies 'always) - ;; After we delete some files or directories, it makes sense to get rid of any buffers which are looking at those files or directories. - (dired-clean-up-buffers-too nil) - ;; With this set, if we have two dired buffers open next to one another, a rename operation in one will default to the directory shown in the other. In this way, we can pretend we are using some kind of norton commander like file browser instead of slumming it in emacs. - (dired-dwim-target t) - ;; These are some useful ls switches. We have to keep -l. To show dotfiles as well, we use -a. To sort numbers by number order instead of lumping together ones, twos, and so on, we use -v. Because we don't have colour, it's nice to have a clear indicator of what is a file and what is a directory, as well as other different things like symlinks which i never remember. By using -F, a forward slash is appended to every directory. And to get more easily understandable file sizes, we use -h, which will tell us the file size in kilobytes or megabytes rather than a huge number that means nothing to me. I won't explain the meaning of the long flag. - (dired-listing-switches "-alvFh --group-directories-first")) +;; By default, dired permanently deletes files. But i have quite a bit of storage and also make bad decisions regularly, so it seems fitting to make use of the wonderful invention that is the trash. People who have used systems from the last forty years or so will likely be familiar with this innovation. +(setopt delete-by-moving-to-trash t) +;; It's not fun to be asked every time whether we want to delete a directory recursively. It's an understandable default for safety reasons, but because we are not deleting permanently but rather just moving to the trash, it's not such a concern. +(setopt dired-recursive-deletes 'always) +;; Recursive copying isn't even destructive, so i definitely don't want to be asked about that. +(setopt dired-recursive-copies 'always) +;; After we delete some files or directories, it makes sense to get rid of any buffers which are looking at those files or directories. +(setopt dired-clean-up-buffers-too nil) +;; With this set, if we have two dired buffers open next to one another, a rename operation in one will default to the directory shown in the other. In this way, we can pretend we are using some kind of norton commander like file browser instead of slumming it in emacs. +(setopt dired-dwim-target t) +;; These are some useful ls switches. We have to keep -l. To show dotfiles as well, we use -a. To sort numbers by number order instead of lumping together ones, twos, and so on, we use -v. Because we don't have colour, it's nice to have a clear indicator of what is a file and what is a directory, as well as other different things like symlinks which i never remember. By using -F, a forward slash is appended to every directory. And to get more easily understandable file sizes, we use -h, which will tell us the file size in kilobytes or megabytes rather than a huge number that means nothing to me. I won't explain the meaning of the long flag. +(setopt dired-listing-switches "-alvFh --group-directories-first") ;;; Indentation: tabs and whitespace settings @@ -576,18 +540,6 @@ and when JID is not in `jabber-activity-banned'." ;; By default, the point has to be after a paren for it to be highlighted. But often the point will be just inside, in which case it's also helpful for the pair to be highlighted. (setopt show-paren-when-point-inside-paren t) -;; populate and enable the context menu -;; (setopt context-menu-functions '( -;; context-menu-ffap -;; occur-context-menu -;; context-menu-region -;; context-menu-undo -;; goto-address-context-menu) -;; context-menu-mode t) -(use-package mouse - :custom - (context-menu-mode nil)) - (setopt tab-bar-mode t) (setopt tab-bar-format '(tab-bar-format-menu-bar tab-bar-format-align-right @@ -635,36 +587,29 @@ and when JID is not in `jabber-activity-banned'." (add-hook 'focus-out-hook (lambda () (interactive) (save-some-buffers t))) (add-hook 'mouse-leave-buffer-hook (lambda () (interactive) (save-some-buffers t))) -(use-package keyfreq - :ensure t - :custom - (keyfreq-mode t) - (keyfreq-autosave-mode t)) +(use-package keyfreq :ensure t) +(setopt keyfreq-mode t) +(setopt keyfreq-autosave-mode t) ;; C-l goes in order (setopt recenter-positions '(top middle bottom)) ;; Emacs uses choppy scrolling by default. If i scoll with my trackpad, it's nice to have it move tiny amounts at the same time as my fingers, which pixel-scroll-precision-mode allows for. This also has the benefit of making scrolling over images a little bit of a nicer experience. -(setopt - pixel-scroll-precision-mode t - pixel-scroll-precision-use-momentum t) +(setopt pixel-scroll-precision-mode t + pixel-scroll-precision-use-momentum t) -(use-package smartscan - :bind (("M-n" . smartscan-symbol-go-forward) - ("M-p" . smartscan-symbol-go-backward) - ("" . nil) - ("" . smartscan-symbol-go-forward))) +(use-package smartscan) +(global-set-key (kbd "M-n") #'smartscan-symbol-go-forward) +(global-set-key (kbd "M-p") #'smartscan-symbol-go-backward) ;;; sentences (setopt sentence-end-double-space nil) ;;; spellcheck -(setopt - flyspell-mode t - ispell-program-name "aspell" - ispell-dictionary "en_GB" - ispell-extra-args '("--sug-mode=ultra")) - +(setopt flyspell-mode t + ispell-program-name "aspell" + ispell-dictionary "en_GB" + ispell-extra-args '("--sug-mode=ultra")) ;; If i write a script, i will always run chmod +x after saving it. This command means i don't have to do that. (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) @@ -681,22 +626,20 @@ and when JID is not in `jabber-activity-banned'." (setopt history-length 250 kill-ring-max 25) -(use-package savehist - :custom - (savehist-file "~/.config/emacs/savehist") - (savehist-additional-variables - '(kill-ring - command-history - set-variable-value-history - custom-variable-history - query-replace-history - read-expression-history - minibuffer-history - read-char-history - face-name-history - bookmark-history - file-name-history)) - (savehist-mode t)) +(setopt savehist-file "~/.config/emacs/savehist") +(setopt savehist-additional-variables + '(kill-ring + command-history + set-variable-value-history + custom-variable-history + query-replace-history + read-expression-history + minibuffer-history + read-char-history + face-name-history + bookmark-history + file-name-history)) +(setopt savehist-mode t) (use-package frame :custom @@ -705,44 +648,38 @@ and when JID is not in `jabber-activity-banned'." (window-divider-default-bottom-width 1) (window-divider-default-places t)) -(use-package emacs - :init - ;; Add prompt indicator to `completing-read-multiple'. - ;; We display [CRM], e.g., [CRM,] if the separator is a comma. - (defun crm-indicator (args) - (cons (format "[CRM%s] %s" - (replace-regexp-in-string - "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" - crm-separator) - (car args)) - (cdr args))) - (advice-add #'completing-read-multiple :filter-args #'crm-indicator) - - ;; Do not allow the cursor in the minibuffer prompt - (setq minibuffer-prompt-properties - '(read-only t cursor-intangible t face minibuffer-prompt)) - (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) - - :custom - (display-battery-mode t) - (display-time-mode t) - (display-time-default-load-average nil) - (display-time-24hr-format t) - - ;; Support opening new minibuffers from inside existing minibuffers. - (enable-recursive-minibuffers t) - (debug-on-error t) - - ;; Hide commands in M-x which do not work in the current mode. - (read-extended-command-predicate 'command-completion-default-include-p)) +;; Add prompt indicator to `completing-read-multiple'. +;; We display [CRM], e.g., [CRM,] if the separator is a comma. +(defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) +(advice-add #'completing-read-multiple :filter-args #'crm-indicator) + +;; Do not allow the cursor in the minibuffer prompt +(setopt minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) +(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) +(setopt display-battery-mode t) +(setopt display-time-mode t) +(setopt display-time-default-load-average nil) +(setopt display-time-24hr-format t) + +;; Support opening new minibuffers from inside existing minibuffers. +(setopt enable-recursive-minibuffers t) +(setopt debug-on-error t) + +;; Hide commands in M-x which do not work in the current mode. +(setopt read-extended-command-predicate 'command-completion-default-include-p) (setopt recentf-max-menu-items 25 recentf-save-file "~/.config/emacs/recentf" recentf-mode 1 bookmark-default-file "~/.config/emacs/bookmarks") - - ;;; miscellaneous (setopt save-place-mode 1) -- cgit 1.4.1-2-gfad0