From 9508fd568804b5980a6fc721a2fb0167e52e7474 Mon Sep 17 00:00:00 2001 From: noa@gaiwan.org Date: Mon, 15 Jul 2024 00:13:32 +0000 Subject: Reorganise outline and add more headings --- config.org | 444 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 232 insertions(+), 212 deletions(-) diff --git a/config.org b/config.org index fbf0701..cc0a116 100644 --- a/config.org +++ b/config.org @@ -133,90 +133,6 @@ It is often useful to be able to run a command while i am already in the process (setopt minibuffer-depth-indicate-mode t) #+end_src -* Minibuffer candidate completion -Vertico is a package for a nice minibuffer completion experience. It displays a vertical list of candidates. It integrates well with the emacs ecosystem and lets me use other packages that also play nicely. - -#+begin_src elisp - (package-ensure 'vertico) - (setopt vertico-mode t) -#+end_src - -We want vertico to take up a maximum of 12 lines on the display. My screen is quite small, so that's fine, but if i had a bigger screen, i might want to look into setting a percentage or increasing this. - -#+begin_src elisp - (setopt vertico-count 12) -#+end_src - -By default, vertico uses a font-face trick to put a horizontal line across group titles. It looks quite nice, but doesn't really conform to my design sensibilities, so here i redefine the group format to not have this. Because we no longer have the line, we also align the group name to the left edge. - -#+begin_src elisp -(setopt vertico-group-format #("%s " 0 3 (face vertico-group-title))) -#+end_src - -We also want to be able to jump to the bottom of the list by moving up from the top of the list, and the opposite. I've rarely made use of this functionality and i don't know if it's actually a best practice from an interaction perspective, but i'm going to keep it on until it causes an issue for me. - -#+begin_src elisp -(setopt vertico-cycle t) -#+end_src - -And of course, i want to be able to interact with vertico with the mouse. - -#+begin_src elisp - (with-eval-after-load 'vertico - (setopt vertico-mouse-mode t)) -#+end_src - -When completing a filename, i want to be able to easily delete directories in one fell swoop, instead of character by character or word by word. Usually C- would be fine, but if directories have a hyphen or space in their name, i have to press multiple times, which is almost never desirable. - -#+begin_src elisp - (with-eval-after-load 'vertico - (bind-key (kbd "RET") #'vertico-directory-enter 'vertico-map) - (bind-key (kbd "") #'vertico-directory-delete-char 'vertico-map) - (bind-key (kbd "") #'vertico-directory-delete-word 'vertico-map)) -#+end_src - -If i type ~/ etc in a find-file prompt, get rid of the preceding directory names for a cleaner look. - -#+begin_src elisp -(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) -#+end_src - -** Better default completion - -Some settings for nicer completion with the default emacs completion buffer. I don't use this, because i use vertico. - -#+begin_src elisp :tangle no - (setopt completion-auto-help 'lazy - completion-auto-select 'second-tab - completion-show-help nil - completions-sort nil - completions-header-format nil) -#+end_src - -* Completion styles -When given a prompt to select from a list of candidates, there are quite a lot of things we can tweak to improve the experience. - -The first thing we do is to ignore case, which in these cases is rarely useful. I find that thinking about the case of a candidate is slower than just typing more to narrow down the options. I don't actually know if these make any difference when i've specified a different completion style. - -#+begin_src elisp -(setopt read-buffer-completion-ignore-case t) -(setopt read-file-name-completion-ignore-case t) -(setopt completion-ignore-case t) -#+end_src - -Next, we want to set orderless and basic as the two completion style. Basic matches candidates with the same text before the point, and the text after the point as a substring. Orderless takes any number of space separated components and displays candidates that much every component in any order. We specify basic first. What this means in practice is that first we will try and complete exactly what i've input, and if that fails, widen the search with orderless to pick up more options. - -#+begin_src elisp - (package-ensure 'orderless) - (setopt completion-styles '(basic orderless)) -#+end_src - -By default, emacs overrides the completion styles for email address, but i'm happy with my configuration above. - -#+begin_src elisp - (setopt completion-category-defaults nil) -#+end_src - * Aesthetic changes ** Colour theme This is my emacs theme. It's a monochrome theme which, unlike most monochrome themes, really does have only two colours. I define a few faces, and set every other face as one of them. There are a few things i want to do with it before i make it properly public: make the colours configurable and able to update on the fly, and in general iron out some of the janky parts. A few things defined it are quite specific to this configuration, like the way i define the borders for the tab and header bars, and there is no mode line configuration because i don't use it. @@ -380,7 +296,7 @@ Adaptive wrap will indent visually wrapped text to match the indent at the start (add-hook 'visual-fill-column-mode-hook #'visual-wrap-prefix-mode) #+end_src -** Interface +** Wider scrollbars I want to make sure that various bits of the interface are hidden. but this isn't an "all gui chrome is useless" rampage. I personally think the scrollbar is useful, i like the visual indication it gives of how far i am through a file. First we can change the style of the scrollbars to be a bit chunkier. This is done in css. Unfortunately i can't figure out how to change the colour of the slider, which apparently can be done with the usual attributes, but this doesn't actually affect the colour shown on my scrollbars. @@ -411,6 +327,8 @@ For some programs, it might be necessary to set ~gsettings set org.gnome.desktop } #+end_src +** No menu and tool bar + At the moment, explicitly disabling the menu bar and tool bar does nothing, because i already set there to be no lines displayed for the tool and menu bars in my early-init.el file. #+begin_src elisp :tangle no @@ -418,18 +336,24 @@ At the moment, explicitly disabling the menu bar and tool bar does nothing, beca tool-bar-mode nil) #+end_src +** Consistent tooltip location + Tooltips are little popups next to the mouse cursor. I think this information is helpful, but i like it to appear in a more consistent position, because i find it frustrating when popups cover parts of the ui that i wanted to see. By disabling tooltip-mode, the contents that would be in a popup is instead shown in the echo area. #+begin_src elisp (setopt tooltip-mode nil) #+end_src +** Show keystrokes + I see no reason not to immediately show which chords in a key sequence i have already pressed. Emacs does, however, and instead of letting me set the value of echo-keystrokes to zero to wait zero seconds to show that information, it repurposes zero as a method of disabling the functionality altogether, and provides no special functionality for setting it to nil that would explain why that's not an acceptable method of disabling a feature. Instead, i have to deal with setting it to nearly zero, and luckily i can't tell the difference. #+begin_src elisp (setopt echo-keystrokes 0.1) #+end_src +** Highlight matching parentheses + A useful feature when programming is to show matching parentheses. Show-paren-mode is a global mode. By default it runs in all buffers except those inheriting from special mode. #+begin_src elisp @@ -448,6 +372,8 @@ By default, the point has to be after a paren for it to be highlighted. But oft (setopt show-paren-when-point-inside-paren t) #+end_src +** Tab bar + #+begin_src elisp (setopt tab-bar-mode t) (setopt tab-bar-format '(tab-bar-format-menu-bar @@ -461,11 +387,20 @@ By default, the point has to be after a paren for it to be highlighted. But oft (setopt tab-bar-select-tab-modifiers '(control)) #+end_src + +#+begin_src elisp :tangle no + (global-set-key (kbd "C-t") 'tab-new) +#+end_src + +** Syntax highlighting + #+begin_src elisp (setopt global-font-lock-mode t) (setopt font-lock-maximum-decoration nil) #+end_src +** Further options + #+begin_src elisp (setopt inhibit-startup-screen t mouse-drag-and-drop-region nil @@ -474,9 +409,7 @@ By default, the point has to be after a paren for it to be highlighted. But oft delete-selection-mode nil) #+end_src -#+begin_src elisp -(global-set-key (kbd "C-t") 'tab-new) -#+end_src +** Mouse selection Shift click to select region with the mouse. This annoyingly rings the bell for an error. It also interferes with my input method switcher, which doesn't notice the mouse click and thinks i've pressed shift with no other keys. @@ -576,7 +509,7 @@ Finally, have a binding to jump to a buffer in which there's been some new activ (keymap-global-set "C-c C-j" #'jabber-activity-switch-to) #+end_src -* Nov.el +* Reading epubs #+begin_src elisp (package-ensure 'nov) (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)) @@ -857,7 +790,7 @@ Almost everywhere else, the ~highlight~ face is used for interactive text on mou I mentioned that i thought this wasn't the best default behaviour [[https://github.com/minad/jinx/discussions/184][in the jinx repository]], but Daniel seems happy with it. I appreciate that he's made it so easy to change the behaviour to something i prefer. -* My website +* Publishing my website I generate my website using org mode. I use the built in ox-publish subsystem for convenience. However, it isn't all that convenient, as it doesn't actually work very well at the moment. #+begin_src elisp @@ -935,67 +868,6 @@ We also need to install a newer version of htmlize so that we can properly conve (package-ensure 'htmlize) #+end_src -* Completing-read everywhere with consult -Consult is a package to provide navigation commands that take advantage of completing-read. I set up a nice completing-read environment earlier with vertico. There are a lot of commands built in to consult, and it's possible to define more. But i use it very simply. - -#+begin_src elisp - (package-ensure 'consult) - (package-activate 'consult) -#+end_src - -Consult buffer can be used instead of the default buffer menu. It lists recently used files and bookmarks as well as open buffers. - -#+begin_src elisp - (autoload #'consult-buffer "consult" nil t) - (global-set-key [remap switch-to-buffer] #'consult-buffer) -#+end_src - -These are some other almost default functions but with extra interactivity. - -#+begin_src elisp - (global-set-key [remap yank-pop] #'consult-yank-pop) - (global-set-key [remap goto-line] #'consult-goto-line) - (global-set-key [remap imenu] #'consult-imenu) - (with-eval-after-load 'org - (bind-key [remap imenu] #'consult-org-heading #'org-mode-map)) -#+end_src - -#+begin_src elisp - (global-set-key [remap info] #'consult-info) -#+end_src - -* Annotations for completing-read -Marginalia provides us with annotations for candidates in completing read functions. This is things like docstrings for functions, file permissions in find-file, and so on. It's a small quality of life improvement. - -#+begin_src elisp - (package-ensure 'marginalia) - (setopt marginalia-mode t) -#+end_src - -We want to always show the relative age of a file. By default, files which haven't been modified for more than two weeks will display an absolute date. - -#+begin_src elisp -(setopt marginalia-max-relative-age most-positive-fixnum) -#+end_src - -My keyboard has a tab key and an i key. For legacy reasons, by default emacs converts C-i to mean the same thing as the tab key, but i don't really want that. The tab key is called and it gets translated to TAB. C-i is TAB, but i'd rather it by C-i. That's what this decode line does. - -#+begin_src elisp -(define-key input-decode-map [?\C-i] [C-i]) -#+end_src - -Now that tab and C-i are properly distinguished, i can bind C-i to completion at point. - -#+begin_src elisp -(global-set-key (kbd "") 'completion-at-point) -#+end_src - -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. - -#+begin_src elisp -(setopt completion-in-region-function 'consult-completion-in-region) -#+end_src - * Getting help Emacs is great because of its great built in help system! @@ -1032,7 +904,7 @@ Often, i will look at the documentation for a variable and immediately want to p (setopt help-enable-variable-value-editing t) #+end_src -* Web browsing in emacs +* Web browsing I hear it's now possible to run a full fat browser inside emacs. But this is surely quite heavyweight, and doesn't get to take advantage of things like ublock origin. When it comes to alternative browsers, it's always the same story; i like the concept, but most websites are a horrific experience without a good ad blocker. Instead, i use eww, a browser more closely aligned with browsers for the terminal. Despite the name, eww is a delight to use for text-heavy websites. If a website doesn't render well in it, because it uses fancy layout tricks or lots of javascript, we can press ~&~ to open the url in firefox. @@ -1102,7 +974,7 @@ Use a bar cursor and blink it and don't stop blinking it. i don't know how i fe blink-cursor-interval 0.7) #+end_src -* Dired +* File management 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. 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. @@ -1155,6 +1027,38 @@ I find it useful to see the recursive sizes of directories. This can be a littl (add-hook 'dired-mode-hook #'dired-du-mode) #+end_src +** Version control +I don't use magit. I tried it once, but my use of version control is very limited to just making some changes and then committing them. I don't work in programming and my projects are simple. + +** Tramp + +Some tramp settings. + +#+begin_src elisp + (setopt remote-file-name-inhibit-locks t) + (setopt tramp-inline-compress-start-size 1000) + (setopt tramp-verbose 3) + ;; (add-to-list 'tramp-remote-path 'tramp-own-remote-path) +#+end_src + +The version control system will try each of these methods in order. Because almost everything source controlled i do uses git, i put it first in the list. But at the moment, because i don't think i actually use any of the other methods, i remove the rest of them from the list. + +#+begin_src elisp + (setopt vc-handled-backends '(Git)) + ;; (setopt vc-handled-backends '(Git RCS CVS SVN SCCS SRC Bzr Hg)) +#+end_src + + It seems that tramp can also be made faster with these .ssh/config settings. + +#+begin_src conf-unix :tangle no + Host * + ControlMaster auto + ControlPath ~/.ssh/master-%h:%p + ControlPersist 10m + ForwardAgent yes + ServerAliveInterval 60 +#+end_src + * Behaviour ** Switching buffers @@ -1460,7 +1364,152 @@ By default, clicking on a character will always put the point in front of that c (setopt mouse-prefer-closest-glyph t) #+end_src -* Writing code +** Completing-read everywhere with consult +Consult is a package to provide navigation commands that take advantage of completing-read. I set up a nice completing-read environment earlier with vertico. There are a lot of commands built in to consult, and it's possible to define more. But i use it very simply. + +#+begin_src elisp + (package-ensure 'consult) + (package-activate 'consult) +#+end_src + +Consult buffer can be used instead of the default buffer menu. It lists recently used files and bookmarks as well as open buffers. + +#+begin_src elisp + (autoload #'consult-buffer "consult" nil t) + (global-set-key [remap switch-to-buffer] #'consult-buffer) +#+end_src + +These are some other almost default functions but with extra interactivity. + +#+begin_src elisp + (global-set-key [remap yank-pop] #'consult-yank-pop) + (global-set-key [remap goto-line] #'consult-goto-line) + (global-set-key [remap imenu] #'consult-imenu) + (with-eval-after-load 'org + (bind-key [remap imenu] #'consult-org-heading #'org-mode-map)) +#+end_src + +#+begin_src elisp + (global-set-key [remap info] #'consult-info) +#+end_src + +** Annotations for completing-read +Marginalia provides us with annotations for candidates in completing read functions. This is things like docstrings for functions, file permissions in find-file, and so on. It's a small quality of life improvement. + +#+begin_src elisp + (package-ensure 'marginalia) + (setopt marginalia-mode t) +#+end_src + +We want to always show the relative age of a file. By default, files which haven't been modified for more than two weeks will display an absolute date. + +#+begin_src elisp +(setopt marginalia-max-relative-age most-positive-fixnum) +#+end_src + +My keyboard has a tab key and an i key. For legacy reasons, by default emacs converts C-i to mean the same thing as the tab key, but i don't really want that. The tab key is called and it gets translated to TAB. C-i is TAB, but i'd rather it by C-i. That's what this decode line does. + +#+begin_src elisp +(define-key input-decode-map [?\C-i] [C-i]) +#+end_src + +Now that tab and C-i are properly distinguished, i can bind C-i to completion at point. + +#+begin_src elisp +(global-set-key (kbd "") 'completion-at-point) +#+end_src + +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. + +#+begin_src elisp +(setopt completion-in-region-function 'consult-completion-in-region) +#+end_src + +** Minibuffer candidate completion +Vertico is a package for a nice minibuffer completion experience. It displays a vertical list of candidates. It integrates well with the emacs ecosystem and lets me use other packages that also play nicely. + +#+begin_src elisp + (package-ensure 'vertico) + (setopt vertico-mode t) +#+end_src + +We want vertico to take up a maximum of 12 lines on the display. My screen is quite small, so that's fine, but if i had a bigger screen, i might want to look into setting a percentage or increasing this. + +#+begin_src elisp + (setopt vertico-count 12) +#+end_src + +By default, vertico uses a font-face trick to put a horizontal line across group titles. It looks quite nice, but doesn't really conform to my design sensibilities, so here i redefine the group format to not have this. Because we no longer have the line, we also align the group name to the left edge. + +#+begin_src elisp +(setopt vertico-group-format #("%s " 0 3 (face vertico-group-title))) +#+end_src + +We also want to be able to jump to the bottom of the list by moving up from the top of the list, and the opposite. I've rarely made use of this functionality and i don't know if it's actually a best practice from an interaction perspective, but i'm going to keep it on until it causes an issue for me. + +#+begin_src elisp +(setopt vertico-cycle t) +#+end_src + +And of course, i want to be able to interact with vertico with the mouse. + +#+begin_src elisp + (with-eval-after-load 'vertico + (setopt vertico-mouse-mode t)) +#+end_src + +When completing a filename, i want to be able to easily delete directories in one fell swoop, instead of character by character or word by word. Usually C- would be fine, but if directories have a hyphen or space in their name, i have to press multiple times, which is almost never desirable. + +#+begin_src elisp + (with-eval-after-load 'vertico + (bind-key (kbd "RET") #'vertico-directory-enter 'vertico-map) + (bind-key (kbd "") #'vertico-directory-delete-char 'vertico-map) + (bind-key (kbd "") #'vertico-directory-delete-word 'vertico-map)) +#+end_src + +If i type ~/ etc in a find-file prompt, get rid of the preceding directory names for a cleaner look. + +#+begin_src elisp +(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) +#+end_src + +** Better default completion + +Some settings for nicer completion with the default emacs completion buffer. I don't use this, because i use vertico. + +#+begin_src elisp :tangle no + (setopt completion-auto-help 'lazy + completion-auto-select 'second-tab + completion-show-help nil + completions-sort nil + completions-header-format nil) +#+end_src + +** Completion styles +When given a prompt to select from a list of candidates, there are quite a lot of things we can tweak to improve the experience. + +The first thing we do is to ignore case, which in these cases is rarely useful. I find that thinking about the case of a candidate is slower than just typing more to narrow down the options. I don't actually know if these make any difference when i've specified a different completion style. + +#+begin_src elisp +(setopt read-buffer-completion-ignore-case t) +(setopt read-file-name-completion-ignore-case t) +(setopt completion-ignore-case t) +#+end_src + +Next, we want to set orderless and basic as the two completion style. Basic matches candidates with the same text before the point, and the text after the point as a substring. Orderless takes any number of space separated components and displays candidates that much every component in any order. We specify basic first. What this means in practice is that first we will try and complete exactly what i've input, and if that fails, widen the search with orderless to pick up more options. + +#+begin_src elisp + (package-ensure 'orderless) + (setopt completion-styles '(basic orderless)) +#+end_src + +By default, emacs overrides the completion styles for email address, but i'm happy with my configuration above. + +#+begin_src elisp + (setopt completion-category-defaults nil) +#+end_src + +* Programming ** Indentation: tabs and whitespace settings In general, my rules for inserting tabs are that the tab key should insert tabs. I personally prefer tabs to spaces, because tabs work reasonably well whatever font or tab width one chooses to set, whereas spaces are the same width for everyone, except when someone uses a proportional font in which case they are narrower than expected. Furthermore, people tend to use spaces for alignment, which looks bad when you can't rely on every character being the same width. @@ -1548,35 +1597,6 @@ We are on a unix system, so it makes sense to end files in the unix system way. frame-resize-pixelwise t) #+end_src elisp -* Tramp - -Some tramp settings. - -#+begin_src elisp - (setopt remote-file-name-inhibit-locks t) - (setopt tramp-inline-compress-start-size 1000) - (setopt tramp-verbose 3) - ;; (add-to-list 'tramp-remote-path 'tramp-own-remote-path) -#+end_src - -The version control system will try each of these methods in order. Because almost everything source controlled i do uses git, i put it first in the list. But at the moment, because i don't think i actually use any of the other methods, i remove the rest of them from the list. - -#+begin_src elisp - (setopt vc-handled-backends '(Git)) - ;; (setopt vc-handled-backends '(Git RCS CVS SVN SCCS SRC Bzr Hg)) -#+end_src - - It seems that tramp can also be made faster with these .ssh/config settings. - -#+begin_src conf-unix :tangle no - Host * - ControlMaster auto - ControlPath ~/.ssh/master-%h:%p - ControlPersist 10m - ForwardAgent yes - ServerAliveInterval 60 -#+end_src - * I-ching I don't know why but it seems cool @@ -1715,30 +1735,6 @@ Put a quote in the scratch buffer "\n\n")) #+end_src -* Eshell -Eshell is a command shell written in elisp. It integrates with emacs in a more consistent manner than the other shells available, although it still has its own quirks. - -In general, i try and avoid using a shell if possible, because i think that bespoke emacs interfaces to different commands tend to have more pleasant interaction methods. But there are still lots of things which are simply easier to do with a shell. - -** Set the eshell banner -This is equivalent to the message of the day present in some shells. I wanted it to print a new quote every time eshell opened, but when i tried that eshell refused to load. Probably some mistake on my end. - -#+begin_src elisp -(defun noa/eshell-banner-message () - (concat (cookie cookie-file) - "\n\n")) -(setopt eshell-banner-message (noa/eshell-banner-message)) -#+end_src - -** Environment variables - -#+begin_src elisp -(setenv "PAGER" "cat") -(setenv "TERM" "dumb") -(setenv "NO_COLOR") -(setenv "GPG_AGENT_INFO" nil) -#+end_src - * Password management I mostly don't use emacs for passage management. Instead i use the wonderful [[https://keepassxc.org/][keepassxc]]. Keepassxc has many great features i make use of, including one time passwords, an ssh agent, and checking if my password appears in leaks. @@ -1751,7 +1747,9 @@ And so i'm back with keepassxc. Luckily keepassxc supports the secret service a Not quite. The keys that auth-source expects don't quite align with the keys that keepassxc has. So any passwords i want emacs to be able to easily deal with have to be moved around a little. Luckily the passwords key itself is just where it should be, but i had to go the advanced options in my keepassxc entry and add things in the :user, :host, and :port slots. I probably won't be updating these very often, so it's not a big deal. But i'm writing it here because otherwise i will forget. #+begin_src elisp - (require 'secrets t nil) + ;; (start-process-shell-command "keepassxc" nil "keepassxc") + + (require 'secrets) ;; (secrets-open-session) (setopt auth-sources '("secrets:Passwords")) (auth-source-forget-all-cached) @@ -1767,9 +1765,6 @@ Not quite. The keys that auth-source expects don't quite align with the keys th (global-set-key (kbd "C-=") #'calc) #+end_src -* Version control -I don't use magit. I tried it once, but my use of version control is very limited to just making some changes and then committing them. I don't work in programming and my projects are simple. - * Email I like to have my email offline. Of course my preference is also to have it inside of emacs for consistency with everything else. I use some external tools to fetch and send the mail. @@ -1888,7 +1883,32 @@ It's nice to have a message signature. I want the signature to be loaded from a account default: noa.pub #+end_src -* Network management +* System administration +** Eshell +Eshell is a command shell written in elisp. It integrates with emacs in a more consistent manner than the other shells available, although it still has its own quirks. + +In general, i try and avoid using a shell if possible, because i think that bespoke emacs interfaces to different commands tend to have more pleasant interaction methods. But there are still lots of things which are simply easier to do with a shell. + +*** Set the eshell banner +This is equivalent to the message of the day present in some shells. I wanted it to print a new quote every time eshell opened, but when i tried that eshell refused to load. Probably some mistake on my end. + +#+begin_src elisp +(defun noa/eshell-banner-message () + (concat (cookie cookie-file) + "\n\n")) +(setopt eshell-banner-message (noa/eshell-banner-message)) +#+end_src + +*** Environment variables + +#+begin_src elisp +(setenv "PAGER" "cat") +(setenv "TERM" "dumb") +(setenv "NO_COLOR") +(setenv "GPG_AGENT_INFO" nil) +#+end_src + +** Network management #+begin_src elisp (package-ensure 'enwc) (setopt enwc-default-backend 'nm) -- cgit 1.4.1-2-gfad0