I made a custom completefunc for email addresses from the tip here:
https://gitlab.com/muttmua/mutt/wikis/ConfigTricks

fun! CompleteEmails(findstart, base)
 if a:findstart
   let line = getline('.')
   let start = col('.') - 1
   while start > 0 && line[start - 1] =~ '[^:,]'
     let start -= 1
   endwhile
   return start
 else
   let res = []
   for m in split(system('completeemails ' . shellescape(a:base)), '\n')
     call add(res, m)
   endfor
   return res
 endif
endfun

fun! UserComplete(findstart, base)
 let line = getline(line('.'))
 if line =~ '^\(To\|Cc\|Bcc\|From\|Reply-To\):'
   return CompleteEmails(a:findstart, a:base)
 endif
endfun

And my completer script:

#################################
#!/bin/sh

afile="$HOME/.mutt/aliases"
base=$(echo "$@" | sed "s%^ %%g")

aliases=$(cut -d' ' -f2- $afile | grep -iE "^$base" | cut -d' ' -f2- \
 | sed "s%^% %")
names=$(cut -d' ' -f3- $afile | grep -iE "^$base" \
 | sed "s%^% %")
addresses=$(cut -d'<' -f2 $afile | cut -d'>' -f1 | grep -iE "^$base" \
 | sed "s%^% %")

printf "%s\n%s\n%s" "$aliases" "$names" "$addresses" | sort -u
################################

When querying the script it works, but when I select an entry I get
": &" added to the end of the line.

This even happens if I put this in the top of the script:

echo " a"
echo " b"
echo " c"
exit

It doesn't do this when using a string, like the CompleteMonths()
example in the docs.

Why is it adding the ": &" to the end?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to