All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 local i, _ = string.find(vim.bo.filetype, "markdown")
3 vim.opt_local.filetype = "mail.markdown"
4 -- this should trigger a reload of the ftplugin
8 -- There are no diagnostics for mail, but we do not want the
9 -- Markdown standards imposed on mail header and signature…
10 vim.diagnostic.enable(false)
11 vim.b.autoformat = false
13 -- disable Treesitter format expression for Mail
14 vim.opt_local.formatexpr = ""
16 vim.opt_local.formatoptions:remove("o")
17 vim.opt_local.formatoptions:remove("r")
18 vim.opt_local.formatoptions:remove("l")
19 vim.opt_local.formatoptions:append("a")
20 vim.opt_local.formatoptions:append("w")
21 vim.opt_local.formatoptions:append("n")
23 vim.keymap.set("n", "<leader>p", "", { buffer = true, desc = "mailplate profiles" })
28 ":w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>",
29 { buffer = true, desc = "Automatically determine mailplate profile" }
32 local function profile_keymap(key, profile)
35 "<leader>p<" .. key .. ">",
36 ":w<CR>:%!mailplate --keep-unknown " .. profile .. "<CR>",
37 { buffer = true, desc = "Switch to mailplate profile '" .. profile .. "'" }
41 profile_keymap("F1", "official")
42 profile_keymap("F2", "pobox")
43 profile_keymap("F3", "tahi")
44 profile_keymap("F4", "toni")
45 profile_keymap("F5", "kbkg")
46 profile_keymap("F6", "krafftwerk")
47 profile_keymap("F7", "siby")
48 profile_keymap("F8", "debian")
49 profile_keymap("F9", "uniwh")
50 profile_keymap("F10", "mtfk")
51 profile_keymap("F11", "sudetia")
52 profile_keymap("F12", "default")
54 local function write_mail_backup()
55 local tmpdir = vim.fn.expand(os.getenv("TMPDIR") or "/tmp") .. "/mail-backups"
56 vim.fn.mkdir(tmpdir, "p", "0o700")
57 local filename = os.date("%Y-%m-%d-%H%M%S") .. ".msg"
58 local file = io.open(tmpdir .. "/" .. filename, "a")
60 local lines = vim.api.nvim_buf_get_lines(0, 1, -1, false) or {}
61 local content = table.concat(lines, "\n")
64 vim.notify("Saved a backup to " .. filename, vim.log.levels.INFO)
68 vim.api.nvim_create_autocmd({ "BufWrite" }, {
69 callback = write_mail_backup,
73 vim.cmd.runtime("greeting_abbrevs.vim")