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>m", "", { buffer = true, desc = "mail functions" })
24 vim.keymap.set("n", "<leader>ms", "", { buffer = true, desc = "subject manipulation" })
29 ":1,/^$/s,\\v(Subject:)\\s*((Re|AW):\\s*)*((.|\\_s\\s+)+),\\1 (was: \\4),e<CR>:set nohls<CR>Whi",
30 -- <CR><cmd>set nohls<CR>f li",
31 { buffer = true, desc = "make a new subject" }
36 '1G/\\v^Subject:(.|\\_s\\s+)+was:/e<CR>:set nohls<CR>"_dab',
37 { buffer = true, desc = "remove old subjects" }
40 vim.keymap.set("n", "<leader>p", "", { buffer = true, desc = "mailplate profiles" })
45 ":w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>",
46 { buffer = true, desc = "Automatically determine mailplate profile" }
49 local function profile_keymap(key, profile)
52 "<leader>p<" .. key .. ">",
53 ":w<CR>:%!mailplate --keep-unknown " .. profile .. "<CR>",
54 { buffer = true, desc = "Switch to mailplate profile '" .. profile .. "'" }
58 profile_keymap("F1", "official")
59 profile_keymap("F2", "pobox")
60 profile_keymap("F3", "tahi")
61 profile_keymap("F4", "toni")
62 profile_keymap("F5", "kbkg")
63 profile_keymap("F6", "krafftwerk")
64 profile_keymap("F7", "siby")
65 profile_keymap("F8", "debian")
66 profile_keymap("F9", "uniwh")
67 profile_keymap("F10", "mtfk")
68 profile_keymap("F11", "sudetia")
69 profile_keymap("F12", "default")
71 local function write_mail_backup()
72 local tmpdir = vim.fn.expand(os.getenv("TMPDIR") or "/tmp") .. "/mail-backups"
73 vim.fn.mkdir(tmpdir, "p", "0o700")
74 local filename = os.date("%Y-%m-%d-%H%M%S") .. ".msg"
75 local file = io.open(tmpdir .. "/" .. filename, "a")
77 local lines = vim.api.nvim_buf_get_lines(0, 1, -1, false) or {}
78 local content = table.concat(lines, "\n")
81 vim.notify("Saved a backup to " .. filename, vim.log.levels.INFO)
85 vim.api.nvim_create_autocmd({ "BufWrite" }, {
86 callback = write_mail_backup,
90 vim.cmd.runtime("greeting_abbrevs.vim")