; bem's .vilerc...
;
; Last modified July 26 1998
;
~if &seq $progname "vile"
; vile specific stuff....
set fcolor cyan
~endif
~if &seq $progname "xvile"
; xvile stuff
set buffer-hook buffhook
~endif
; update the title to show the current buffer: since I can have several
; xvile's running at once, this can be useful.
store-procedure buffhook
set-variable $title &cat "XVile: " $cbufname
~endm
; misc junk... I like a ruler
set ruler
set tabs 8
set shiftwidth 4
; allow all the fun digraphs.
source .digraphs.rc
set printing-low 160
set printing-high 255
;
; hgrep is a cute little macro that comes with vile. Great for working on
; sprawling code like IMAP.
store-procedure hgrep
perl "require 'hgrep.pl'"
perl hgrep
error-buffer $cbufname
~endm
; spawn off lynx on the current file (forcing html mode)
22 store-macro
write-message &cat "Viewing " $cfilname
~if &seq $progname "vile"
1 shell-command &cat "lynx -force_html " $cfilname
~else
shell-command &cat &cat "xterm -e lynx -force_html " $cfilname "&"
~endif
~endm
23 store-macro
set-variable %command &cat "lynx -dump -force_html " $cfilname
capture-command %command
~endm
; Included below are 4 vile macros to sign buffers with PGP 2.6.2 plain
; text signatures. One use for these macros is to sign e-mail messages
; or USENET postings. When selecting one or more of the macros below,
; choose based on these criteria:
; - type of shell specified in $SHELL
; - whether or not the buffer contains message headers (at top of
; buffer) that are separated from message body by a blank line.
; Some mail user agents expose headers to the end user (e.g., mush)
; and others do not (elm). If you post USENET messages via Pnews,
; message headers are included in the buffer.
;
; All macros use the same principle:
; - prompts for PGP pass phrase for user Clark (change this user id
; as appropriate for your application)
; - places pass phrase at appropriate point in buffer
; - filters buffer to pgp and forces pgp to read passphrase from buffer.
; Buffer signed from the first blank line of the buffer to end-of-file.
; Macro applicable to csh and its derivatives (tcsh, etc). Due to
; inherent limitations in csh commandline syntax, this macro reads all
; pgp output (stdout & stderr) and then filters it. Consequently, if
; something goes wrong (e.g., passphrase typo), the pgp error msg is
; retained in the buffer.
31 store-macro
set-variable %phrase &cat @"PGP PassPhrase? " "\n"
write-message " " ; erase passphrase
set-variable %var "setenv PGPPASSFD 0;"
set-variable %cmd &cat %var "pgp -fsta -u bem"
beginning-of-file
search-forward "^[ \t]*$"
set-named-mark q
~force down-line
insert-string %phrase
~force up-line-at-bol
filter-til end-of-file %cmd
goto-named-mark q
down-line
~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-31 #-t ; invoke with the keystroke #t
;
; Same macro as above, except that the entire buffer is signed.
;
32 store-macro
set-variable %phrase &cat @"PGP PassPhrase? " "\n"
write-message " " ; erase passphrase
set-variable %var "setenv PGPPASSFD 0;"
set-variable %cmd &cat %var "pgp -fsta -u bem"
beginning-of-file
insert-string %phrase
~force up-line-at-bol
filter-til end-of-file %cmd
beginning-of-file
~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-32 #-T ; invoke with the keystroke #T
; This macro stolen from Clark O. Morgan, cmorgan@aracnet.com who posted it
; to Usenet in <5cb7l6$41q@shelob.aracnet.com>. I've hacked it a bit to
; know about 'mailmode' (for news and mail posts) and 'htmlmode' for
; web pages.
;
; Vile macro to ispell an e-mail msg or USENET posting that contains
; msg headers (headers are separated from body by at least one blank line).
; This macro feeds the Subject: header and msg body to ispell, then glues
; the returned result back into the original message. NB: this macro does
; not handle a Subject: hdr that's continued over more than one line and
; it assumes that the blank line separating hdrs & body is exactly "^$" .
24 store-macro
beginning-of-file
; only play around with the header-skipping-stuff if we're in mailmode...
~if ¬ &seq $majormode "mail"
search-forward ""
beginning-of-file
~goto wholebuffer
~endif
search-forward "^" ; $match has known value
load-register p ""
~force search-forward "^Subject:"
~if &seq "Subject:" $match
use-register p delete-til lines ; delete til eol
~endif
beginning-of-file
~force search-forward "^$"
*wholebuffer
~if &seq "" $match
use-register P delete-til goto-line ; delete til EOF
~else ; Assume no msg body, add blank line as msg
end-of-file
1 force-blank-lines
use-register P delete-til goto-line ; delete til EOF
~endif
write-file
set-variable %origfile $cfilname
set-variable %tmpleaf &cat ".vile.ispell." $pid
set-variable %tmpfile &cat "$HOME/" %tmpleaf
edit-file %tmpfile
use-register p put-after ; put subj hdr & msg body in tmp file
write-file
1 shell-command &cat "chmod go-rwx " %tmpfile ; protect file contents
; set the '-h' flag if we're in html mode.
~if &seq $majormode "html"
set-variable %ispellopts "-h "
~else
set-variable %ispellopts ""
~endif
~if &seq $progname "vile"
1 shell-command &cat &cat "ispell " %ispellopts $cfilname
~else
1 shell-command &cat &cat "xterm -e ispell " %ispellopts $cfilname
~endif
edit-file %origfile
end-of-file
insert-file %tmpfile
delete-buffer %tmpleaf
1 shell-command &cat &cat "rm " %tmpfile "*" ; cleanup tmpfile
~endm
bind-key execute-macro-24 ^X-i ; invoke with the keystroke ^X-i
17 store-macro
write-message "[Attaching C/C++ attributes...]"
set-variable %savcol $curcol
set-variable %savline $curline
set-variable %modified $modified
goto-beginning-of-file
filter-til end-of-file "/usr/local/bin/vile-c-filt"
goto-beginning-of-file
attribute-cntl_a-sequences-til end-of-file
~if ¬ %modified
unmark-buffer
~endif
%savline goto-line
%savcol goto-column
write-message "[Attaching C/C++ attributes...done ]"
setl cmode
~endm
define-majormode c
; Declares a mode 'c', and corresponding symbol 'cmode'
define-submode c suffixes=\\.\\(\\([Cchisyl]\\)\\|CC\\|cc|cpp\\|cxx\\|hxx\\|scm\\|pl\\)$
; suck perl into cmode
define-submode c preamble "^#.*perl\\>"
; Specifies the filename suffixes which control whether a newly-loaded
; buffer is set to 'c' mode.
define-submode c tabs=8
define-submode c shiftwidth=4
define-submode c autoindent
; perl majormode deleted..... I can't make it do everything that 'cmode' does
; like { and } indent-in and indent-out.
define-majormode html
define-submode html suffixes "\\.\\(s\\|p\\)\\?html\\?$"
define-submode html wrapmargin 8
define-submode html shiftwidth 4
define-submode html tabs=8
define-submode html autoindent
define-submode html comments begin ""
define-submode html fence-pairs "<>"
; define-submode html paragraphs "\\?p[^>]*>"
; paragraphs are
,
,
... anything else? In short, these are
; things that force a hard return so that ^Af will be happy to reformat
; them for us without breaking the HTML or making it look ugly.
define-submode html paragraphs "\\?\\([pP]\\|[bB][Rr]\\|[lL][iI]\\)[^>]*>"
; sections.... should these be table-things?
;
; macro 2 - forward to the line of same indent
2 store-macro
first-nonwhite
set-variable %indlev $curcol
~force down-line-at-bol
~if &seq &trim $line ""
~goto L2
~endif
~while &les %indlev $curcol
*L2
~force down-line-at-bol
~if &seq $status "FALSE"
~return
~endif
~if &seq &trim $line ""
~goto L2
~endif
~endwhile
~endm
bind-key execute-macro-2 ^X-]
; space is follow hyperlink
30 store-macro
~force execute-hypertext-command
~if ¬ $status
~force forward-character-to-eol
~endif
~endm
bind-key execute-macro-30 \
;
; A delete-sig macro for mail/news posts (this works great with both
; slrn and mutt: others may need to change the suffixes).
store-procedure del-sig
~if ¬ &seq $majormode "mail"
~goto finish
~endif
set fcolor white
goto-beginning-of-file
~force search-forward "^>[> ]* -- $"
; if .sig exists ...
~if ¬ &equ $curline 1
; this one took me a while to fix... we delete until our sig
; seperator, or a null line (being end of file). Without the
; second trap, if you have no .sig file it would loop forever
; trying to delete that last line.
~while &and ¬ &seq $line "-- " ¬ &seq $line ""
~force delete-til lines
~endwhile
; shove a newline back in right before our own .sig (it
; looks better this way).
newline
goto-beginning-of-file
~endif
; move the cursor after the headers, on the first line of the body.
; (I have $edit_hdrs set :) remove these two lines if you don't.
; I also 'force' them, since it would otherwise fail if I have
; no .sig and write a new letter.
~force next-paragraph
~force next-line
perl "require 'mail.pl'"
perl format_mail
*finish
~endm
define-mode mail
define-submode mail suffixes \\(^\\(/tmp/mutt-[a-z]\\+-[0-9]\\+-[0-9]\\+\\)\\|\\(.followup\\|.letter\\|.article\\)\\)$
define-submode mail wm 8
set read-hook "del-sig"
; set buffer-hook "init"
;
; this procedure implements a primitive ascii picture-drawing mode.
; pgf, may '95
; motions are accomplished with the usual h, j, k, and l keys
; (the arrow keys do _not_ work here). in addition, the u, i,
; n, and m keys will perform diagonal motions. look at your
; keyboard to see why these were chosen.
; normally, entering the motion characters (h, j, k, l, u, i, n, m)
; will draw appropriate box outlines, using the -, |, /, and \ characters.
; lines will be drawn instead with a specific character if the 'c' command
; is given -- you will be prompted for a character. this can be
; cancelled, to revert lines to their "natural" rendition, with the
; 'C' command. for example, to draw with a '+' character, you would
; use "c+" and when finished, would cancel with "C".
; the ^T command will allow you to enter a string of text. this
; text will accumulate until ESC, CR, or NL is typed.
; all other input will be inserted as-is, with no cursor movement. so
; the space bar can be used to "erase" previously drawn stuff.
; space for the picture must be pre-allocated, with, for example:
; 80i yy24p
;
; start this up with "run pic"
; to bind it to a key instead, change it to a "NN store-macro", and
; then bind "execute-macro NN" to the key you want.
store-procedure replc
; never replace a newline
~if &equ $char 0xA
~return
~endif
~if &seq %userchar &chr 0
replace-character %linechar
~else
replace-character %userchar
~endif
~endm
store-procedure pic
set-variable %keywas &chr 0
set-variable %userchar &chr 0
set-variable %linechar &chr 0
write-message "entering picture, end with ESC"
redraw-display
~while 1
set-variable %keywas >k
; was it ESC? quit if so.
~if &seq %keywas &chr 0x1b
~break
~endif
; Rectangular Lines: h, j, k, l
~if &seq %keywas h
~force backward-character
set-variable %linechar -
run replc
~goto redraw
~endif
~if &seq %keywas l
~force forward-character
set-variable %linechar -
run replc
~goto redraw
~endif
~if &seq %keywas j
~force down-line
set-variable %linechar |
run replc
~goto redraw
~endif
~if &seq %keywas k
~force up-line
set-variable %linechar |
run replc
~goto redraw
~endif
; Diagonal Lines: u, i, n, m
~if &seq %keywas u
~force up-line
~force backward-character
set-variable %linechar "\\\\"
run replc
~goto redraw
~endif
~if &seq %keywas i
~force up-line
~force forward-character
set-variable %linechar /
run replc
~goto redraw
~endif
~if &seq %keywas n
~force down-line
~force backward-character
set-variable %linechar /
run replc
~goto redraw
~endif
~if &seq %keywas m
~force down-line
~force forward-character
set-variable %linechar "\\\\"
run replc
~goto redraw
~endif
; Rectangular Motions: ^H, ^L, ^J, ^K
; was it ^H
~if &seq %keywas &chr 0x8
~force backward-character
~goto redraw
~endif
; was it ^L
~if &seq %keywas &chr 0xC
~force forward-character
~goto redraw
~endif
; was it ^J
~if &seq %keywas &chr 0xA
~force down-line
~goto redraw
~endif
; was it ^K
~if &seq %keywas &chr 0xB
~force up-line
~goto redraw
~endif
; Diagonal Motions: ^U, ^I, ^N, ^M
; was it ^U
~if &seq %keywas &chr 0x15
~force up-line
~force backward-character
~goto redraw
~endif
; was it ^I
~if &seq %keywas &chr 0x9
~force up-line
~force forward-character
~goto redraw
~endif
; was it ^N
~if &seq %keywas &chr 0xE
~force down-line
~force backward-character
~goto redraw
~endif
; was it ^M
~if &seq %keywas &chr 0xD
~force down-line
~force forward-character
~goto redraw
~endif
; Text: ^Ttext to be entered
; was it ^T
~if &seq %keywas &chr 0x14
write-message "entering text, end with CR"
redraw-display
set-variable %textkey 0
~while 1
set-variable %textkey >k
; was it CR (^M)
~if &seq %textkey &chr 0xD
~break
~endif
; was it LF (^J)
~if &seq %textkey &chr 0xA
~break
~endif
; was it ESC (^[)
~if &seq %textkey &chr 0x1B
~break
~endif
; was it BS (^H) or DEL?
~if &or &seq %textkey &chr 0x7f &seq %textkey &chr 0x8
~force backward-character
replace-character &chr 0x20
~force backward-character
set-variable %textkey &chr $char
~endif
replace-character %textkey
~force forward-character
redraw-display
~endwhile
write-message "text done, drawing lines again"
~goto redraw
~endif
; user-selected lines: 'c' to set the linechar, 'C' to cancel
~if &seq %keywas c
write-message "enter char to draw with: "
set-variable %userchar >k
write-message &cat "will draw with: " %userchar
~goto redraw
~endif
~if &seq %keywas C
write-message "will draw normal lines again"
set-variable %userchar &chr 0
~goto redraw
~endif
; Everything else is self inserting
replace-character %keywas
*redraw
redraw-display
~endwhile
write-message "picture mode done"
~endm
; makes Anchor ("
~force forward-char-scan " "
~if ¬ &equ $char 32
end-of-line
append-string ""
~else
insert-string ""
~endif
~endm
;
; okay, I'm going to try this again, but with perl....
; I just want to shove an item into the [Error Expressions] buffer so that
; weblint's pattern can be spotted.
; the pattern: "%F(%L):%T"
; this is somewhat hackish: we force the error expressions into existence by
; compiling them, then shove our new expression into place, then recompile.
compile-error-expressions
perl "require 'vileinit.pl'"
compile-error-expressions