mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 05:07:55 +08:00
release v0.5.4 (#285)
* replace bsd3 license by bsd4 * add attachments with save and send commands (#284) * set up tpl save and send commands * improve msg save and send handlers * add vim msg#add_attachment fn * improve vim logs * update changelog * add attachment keybind vim doc * reverse range order fetch envelopes (#276) * bump version v0.5.4
This commit is contained in:
@@ -155,6 +155,16 @@ nmap gD <plug>(himalaya-msg-delete)
|
||||
|
||||

|
||||
|
||||
| Function | Default binding |
|
||||
| --- | --- |
|
||||
| Add attachment | `ga` |
|
||||
|
||||
They can be customized:
|
||||
|
||||
```vim
|
||||
nmap ga <plug>(himalaya-msg-add-attachment)
|
||||
```
|
||||
|
||||
When you exit this special buffer, you will be prompted 4 choices:
|
||||
|
||||
- `Send`: sends the message
|
||||
|
||||
@@ -5,6 +5,7 @@ let s:plain_req = function("himalaya#request#plain")
|
||||
|
||||
let s:msg_id = 0
|
||||
let s:draft = ""
|
||||
let s:attachment_paths = []
|
||||
|
||||
function! himalaya#msg#list_with(account, mbox, page, should_throw)
|
||||
let pos = getpos(".")
|
||||
@@ -254,6 +255,7 @@ endfunction
|
||||
function! himalaya#msg#draft_handle()
|
||||
try
|
||||
let account = himalaya#account#curr()
|
||||
let attachments = join(map(s:attachment_paths, "'--attachment '.v:val"), " ")
|
||||
while 1
|
||||
let choice = input("(s)end, (d)raft, (q)uit or (c)ancel? ")
|
||||
let choice = tolower(choice)[0]
|
||||
@@ -261,15 +263,15 @@ function! himalaya#msg#draft_handle()
|
||||
|
||||
if choice == "s"
|
||||
return s:cli(
|
||||
\"--account %s send -- %s",
|
||||
\[shellescape(account), shellescape(s:draft)],
|
||||
\"--account %s template send %s -- %s",
|
||||
\[shellescape(account), attachments, shellescape(s:draft)],
|
||||
\"Sending message",
|
||||
\0,
|
||||
\)
|
||||
elseif choice == "d"
|
||||
return s:cli(
|
||||
\"--account %s --mailbox Drafts save -- %s",
|
||||
\[shellescape(account), shellescape(s:draft)],
|
||||
\"--account %s --mailbox Drafts template save %s -- %s",
|
||||
\[shellescape(account), attachments, shellescape(s:draft)],
|
||||
\"Saving draft",
|
||||
\0,
|
||||
\)
|
||||
@@ -336,6 +338,21 @@ function! himalaya#msg#complete_contact(findstart, base)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! himalaya#msg#add_attachment()
|
||||
try
|
||||
let attachment_path = input("Attachment path: ", "", "file")
|
||||
if empty(expand(glob(attachment_path)))
|
||||
throw "The file does not exist"
|
||||
endif
|
||||
call add(s:attachment_paths, attachment_path)
|
||||
redraw | call himalaya#shared#log#info("Attachment added!")
|
||||
catch
|
||||
if !empty(v:exception)
|
||||
redraw | call himalaya#shared#log#err(v:exception)
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Utils
|
||||
|
||||
" https://newbedev.com/get-usable-window-width-in-vim-script
|
||||
|
||||
@@ -7,6 +7,10 @@ if exists("g:himalaya_complete_contact_cmd")
|
||||
setlocal completefunc=himalaya#msg#complete_contact
|
||||
endif
|
||||
|
||||
call himalaya#shared#bindings#define([
|
||||
\["n", "ga", "msg#add_attachment"],
|
||||
\])
|
||||
|
||||
augroup himalaya_write
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWriteCmd <buffer> call himalaya#msg#draft_save()
|
||||
|
||||
Reference in New Issue
Block a user