vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] Detecting if vile is idle


From: Chris Green
Subject: Re: [vile] Detecting if vile is idle
Date: Fri, 1 Apr 2016 10:37:57 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

> 
> buffer-hook does what I need, it gets run when entering the first
> buffer so I can do something in a procedure called by buffer-hook that
> sets the modified flag.
> 
Just as a final follow-up to this I now have what I want working
perfectly thanks to the various bits of help here.

The whole point of the exercise was to feed the output of decrypting a
gpg encrypted file into vile by stdin and then, on exit from vile to
re-encrypt it from stdout back into gpg.  Thus no temporary files with
decrypted data hanging around.

Then, having done the above I wanted to auto-close the vile window
after a timeout as I was always finding vile open on the decrypted
data that I had left there hours or days before.

The whole of my extra .vilerc for this is appended below:-

;
;
; .nnvilerc: special vilerc file for nn encrypted file editing
;
;
;
; get my standard vile configuration
;
source ~/.vilerc
;
;
; map ZZ to write-stdout-exit procedure
;
map ZZ :write-stdout-exit^M
;
;
; procedure to run on ZZ exit, inserts the pass phrase at the beginning
; of the file and then runs it through gpg to encrypt it.
;
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
;
;
; procedure run by buffer-hook on entry to set the modified flag
;
store-procedure modify-it 'Set buffer modified flag'
    insert-string "XXXXX"
    undo-change
~endm

setv buffer-hook modify-it
;
;
; use the autocolor hook to time out if idle
;
store-procedure idleExit 'Exit after period of idleness'
    write-stdout-exit
~endm

setv $autocolor-hook idleExit
;
;
; timeout in mS
;
setv $autocolor 60000


-- 
Chris Green



reply via email to

[Prev in Thread] Current Thread [Next in Thread]