upgrade toc in email-in-kakoune to new system
This commit is contained in:
parent
307f27f3fc
commit
8fac51f4d0
1 changed files with 42 additions and 45 deletions
|
@ -3,24 +3,18 @@ title: Writing Emails In Kakoune
|
||||||
date: 2025-06-01
|
date: 2025-06-01
|
||||||
---
|
---
|
||||||
|
|
||||||
This post will guide you through my setup for using Kakoune as an email composer
|
This post will guide you through my setup for using Kakoune as an email
|
||||||
inside `aerc`. I'll also explain how to configure Kakoune to act as the _pager_
|
composer inside `aerc`. I'll also explain how to configure Kakoune to act
|
||||||
for reading `text/plain` emails. If you only care about the final config, feel
|
as the _pager_ for reading `text/plain` emails. If you only care about the
|
||||||
free to skip to it [here](#final-configuration).
|
final config, feel free to skip to it [here](#final-configuration).
|
||||||
|
|
||||||
<!--toc:start-->
|
[TOC]
|
||||||
|
|
||||||
- [Naive Approach](#naive-approach)
|
|
||||||
- [Composer Setup](#composer-setup)
|
|
||||||
- [Reader Setup](#reader-setup)
|
|
||||||
- [Final Configuration](#final-configuration)
|
|
||||||
|
|
||||||
<!--toc:end-->
|
|
||||||
|
|
||||||
## Naive Approach
|
## Naive Approach
|
||||||
|
|
||||||
Since `aerc` uses your `$EDITOR` for composition, you don't technically have to
|
Since `aerc` uses your `$EDITOR` for composition, you don't technically
|
||||||
do anything. I prefer setting it explicitly in `aerc.conf`, for good measure:
|
have to do anything. I prefer setting it explicitly in `aerc.conf`, for
|
||||||
|
good measure:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[compose]
|
[compose]
|
||||||
|
@ -31,8 +25,9 @@ The rest of the magic happens in your `kakrc`.
|
||||||
|
|
||||||
## Composer Setup
|
## Composer Setup
|
||||||
|
|
||||||
Essentially, we want to hook `filetype=mail` and set our buffer configuration
|
Essentially, we want to hook `filetype=mail` and set our buffer
|
||||||
there. I'll share a recommended configuration with some explanation.
|
configuration there. I'll share a recommended configuration with some
|
||||||
|
explanation.
|
||||||
|
|
||||||
```kak
|
```kak
|
||||||
hook global WinSetOption filetype=mail %~
|
hook global WinSetOption filetype=mail %~
|
||||||
|
@ -47,51 +42,53 @@ hook global WinSetOption filetype=mail %~
|
||||||
~
|
~
|
||||||
```
|
```
|
||||||
|
|
||||||
I use a custom formatter to format emails. It automatically hard-wraps lines
|
I use a custom formatter to format emails. It automatically hard-wraps
|
||||||
while preserving certain markup elements, code blocks, sign-offs, and signature
|
lines while preserving certain markup elements, code blocks, sign-offs,
|
||||||
blocks. For more details, check the formatting section of my post on
|
and signature blocks. For more details, check the formatting section of my
|
||||||
[Helix](/blog/email/helix#formatting).
|
post on [Helix](/blog/email/helix#formatting).
|
||||||
|
|
||||||
I find that setting `>` as the `comment_line` token is convenient for working
|
I find that setting `>` as the `comment_line` token is convenient for
|
||||||
with quotes in replies.
|
working with quotes in replies.
|
||||||
|
|
||||||
The `try autospell-enable` enables my
|
The `try autospell-enable` enables my
|
||||||
[kak-autospell](https://codeberg.org/ficd/kak-autospell) plugin for the buffer.
|
[kak-autospell](https://codeberg.org/ficd/kak-autospell) plugin for the
|
||||||
Essentially, it provides spellchecking that's continuously refreshed and hidden
|
buffer. Essentially, it provides spellchecking that's continuously
|
||||||
in insert mode.
|
refreshed and hidden in insert mode.
|
||||||
|
|
||||||
The remaining commands configure auto-formatting on save. I always prefer having
|
The remaining commands configure auto-formatting on save. I always prefer
|
||||||
this on so I never forget to format my message before sending it.
|
having this on so I never forget to format my message before sending it.
|
||||||
|
|
||||||
## Reader Setup
|
## Reader Setup
|
||||||
|
|
||||||
I find that using Kakoune to **read** emails is helpful because of how easy it
|
I find that using Kakoune to **read** emails is helpful because of how
|
||||||
is to copy quotes, open links, etc. Configuring this is a tad hackier, however.
|
easy it is to copy quotes, open links, etc. Configuring this is a tad
|
||||||
The basic idea is to set Kakoune as the viewer `pager` in `aerc.conf`.
|
hackier, however. The basic idea is to set Kakoune as the viewer `pager`
|
||||||
|
in `aerc.conf`.
|
||||||
|
|
||||||
However, all this does is pipe the email to `kak` through standard input, so we
|
However, all this does is pipe the email to `kak` through standard input,
|
||||||
need to tell the editor to treat it like an email:
|
so we need to tell the editor to treat it like an email:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[viewer]
|
[viewer]
|
||||||
pager=kak -e 'set buffer filetype mail'
|
pager=kak -e 'set buffer filetype mail'
|
||||||
```
|
```
|
||||||
|
|
||||||
When you're using Kakoune as a pager, you'll probably want to configure some
|
When you're using Kakoune as a pager, you'll probably want to configure
|
||||||
things differently. In my case, I like to set the buffer as `readonly`, remove
|
some things differently. In my case, I like to set the buffer as
|
||||||
the `number-lines` and `show-whitespaces` highlighters, disable soft-wrap & my
|
`readonly`, remove the `number-lines` and `show-whitespaces` highlighters,
|
||||||
scrolloff settings, and _not_ set any formatters.
|
disable soft-wrap & my scrolloff settings, and _not_ set any formatters.
|
||||||
|
|
||||||
The `pager` command above sets the filetype, but we need to distinguish between
|
The `pager` command above sets the filetype, but we need to distinguish
|
||||||
_composing_ and _reading_ in our Kakoune hook. When Kakoune is opened with input
|
between _composing_ and _reading_ in our Kakoune hook. When Kakoune is
|
||||||
through standard input, it loads a buffer that's conveniently named `*stdin*`.
|
opened with input through standard input, it loads a buffer that's
|
||||||
Thus, we can check the buffer name before continuing.
|
conveniently named `*stdin*`. Thus, we can check the buffer name before
|
||||||
|
continuing.
|
||||||
|
|
||||||
If we're in "reading mode", we define a hidden command called `ismailreader`
|
If we're in "reading mode", we define a hidden command called
|
||||||
which doesn't do anything. Why? If the command is defined, and we try to invoke
|
`ismailreader` which doesn't do anything. Why? If the command is defined,
|
||||||
it... well, nothing happens! But if it's **not** defined, we get an error
|
and we try to invoke it... well, nothing happens! But if it's **not**
|
||||||
instead. We can combine this with the `try` command to for some simple boolean
|
defined, we get an error instead. We can combine this with the `try`
|
||||||
logic.
|
command to for some simple boolean logic.
|
||||||
|
|
||||||
```kak
|
```kak
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue