mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 13:17:55 +08:00
release v0.5.2 (#282)
* doc: fix blur in list msg screenshots (#181) * fix a typo in mbox arg (#245) `targetted` to `targeted` 👌🏻 * make inbox, sent and drafts folder customizable (#246) * mbox: make inbox, sent and drafts folder customizable * msg: update send handler parameters order * vim: fix extracting message ids from list (#247) The current method doesn't work because the list uses a fancy line character (`│`) as the separator, not a regular pipe character (`|`). Matching for the first number in the line instead solves the problem and will continue to work regardless of what separator is used. * add new line after printing strings (#251) * init cargo workspace (#252) * init cargo workspaces * nix: fix assets path * doc: update rtp vim plugin * vim: add error message if loading vim plugin from vim/ * init sub crates (#253) * init sub crates * doc: update readme * doc: improve main readme * doc: add links, add missing crate task * doc: update emojis * update cargo lock * implement contact completion with completefunc (#250) This allows users to define a command for contact completion with `g:himalaya_complete_contact_cmd` and trigger it with `<C-x><C-u>` when writing an email. * fix clippy lints (#255) * revert cargo workspace feature * fix nix run (#274) * replace cargo2nix by naersk * add rust-analyzer and rustfmt to nix build inputs * remove wiki from git submodules, update changelog * fix missing range when fetch fails, add more logs (#276) * add missing fix in changelog * remove blank lines and spaces from plain parts (#280) * fix watch command (#271) * remove also tabs from text parts (#280) * pin native-tls minor version (#278) * improve msg sanitization (#280) * fix mbox vim plugin telescope preview (#249) * bump version v0.5.2 * update changelog Co-authored-by: Austin Traver <austintraver@gmail.com> Co-authored-by: Jason Cox <dev@jasoncarloscox.com> Co-authored-by: Gökmen Görgen <gkmngrgn@gmail.com> Co-authored-by: Ethiraric <ethiraric@gmail.com>
This commit is contained in:
@@ -305,6 +305,37 @@ function! himalaya#msg#attachments()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! himalaya#msg#complete_contact(findstart, base)
|
||||
try
|
||||
if a:findstart
|
||||
if !exists("g:himalaya_complete_contact_cmd")
|
||||
echoerr "You must set 'g:himalaya_complete_contact_cmd' to complete contacts"
|
||||
return -3
|
||||
endif
|
||||
|
||||
" search for everything up to the last colon or comma
|
||||
let line_to_cursor = getline(".")[:col(".") - 1]
|
||||
let start = match(line_to_cursor, '[^:,]*$')
|
||||
|
||||
" don't include leading spaces
|
||||
while start <= len(line_to_cursor) && line_to_cursor[start] == " "
|
||||
let start += 1
|
||||
endwhile
|
||||
|
||||
return start
|
||||
else
|
||||
let output = system(substitute(g:himalaya_complete_contact_cmd, "%s", a:base, ""))
|
||||
let lines = split(output, "\n")
|
||||
|
||||
return map(lines, "s:line_to_complete_item(v:val)")
|
||||
endif
|
||||
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
|
||||
@@ -326,9 +357,13 @@ function! s:bufwidth()
|
||||
return width - numwidth - foldwidth - signwidth
|
||||
endfunction
|
||||
|
||||
function! s:get_msg_id(line)
|
||||
return matchstr(a:line, '[0-9]*')
|
||||
endfunction
|
||||
|
||||
function! s:get_focused_msg_id()
|
||||
try
|
||||
return s:trim(split(getline("."), "|")[0])
|
||||
return s:get_msg_id(getline("."))
|
||||
catch
|
||||
throw "message not found"
|
||||
endtry
|
||||
@@ -336,7 +371,7 @@ 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])"), ",")
|
||||
return join(map(range(a:from, a:to), "s:get_msg_id(getline(v:val))"), ",")
|
||||
catch
|
||||
throw "messages not found"
|
||||
endtry
|
||||
@@ -349,3 +384,14 @@ function! s:close_open_buffers(name)
|
||||
execute ":bwipeout " . buffer_to_close
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:line_to_complete_item(line)
|
||||
let fields = split(a:line, "\t")
|
||||
let email = fields[0]
|
||||
let name = ""
|
||||
if len(fields) > 1
|
||||
let name = '"' . fields[1] . '" '
|
||||
endif
|
||||
|
||||
return name . "<" . email . ">"
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user