fix vim msg list and read

This commit is contained in:
Clément DOUIN 2021-09-19 18:08:27 +02:00
parent 9931658ea3
commit b9a9d0e687
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
2 changed files with 14 additions and 7 deletions

View file

@ -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

View file

@ -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