[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vile] How to insert text in a macro
From: |
Chris Green |
Subject: |
Re: [vile] How to insert text in a macro |
Date: |
Tue, 13 Oct 2015 09:20:43 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Oct 12, 2015 at 07:49:35PM -0400, Thomas Dickey wrote:
[snip - thanks for the explanation]
>
> suggestions for how to improve this are welcome :-)
>
I suspect that the only really practical way would be another page of
documentation called 'commands' or whatever they should be called with
a longer explanation of each command.
It's something I'd certainly use whenever I go through one of these
exercises where I need to add bits to my .vilerc to do specialised
things.
I'd be happy to attempt a first pass at least, it would take me a
while though as I'm not all *that* familiar with vile (that might be a
good thing of course).
By the way I have finally got what I've been trying to do for the past
few days working properly now.
I've been replacing my use of vile's internal crypt which is very
handy in its ease of use:-
vile -k $pwd <encrypted file>
I now use gpg, the difficult bit was to avoid saving the unencrypted
data in temporary files anywhere, that's why I wanted to get vile to
write to stdout. Adding in the need to get the password through to
the output as well makes things quite difficult!
Getting the file *into* vile is fairly straightforward:-
echo $pwd | gpg -d --passphrase-fd 0 $1 | vi
(the password has been obtained earlier, needs to be in the user's
environment so it can be used when the file is saved)
Saving the file from vile uses the following stored procedure:-
store-procedure write-stdout-exit
setv %gpg "gpg --symmetric --passphrase-fd 0 >temp.gpg"
;
;
; Only do this if we're editing stdin (which is fed in from gpg)
; and the buffer has been changed
;
~if &sequal $cbufname "[Standard Input]"
~if $modified
goto-beginning-of-file
insert-string &env "pwd"
insert-string "\n"
goto-beginning-of-file
filter-til end-of-file %gpg
quit-without-save
~else
quit
~endif
~else
write-changed-buffers-and-quit
~endif
~endm
This works because gpg (with --passphrase-fd 0) reads just the first
line of stdin as the password and then treats the rest of stdin as the
file to be encrypted.
It could be done a bit more tidily maybe but it's fairly easy to
understand as it is now which is quite important.
Thanks for all the help on the way, just being able to use this list
as a sort of sounding board is useful.
.... and I did mean that bit about documenting built-in commands if
you think it might be useful.
--
Chris Green