diff --git a/ftplugin/mail.lua b/ftplugin/mail.lua index 89d250c..1fa136f 100644 --- a/ftplugin/mail.lua +++ b/ftplugin/mail.lua @@ -4,6 +4,13 @@ if vim.startswith(vim.fs.basename(vim.api.nvim_buf_get_name(0)), "thread:") then vim.opt_local.foldmethod = "marker" vim.opt_local.foldlevel = 0 + -- if there is only one message, open it + if vim.b.notmuch_messages and #vim.b.notmuch_messages == 1 then + vim.schedule(function() + vim.cmd.normal({ args = { "zR" }, bang = true }) + end) + end + vim.api.nvim_buf_create_user_command(0, "TagAdd", function(arg) tag.msg_add_tag(arg.args) end, { diff --git a/lua/notmuch/init.lua b/lua/notmuch/init.lua index e065206..1899276 100644 --- a/lua/notmuch/init.lua +++ b/lua/notmuch/init.lua @@ -221,8 +221,9 @@ nm.show_thread = function(s) v.nvim_buf_set_lines(buf, 0, 0, false, { hint_text, "" }) -- Place cursor at head of buffer and prepare display and disable modification - v.nvim_buf_set_lines(buf, -2, -1, true, {}) - v.nvim_win_set_cursor(0, { 1, 0}) + v.nvim_buf_set_lines(buf, -2, -1, true, {}) -- remove last line from buffer + v.nvim_win_set_cursor(0, { 4, 0 }) -- jump to first thread + -- set buffer options vim.bo.filetype="mail" vim.bo.modifiable = false