> " mutt: insert attachment                                                     
>                                                                               
>                              

> fun! RangerMuttAttach()                                                       
>                                                                               
>                              
>     silent !screen -X eval 'split -v' 'focus' 'screen' 'exec ranger 
>--choosefile=/tmp/chosenfile'      
>    if filereadable('/tmp/chosenfile')                                         
>                                                                               
>                            
>    exec 'read /tmp/chosenfile'                                                
>                                                                               
>                           
>    call system('rm /tmp/chosenfile')                                          
>                                                                               
>                       
>    endif                                                                      
>                                                                               
>                           
>    redraw!                                                                    
>                                                                               
>                           
>endfun                                                                         
>                                                                               
>                            
>map \\a magg/Reply-To<CR><ESC>:call RangerMuttAttach()<CR>IAttach: <ESC>`a    
There's one problem: If you exit ranger without a selection the "Attach: " 
string is inserted
nevertheless. This is the reason why I changed it finally to this version:
|  " mutt: insert attachment with ranger 
|  fun! RangerMuttAttach()
|      if filereadable('/tmp/chosendir')
|          silent !ranger --choosefiles=/tmp/chosenfiles 
--choosedir=/tmp/chosendir "$(cat /tmp/chosendir)"
|      else
|          silent !ranger --choosefiles=/tmp/chosenfiles 
--choosedir=/tmp/chosendir
|      endif    
|      if filereadable('/tmp/chosenfiles')
|          call system('sed "s/\(.*\)/Attach: \1/" /tmp/chosenfiles > 
/tmp/muttattach')
|          exec 'read /tmp/muttattach'
|          call system('rm /tmp/chosenfiles /tmp/muttattach')
|      endif
|      redraw!
|  endfun
|  map <C-a> magg/Reply-To<CR><ESC>:call RangerMuttAttach()<CR>`a

Notice that there is a new option --choosefiles (plural).
This is in the newest git version of ranger and returns all the selected files. 
You need a 
 version not older than this to use the --choosefiles option.
The additional lines I have added let ranger remember the last active directory.

> Do you have a way to empty the registry as well from the last use of
> this function so it does not paste the previous file instead of the new
> one? Tried different ways for that like ':let @a=""', but it did not work.
I'm very sorry I cannot understand. Can you explain in more detail what's going 
wrong?

Reply via email to