mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 09:05:13 +00:00
add vim deletion range
This commit is contained in:
parent
ac3b0bfdde
commit
fada081115
|
@ -166,7 +166,8 @@ function! himalaya#msg#move(target_mbox)
|
|||
try
|
||||
let msg_id = stridx(bufname("%"), "Himalaya messages") == 0 ? s:get_focused_msg_id() : s:msg_id
|
||||
let choice = input(printf("Are you sure you want to move the message %d? (y/N) ", msg_id))
|
||||
if tolower(choice) != "y" | redraw | echo | return | endif
|
||||
redraw | echo
|
||||
if choice != "y" | return | endif
|
||||
let pos = getpos(".")
|
||||
let source_mbox = himalaya#mbox#curr_mbox()
|
||||
let msg = s:cli("--mailbox %s move %d %s", [shellescape(source_mbox), msg_id, shellescape(a:target_mbox)], "Moving message", 1)
|
||||
|
@ -179,14 +180,15 @@ function! himalaya#msg#move(target_mbox)
|
|||
endtry
|
||||
endfunction
|
||||
|
||||
function! himalaya#msg#delete()
|
||||
function! himalaya#msg#delete() range
|
||||
try
|
||||
let msg_id = stridx(bufname("%"), "Himalaya messages") == 0 ? s:get_focused_msg_id() : s:msg_id
|
||||
let choice = input(printf("Are you sure you want to delete the message %d? (y/N) ", msg_id))
|
||||
if tolower(choice) != "y" | redraw | echo | return | endif
|
||||
let msg_ids = stridx(bufname("%"), "Himalaya messages") == 0 ? s:get_focused_msg_ids(a:firstline, a:lastline) : s:msg_id
|
||||
let choice = input(printf("Are you sure you want to delete message(s) %s? (y/N) ", msg_ids))
|
||||
redraw | echo
|
||||
if choice != "y" | return | endif
|
||||
let pos = getpos(".")
|
||||
let mbox = himalaya#mbox#curr_mbox()
|
||||
let msg = s:cli("--mailbox %s delete %d", [shellescape(mbox), msg_id], "Deleting message", 1)
|
||||
let msg = s:cli("--mailbox %s delete %s", [shellescape(mbox), msg_ids], "Deleting message(s)", 1)
|
||||
call himalaya#msg#list_with(mbox, himalaya#mbox#curr_page(), 1)
|
||||
call setpos('.', pos)
|
||||
catch
|
||||
|
@ -292,3 +294,11 @@ function! s:get_focused_msg_id()
|
|||
throw "message not found"
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:get_focused_msg_ids(from, to)
|
||||
try
|
||||
return join(map(range(a:from, a:to), "s:trim(split(getline(v:val), '|')[0])"), ",")
|
||||
catch
|
||||
throw "messages not found"
|
||||
endtry
|
||||
endfunction
|
||||
|
|
|
@ -17,4 +17,5 @@ call himalaya#shared#bindings#define([
|
|||
\["n", "gC" , "mbox#pick('himalaya#msg#copy')"],
|
||||
\["n", "gM" , "mbox#pick('himalaya#msg#move')"],
|
||||
\["n", "gD" , "msg#delete()" ],
|
||||
\["v", "gD" , "msg#delete()" ],
|
||||
\])
|
||||
|
|
Loading…
Reference in a new issue