From b9a9d0e6878972071c748e5ed93353b6e486abc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Sun, 19 Sep 2021 18:08:27 +0200 Subject: [PATCH] fix vim msg list and read --- vim/autoload/himalaya/msg.vim | 18 +++++++++++------- vim/autoload/himalaya/shared/cli.vim | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vim/autoload/himalaya/msg.vim b/vim/autoload/himalaya/msg.vim index f7804968..f51362c4 100644 --- a/vim/autoload/himalaya/msg.vim +++ b/vim/autoload/himalaya/msg.vim @@ -8,11 +8,15 @@ let s:draft = "" " Message function! s:format_msg_for_list(msg) - let msg = copy(a:msg) - let flag_new = index(msg.flags, "Seen") == -1 ? "✷" : " " - let flag_flagged = index(msg.flags, "Flagged") == -1 ? " " : "!" - let flag_replied = index(msg.flags, "Answered") == -1 ? " " : "↵" + let msg = {} + let msg.uid = a:msg.uid + let flag_new = index(a:msg.flags, "Seen") == -1 ? "✷" : " " + let flag_flagged = index(a:msg.flags, "Flagged") == -1 ? " " : "!" + let flag_replied = index(a:msg.flags, "Answered") == -1 ? " " : "↵" let msg.flags = printf("%s %s %s", flag_new, flag_replied, flag_flagged) + let msg.subject = a:msg.headers.subject + let msg.sender = a:msg.headers.from[0] + let msg.date = a:msg.date return msg endfunction @@ -61,13 +65,13 @@ function! himalaya#msg#read() \"--account %s --mailbox %s read %d", \[shellescape(account), shellescape(mbox), s:msg_id], \printf("Fetching message %d", s:msg_id), - \0, + \1, \) - let attachment = msg.hasAttachment ? " []" : "" + let attachment = len(msg.attachments) > 0 ? " []" : "" execute printf("silent! edit Himalaya read message [%d]%s", s:msg_id, attachment) setlocal modifiable silent execute "%d" - call append(0, split(substitute(msg.content, "\r", "", "g"), "\n")) + call append(0, split(substitute(msg.body.plain, "\r", "", "g"), "\n")) silent execute "$d" setlocal filetype=himalaya-msg-read let &modified = 0 diff --git a/vim/autoload/himalaya/shared/cli.vim b/vim/autoload/himalaya/shared/cli.vim index 92a42df4..2aee9b3b 100644 --- a/vim/autoload/himalaya/shared/cli.vim +++ b/vim/autoload/himalaya/shared/cli.vim @@ -7,6 +7,9 @@ function! himalaya#shared#cli#call(cmd, args, log, should_throw) redraw | call himalaya#shared#log#info(printf("%s [OK]", a:log)) else try + let res = substitute(res, ":null", ":v:null", "g") + let res = substitute(res, ":true", ":v:true", "g") + let res = substitute(res, ":false", ":v:false", "g") let res = eval(res) redraw | call himalaya#shared#log#info(printf("%s [OK]", a:log)) return res.response