diff options
author | noa@gaiwan.org | 2024-06-13 22:15:25 +0000 |
---|---|---|
committer | noa@gaiwan.org | 2024-06-13 22:15:25 +0000 |
commit | 9ab0ba864dd0050b009dbf53c4fafb3a5864509b (patch) | |
tree | f772cac70ab711755507320dcb3656bedd5506fd | |
parent | eeb30ae2d0d48cafc8829e02ac4755e078628e37 (diff) |
Replace olivetti-mode with visual-fill-column
-rw-r--r-- | emacs/init.el | 363 |
1 files changed, 156 insertions, 207 deletions
diff --git a/emacs/init.el b/emacs/init.el index be53300..d03a1e2 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -430,90 +430,87 @@ and when JID is not in `jabber-activity-banned'." ) (setq org-publish-project-alist `( - ("website" - :components ("website-pages" "website-assets")) - ("website-pages" - :publishing-function org-html-publish-to-html - :base-directory "/home/noa/data/share" - :publishing-directory "/home/noa/projects/org-website" - :base-extension "org" - - :section-numbers nil - :with-toc nil - :with-drawers t - :with-sub-superscript t - :html-link-home "/" - :html-head "<link rel=\"icon\" href=\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>𰻝</text></svg>\">" - :html-head-include-default-style nil - :html-head-include-scripts nil - :html-doctype "html5" - ;; :html-validation-link nil - - :html-preamble "" - :html-postamble ,noa/website-footer - - :html-home/up-format "" - :html-link-up "" - - :html-html5-fancy t - :html-indent t - - :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"love.css\" /> + ("website" + :components ("website-pages" "website-assets")) + ("website-pages" + :publishing-function org-html-publish-to-html + :base-directory "/home/noa/data/share" + :publishing-directory "/home/noa/projects/org-website" + :base-extension "org" + + :section-numbers nil + :with-toc nil + :with-drawers t + :with-sub-superscript t + :html-link-home "/" + :html-head "<link rel=\"icon\" href=\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>𰻝</text></svg>\">" + :html-head-include-default-style nil + :html-head-include-scripts nil + :html-doctype "html5" + ;; :html-validation-link nil + + :html-preamble "" + :html-postamble ,noa/website-footer + + :html-home/up-format "" + :html-link-up "" + + :html-html5-fancy t + :html-indent t + + :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"love.css\" /> <meta name=\"color-scheme\" content=\"light dark\">" - :html-divs ( - (preamble "header" "") - (content "main" "") - (postamble "footer" "")) - - :auto-sitemap t - :sitemap-filename "/home/noa/projects/org-website/index.org" - :sitemap-title "noa.pub" - :sitemap-style list - ;; :sitemap-format-entry - :sitemap-function noa/website-sitemap - :sitemap-sort-folders ignore - :sitemap-sort-files anti-chronologically - :sitemap-ignore-case t - ) - ("website-assets" - :publishing-function org-publish-attachment - :base-directory "/home/noa/data/share" - :publishing-directory "/home/noa/projects/org-website" - :base-extension "css\\|js\\|png|\\jpg" - :recursive t))) - -;; TODO: replace with visual-fill-column -;; https://codeberg.org/joostkremers/visual-fill-column -(use-package olivetti - :ensure t - :hook ( - (text-mode . olivetti-mode) - (eww-after-render . olivetti-mode) - (nov-post-html-render . olivetti-mode) - (mu4e-view-mode . olivetti-mode) - ) -) - -(use-package ffap - :custom - (ffap-file-name-with-spaces t) - :bind ( - ([remap find-file] . find-file-at-point) - ([remap dired] . dired-at-point) - ) -) + :html-divs ( + (preamble "header" "") + (content "main" "") + (postamble "footer" "")) + + :auto-sitemap t + :sitemap-filename "/home/noa/projects/org-website/index.org" + :sitemap-title "noa.pub" + :sitemap-style list + ;; :sitemap-format-entry + :sitemap-function noa/website-sitemap + :sitemap-sort-folders ignore + :sitemap-sort-files anti-chronologically + :sitemap-ignore-case t + ) + ("website-assets" + :publishing-function org-publish-attachment + :base-directory "/home/noa/data/share" + :publishing-directory "/home/noa/projects/org-website" + :base-extension "css\\|js\\|png|\\jpg" + :recursive t))) + +;;; Make wide windows narrow with visual-fill-column +(use-package visual-fill-column :ensure t) +(setopt visual-fill-column-enable-sensible-window-split t) +(setopt visual-fill-column-center-text t) +(add-hook 'text-mode-hook #'visual-line-fill-column-mode) +(advice-add 'text-scale-adjust :after #'visual-fill-column-adjust) + +;; This works... fine. However it's adapting the prefix, it doesn't indent nicely with proportional fonts, but you can't win them all. +(use-package adaptive-wrap :ensure t) +(add-hook 'visual-fill-column-mode-hook #'adaptive-wrap-prefix-mode) + + +(setopt ffap-file-name-with-spaces t) +(global-set-key [remap find-file] #'find-file-at-point) +(global-set-key [remap dired] #'dired-at-point) (setopt browse-url-browser-function 'eww-browse-url browse-url-secondary-browser-function 'browse-url-default-browser url-cookie-trusted-urls '() url-cookie-untrusted-urls '(".*") - shr-cookie-policy nil - ;; I don't want web pages to be able to specify their own colours, because i like the colours i already have set. - shr-use-colors nil - shr-max-width nil - ;; We can set what the maximum size of an image in a window should be. This is a fraction of the total window width or height, and if the image would be bigger than this, it'll be resized to fit. It's useful to have it smaller because emacs still sort of chokes on scrolling when there are large images in a buffer. This is the default value of this option. - shr-max-image-proportion 0.9 + shr-cookie-policy nil) + +;; I don't want web pages to be able to specify their own colours, because i like the colours i already have set. +(setopt shr-use-colors nil) +(setopt shr-max-width nil) + +;; We can set what the maximum size of an image in a window should be. This is a fraction of the total window width or height, and if the image would be bigger than this, it'll be resized to fit. It's useful to have it smaller because emacs still sort of chokes on scrolling when there are large images in a buffer. This is the default value of this option. +(setopt shr-max-image-proportion 0.9 shr-discard-aria-hidden t ;; The default name for the eww buffer is *eww*. This is unhelpful because it makes having more than one eww buffer open a bit of a chore to navigate. We can set it to 'url, 'title, or a function. I set it to 'title because marginalia already shows me the url. However, this means that i can't search for a url name when switching buffers. See the help for this variable for an example of a function which gives the page title and the url. eww-auto-rename-buffer 'title) @@ -830,6 +827,7 @@ and when JID is not in `jabber-activity-banned'." (setenv "PAGER" "cat") (setenv "TERM" "dumb") +(setenv "NO_COLOR") (setenv "GPG_AGENT_INFO" nil) ;; The former means that when given a list of choices, we can use single character abbreviations to answer. The latter is a fancy way of defaliasing yes-or-no-p to y-or-n-p. @@ -840,127 +838,96 @@ and when JID is not in `jabber-activity-banned'." (setopt custom-file (make-temp-file "custom")) (setq inhibit-startup-echo-area-message "noa") ;; #userfreedom -(use-package simple - :delight visual-line-mode - :custom - (global-visual-line-mode t)) - (setopt - kill-whole-line t - uniquify-after-kill-buffer-p t - uniquify-buffer-name-style 'forward - uniquify-ignore-buffers-re "^\\*" - uniquify-separator "/") + kill-whole-line t + uniquify-after-kill-buffer-p t + uniquify-buffer-name-style 'forward + uniquify-ignore-buffers-re "^\\*" + uniquify-separator "/") (setopt - save-interprogram-paste-before-kill t - mouse-yank-at-point t - require-final-newline t - visible-bell t - load-prefer-newer t - ediff-window-setup-function 'ediff-setup-windows-plain) + save-interprogram-paste-before-kill t + mouse-yank-at-point t + require-final-newline t + visible-bell t + load-prefer-newer t + ediff-window-setup-function 'ediff-setup-windows-plain) -(use-package server - :disabled - :config - (unless (server-running-p) (server-start))) +;; (unless (server-running-p) (server-start))) (setopt help-at-pt-display-when-idle t) -(use-package ctrlf - :ensure t - :bind ( - ([remap isearch-forward] . ctrlf-forward-default) - ([remap isearch-backward] . ctrlf-backward-default) - ([remap isearch-forward-regexp] . ctrlf-forward-alternate) - ([remap isearch-backward-regexp] . ctrlf-backward-alternate) - ([remap isearch-forward-symbol] . ctrlf-forward-symbol) - ([remap isearch-forward-symbol-at-point] . ctrlf-forward-symbol-at-point) - ) - :custom - (ctrlf-go-to-end-of-match nil "It makes more sense to go to the start of the match, because i start searching where i want to be.") -) - -(global-set-key (kbd "M-o") 'other-window) +;;; Search in buffer +;; Isearch is good, but it has some rough edges. The easiest way forward was just to use ctrlf, which fixes most of them. +(use-package ctrlf :ensure t) +(global-set-key [remap isearch-forward] #'ctrlf-forward-default) +(global-set-key [remap isearch-backward] #'ctrlf-backward-default) +(global-set-key [remap isearch-forward-regexp] #'ctrlf-forward-alternate) +(global-set-key [remap isearch-backward-regexp] #'ctrlf-backward-alternate) + +;; It makes more sense to go to the start of the match, because i start searching where i want to be. +(setopt ctrlf-go-to-end-of-match nil ) + +(global-set-key (kbd "M-o") 'other-window) (global-set-key (kbd "C-x k") 'kill-this-buffer) ;; undo C-/ ;; redo C-S-/ (setopt undo-no-redo t) -;; mu4e -(use-package mu4e - :custom - (mu4e-headers-skip-duplicates t) - (mu4e-view-show-images t) - (mu4e-view-show-addresses t) - (mu4e-compose-format-flowed nil) - (mu4e-change-filenames-when-moving t) - (mu4e-use-fancy-chars nil) - (mu4e-confirm-quit nil) - (mu4e-headers-leave-behavior 'apply) - (mu4e-headers-precise-alignment t) - (mu4e-headers-fields '( - ;; (:human-date . 12) - (:flags . 6) - (:from . 32) - (:subject))) - (mu4e-search-threads nil) - (mu4e-hide-index-messages t) - (mu4e-get-mail-command "mbsync -c ~/.config/mbsyncrc fastmail") - (mu4e-maildir "~/mail") - (mu4e-drafts-folder "/Drafts") - (mu4e-sent-folder "/Sent") - (mu4e-refile-folder "/Archive") - (mu4e-trash-folder "/Trash") - (mu4e-bookmarks '( - (:name "Inbox" :query "maildir:/Inbox" :key ?i) - (:name "Feeds" :query "maildir:/Feeds" :key ?f) - (:name "Paper trail" :query "\"maildir:/Paper trail\"" :key ?p))) - :bind ( - :map mu4e-headers-mode-map - ("d" . my-move-to-trash) - :map mu4e-view-mode-map - ("d" . my-move-to-trash) - ) - :init - (fset 'my-move-to-trash "mTrash") ;; function to move mails to trash - :config - (setq - mu4e-headers-thread-connection-prefix '("│ " . "│ ") - mu4e-headers-thread-last-child-prefix '("└ " . "└ ") - mu4e-headers-thread-blank-prefix '(" " . " ") - mu4e-headers-thread-root-prefix '("□ " . "□ ") - mu4e-headers-thread-child-prefix '("│ " . "│ ") - mu4e-headers-thread-orphan-prefix '("♢ " . "♢ ") - mu4e-headers-thread-duplicate-prefix '("≡ " . "≡ ") - mu4e-headers-thread-first-child-prefix '("⚬ " . "⚬ ") - mu4e-headers-thread-single-orphan-prefix '("♢ " . "♢ ") - ) - ) - -(setopt message-fill-column nil - ;; (message-signature-file) - message-signature "~noa (https://noa.pub) +;;; Email: mu4e +(setopt mu4e-headers-skip-duplicates t) +(setopt mu4e-view-show-images t) +(setopt mu4e-view-show-addresses t) + +;; In theory i like format flowed, but what i like even more is just not hard wrapping messages and dealing with hacks to get around that to begin with. If software supported soft wrapping at an arbitrary column, the world would be a better place. +(setopt mu4e-compose-format-flowed nil) +(setopt mu4e-change-filenames-when-moving t) +(setopt mu4e-use-fancy-chars nil) +(setopt mu4e-confirm-quit nil) +(setopt mu4e-headers-leave-behavior 'apply) +(setopt mu4e-headers-precise-alignment t) +(setopt mu4e-headers-fields '((:flags . 6) + (:from . 32) + (:subject))) +(setopt mu4e-search-threads nil) +(setopt mu4e-hide-index-messages t) +(setopt mu4e-get-mail-command "mbsync -c ~/.config/mbsyncrc fastmail") +(setopt mu4e-maildir "~/mail") +(setopt mu4e-drafts-folder "/Drafts") +(setopt mu4e-sent-folder "/Sent") +(setopt mu4e-refile-folder "/Archive") +(setopt mu4e-trash-folder "/Trash") +(setopt mu4e-bookmarks '((:name "Inbox" :query "maildir:/Inbox" :key ?i) + (:name "Feeds" :query "maildir:/Feeds" :key ?f) + (:name "Paper trail" :query "\"maildir:/Paper trail\"" :key ?p))) + +;; function to move mails to trash +(with-eval-after-load 'mu4e + (bind-key (kbd "d") #'noa/move-to-trash 'mu4e-headers-mode-map) + (bind-key (kbd "d") #'noa/move-to-trash 'mu4e-view-mode-map) + (fset 'noa/move-to-trash "mTrash")) + +;; The first string is for when fancy characters are disabled, and the second is for when they are enabled. But i set them all manually because some of the other characters are ugly in fancy mode, but i like my unicode thread icons. +(setq mu4e-headers-thread-connection-prefix '("│ " . "│ ") + mu4e-headers-thread-last-child-prefix '("└ " . "└ ") + mu4e-headers-thread-blank-prefix '(" " . " ") + mu4e-headers-thread-root-prefix '("□ " . "□ ") + mu4e-headers-thread-child-prefix '("│ " . "│ ") + mu4e-headers-thread-orphan-prefix '("♢ " . "♢ ") + mu4e-headers-thread-duplicate-prefix '("≡ " . "≡ ") + mu4e-headers-thread-first-child-prefix '("⚬ " . "⚬ ") + mu4e-headers-thread-single-orphan-prefix '("♢ " . "♢ ")) + +;; Setting this to nil stops auto-fill from being automatically enabled in message buffers. +(setopt message-fill-column nil) + +;; (message-signature-file) +(setopt message-signature "~noa (https://noa.pub) • I try to reply to formal emails in three sentences or fewer; excuse my brevity. • I queue replies and batch send them at intervals; excuse my untimeliness.") -(use-package button - :custom-face - ;;(button ((t (:underline t :foreground unspecified)))) - ) - -(use-package faces - :custom-face - ;; (link ((t (:underline t :foreground unspecified)))) - ;; (fringe ((t (:background unspecified)))) - ;; (mode-line ((t (:background unspecified :box 2)))) - ;; (mode-line-active ((t (:inverse-video t)))) - ;; (mode-line-inactive ((t (:background unspecified :box 2 :weight unspecified)))) - ;; (help-key-binding ((t (:inherit default :background unspecified :foreground unspecified :box 1)))) - ) - (global-set-key (kbd "M-z") 'zap-up-to-char) (use-package markdown-mode @@ -976,27 +943,9 @@ and when JID is not in `jabber-activity-banned'." (valign-max-table-size 0)) (use-package eat - :ensure t - :hook ( - (eshell-load . eat-eshell-mode) - (eshell-load . eat-eshell-visual-command-mode) - ) -) - - - -(use-package which-key - :disabled t - :ensure t - :custom - (which-key-popup-type 'side-window) - (which-key-side-window-location 'bottom) - (which-key-side-window-max-height 12) - (which-key-persistent-popup nil) - (which-key-show-prefix 'echo) - (which-key-idle-delay 0) - (which-key-mode t) -) + :ensure t + :hook ((eshell-load . eat-eshell-mode) + (eshell-load . eat-eshell-visual-command-mode))) (use-package fixed-pitch :custom @@ -1014,17 +963,17 @@ and when JID is not in `jabber-activity-banned'." ;; My current favourite font is sn pro, which feels like comic sans for grown ups. It's friendly but consistent and well thought out. However, it's also a proportional font, which obviously is the right way to do things, but emacs is very old and comes from a time before the innovation of legibility. As a result, there are some things that require a monospaced font, so i set one here. I chose go mono for two reasons: the first is because i think it looks really nice; the second is because it has serifs and is very visually distinct from sn pro, so i can notice and shame those buffers which require a fixed width font to operate properly. (custom-set-faces - '(fixed-pitch ((t (:family "Go Mono" :height 110)))) - '(variable-pitch ((t (:family "SN Pro" :height 110)))) -) + '(fixed-pitch ((t (:family "Go Mono" :height 110)))) + '(variable-pitch ((t (:family "SN Pro" :height 110))))) + ;; For some frustrating reason, emacs does not respect fontconfig font settings. What this means in practice is that emacs by default draws cjk characters with the korean variant. Luckily emacs has its own obscure and poorly documented way of doing things, so i can iterate over the relevant charsets and set the font specifically for those characters. (dolist (charset '(han cjk-misc)) (set-fontset-font t charset (font-spec :family "Noto Sans CJK SC"))) ;; Describe a key based on a string like "C-SPC" (defun describe-key-shortcut (shortcut) - (interactive "MShortcut: ") - (describe-key (kbd shortcut))) + (interactive "MShortcut: ") + (describe-key (kbd shortcut))) ;; Update the calendar. We want weeks to start on a monday, the first day of the week. Holidays should be highlighted, and the date format should put the year first. (setopt calendar-week-start-day 1 |