Skip to content

Commit

Permalink
reorganize project tree
Browse files Browse the repository at this point in the history
Put all .vim sources into src/ and use an implicit make rule to build
them into uuencoded versions.

Use variables for Makefile deps.

Put prototypes/ and patches/ into src/ .

Put vimpager.md and vimcat.md into doc/ .

Update Makefile for these changes.

Put ConcealRetab.vim into autoload/ in the built extra runtime path and
rewrite the function and the invocation as an autoload function.
  • Loading branch information
rkitover committed Jul 14, 2015
1 parent 1131f34 commit 8bab382
Show file tree
Hide file tree
Showing 28 changed files with 133 additions and 42 deletions.
28 changes: 13 additions & 15 deletions Makefile
Expand Up @@ -7,9 +7,13 @@ INSTALLMAN=${INSTALL} -m 444
INSTALLCONF=${INSTALL} -m 644
AWK=awk

UUS=ansiesc.tar.uu less.vim.uu perldoc.vim.uu vimcat.uu ConcealRetab.vim.uu
ANSIESC=src/ansiesc/autoload/AnsiEsc.vim src/ansiesc/plugin/AnsiEscPlugin.vim src/ansiesc/plugin/cecutil.vim


all: vimpager docs

vimpager: ansiesc.tar.uu less.vim.uu perldoc.vim.uu vimcat.uu ConcealRetab.vim.uu
vimpager: ${UUS}
mv vimpager vimpager.work
${AWK} '\
/^begin [0-9]* ansiesc.tar/ { exit } \
Expand Down Expand Up @@ -82,20 +86,14 @@ vimpager: ansiesc.tar.uu less.vim.uu perldoc.vim.uu vimcat.uu ConcealRetab.vim.u
rm -f vimpager.work ConcealRetab.vim.uu
chmod +x vimpager

less.vim.uu: less.vim
uuencode less.vim less.vim > less.vim.uu

perldoc.vim.uu: perldoc.vim
uuencode perldoc.vim perldoc.vim > perldoc.vim.uu
%.vim.uu: src/%.vim
(cd src; uuencode `basename $<` `basename $<` > ../$@)

vimcat.uu: vimcat
uuencode vimcat vimcat > vimcat.uu

ConcealRetab.vim.uu: ConcealRetab.vim
uuencode ConcealRetab.vim ConcealRetab.vim > ConcealRetab.vim.uu
uuencode $< $< > $@

ansiesc.tar.uu: ansiesc/autoload/AnsiEsc.vim ansiesc/plugin/AnsiEscPlugin.vim ansiesc/plugin/cecutil.vim
(cd ansiesc; tar cf ../ansiesc.tar .)
ansiesc.tar.uu: ${ANSIESC}
(cd src/ansiesc; tar cf ../../ansiesc.tar .)
uuencode ansiesc.tar ansiesc.tar > ansiesc.tar.uu
rm -f ansiesc.tar

Expand Down Expand Up @@ -135,17 +133,17 @@ install: docs
docs:
@if command -v pandoc >/dev/null; then \
printf '%s' 'Generating vimpager.1...'; \
pandoc -s -w man vimpager.md -o vimpager.1; \
pandoc -s -w man doc/vimpager.md -o vimpager.1; \
tr -d '\015' < vimpager.1 > vimpager.1.tmp; \
mv vimpager.1.tmp vimpager.1; \
echo 'done.'; \
printf '%s' 'Generating vimcat.1...'; \
pandoc -s -w man vimcat.md -o vimcat.1; \
pandoc -s -w man doc/vimcat.md -o vimcat.1; \
tr -d '\015' < vimcat.1 > vimcat.1.tmp; \
mv vimcat.1.tmp vimcat.1; \
echo 'done.'; \
printf '%s' 'Generating README...'; \
pandoc -s -w plain vimpager.md -o README; \
pandoc -s -w plain doc/vimpager.md -o README; \
tr -d '\015' < README > README.tmp; \
mv README.tmp README; \
echo 'done.'; \
Expand Down
2 changes: 1 addition & 1 deletion README.md
3 changes: 3 additions & 0 deletions TODO
@@ -0,0 +1,3 @@
add usage screen
either add multi file support or throw error and update docs
better error message for unreadable files
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ConcealRetab.vim → src/ConcealRetab.vim
@@ -1,6 +1,6 @@
command! -nargs=0 -bang -bar ConcealRetab :call ConcealRetab()
command! -nargs=0 -bang -bar ConcealRetab :call ConcealRetab#ConcealRetab()

function! ConcealRetab()
function! ConcealRetab#ConcealRetab()
let l:current_cursor = getpos('.')

call cursor(1,1)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
90 changes: 90 additions & 0 deletions src/prototypes/gen_awk_uuencode_lookup.py
@@ -0,0 +1,90 @@
#!/usr/bin/env python

# Generate lookup tables code to be placed in BEGIN for an awk lookup table
# based uuencode utility.
#
# Copyright (c) 2015, Rafael Kitover <rkitover@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from sys import stdout, stderr
from collections import defaultdict
import string

def escape(s):
s = s.replace('\\', '\\\\').replace('"', '\\"')
for c in s:
if c not in string.printable or c.isspace():
s = s.replace(c, '\\%03d' % (int(oct(ord(c)))))
return s

left = {}
right = {}

for c1 in range(0, 256):
for c2 in range(0, 256):
left[ chr(c1) + chr(c2)] = chr((c1 >> 2) + 32) + chr(((((c1 & 0b11) << 6) | (c2 >> 2)) >> 2) + 32)
right[chr(c1) + chr(c2)] = chr(((((c1 & 0xF) << 2) & 0b111111) | ((c2 >> 6))) + 32) + chr((c2 & 0b111111) + 32)

lookup = defaultdict(list)

for lr, s, v in [("l", k, v) for k, v in left.items()] + [("r", k, v) for k, v in right.items()]:
lookup[v].append('%s["%s"]' % (lr, escape(s)))

print """\
#!/bin/sh
if command -v gawk >/dev/null; then
awk=gawk
elif command -v nawk >/dev/null; then
awk=nawk
elif command -v mawk >/dev/null; then
awk=mawk
elif [ -x /usr/xpg4/bin/awk ]; then
awk=/usr/xpg4/bin/awk
elif command -v awk >/dev/null; then
awk=awk
else
echo "No awk found!" >&2
exit 1
fi
mkdir /tmp/awk_uuencode_$$
chmod 0700 /tmp/awk_uuencode_$$
trap 'rm -rf /tmp/awk_uuencode_'$$ HUP INT QUIT ILL TRAP KILL BUS TERM
cat <<'EOF' > /tmp/awk_uuencode_$$/uuencode.awk
BEGIN {\
"""

for v, slots in lookup.iteritems():
stdout.write("=".join(slots + ['"%s";\n' % (escape(v))]))

print """\
exit
}
EOF
$awk -f /tmp/awk_uuencode_$$/uuencode.awk
rm -rf /tmp/awk_uuencode_$$
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 24 additions & 24 deletions vimpager
Expand Up @@ -498,8 +498,8 @@ extract_bundled_scripts() {
if [ -n "${use_ansiesc}" ]; then
ansiesc_tar

mkdir "${tmp}/extra_vim_home/plugin" 2>/dev/null
cd "${tmp}/extra_vim_home/plugin"
mkdir "${tmp}/extra_vim_home/autoload" 2>/dev/null
cd "${tmp}/extra_vim_home/autoload"

conceal_retab_vim

Expand All @@ -519,7 +519,7 @@ vim_less() {
extract_bundled_scripts

if [ -n "${use_ansiesc}" ]; then
ansi_command="if exists(':AnsiEsc') | exe 'autocmd VimEnter * :AnsiEsc' | exe 'autocmd VimEnter * :set buftype=nofile modifiable noreadonly' | exe 'autocmd VimEnter * :ConcealRetab' | endif"
ansi_command="if exists(':AnsiEsc') | exe 'autocmd VimEnter * :AnsiEsc' | exe 'autocmd VimEnter * :set buftype=nofile modifiable noreadonly' | exe 'autocmd VimEnter * :call ConcealRetab#ConcealRetab()' | endif"
else
ansi_command='silent! echo'
fi
Expand Down Expand Up @@ -4315,27 +4315,27 @@ conceal_retab_vim() {
(cat <<'EOF') | do_uudecode > ConcealRetab.vim
begin 644 ConcealRetab.vim
M8V]M;6%N9"$@+6YA<F=S/3`@+6)A;F<@+6)A<B!#;VYC96%L4F5T86(@.F-A
M;&P@0V]N8V5A;%)E=&%B*"D*"F9U;F-T:6]N(2!#;VYC96%L4F5T86(H*0H@
M("`@;&5T(&PZ8W5R<F5N=%]C=7)S;W(@/2!G971P;W,H)RXG*0H*("`@(&-A
M;&P@8W5R<V]R*#$L,2D*"B`@("!L970@;#IL;G5M(#T@<V5A<F-H*"=<="<I
M"@H@("`@=VAI;&4@;#IL;G5M("$](R`P"B`@("`@("`@;&5T(&PZ;F5W;&EN
M92`]("<G"B`@("`@("`@;&5T(&PZ8V]L=6UN("`](#`*("`@("`@("!L970@
M;#IL:6YE<&]S(#T@,0H*("`@("`@("!F;W(@;#IC(&EN('-P;&ET*&=E=&QI
M;F4H)RXG*2P@)UQZ<R<I"B`@("`@("`@("`@(&EF(&PZ8R`]/2,@(EQT(@H@
M("`@("`@("`@("`@("`@;&5T(&PZ<W!A8V5S("`@/2`X("T@*&PZ8V]L=6UN
M("4@."D*("`@("`@("`@("`@("`@(&QE="!L.F-O;'5M;B`@*ST@;#IS<&%C
M97,*"B`@("`@("`@("`@("`@("!L970@;#IN97=L:6YE("X](')E<&5A="@G
M("<L(&PZ<W!A8V5S*0H@("`@("`@("`@("!E;'-E"B`@("`@("`@("`@("`@
M("!L970@;#IC;VYC96%L960@/2!S>6YC;VYC96%L960H;#IL;G5M+"!L.FQI
M;F5P;W,I"@H@("`@("`@("`@("`@("`@:68@;#IC;VYC96%L961;,%T@/3TC
M(#`@?'P@;#IC;VYC96%L961;,5T@(3TC("<G"B`@("`@("`@("`@("`@("`@
M("`@;&5T(&PZ8V]L=6UN("L](#$*("`@("`@("`@("`@("`@(&5N9&EF"@H@
M("`@("`@("`@("`@("`@;&5T(&PZ;F5W;&EN92`N/2!C"B`@("`@("`@("`@
M(&5N9&EF"@H@("`@("`@("`@("!L970@;#IL:6YE<&]S("L](#$*("`@("`@
M("!E;F1F;W(*"B`@("`@("`@8V%L;"!S971L:6YE*&PZ;&YU;2P@;#IN97=L
M:6YE*0H*("`@("`@("!L970@;#IL;G5M(#T@<V5A<F-H*"=<="<I"B`@("!E
M;F1W:&EL90H*("`@(&-A;&P@<V5T<&]S*"<N)RP@;#IC=7)R96YT7V-U<G-O
*<BD*96YD9G5N"@``
M;&P@0V]N8V5A;%)E=&%B(T-O;F-E86Q2971A8B@I"@IF=6YC=&EO;B$@0V]N
M8V5A;%)E=&%B(T-O;F-E86Q2971A8B@I"B`@("!L970@;#IC=7)R96YT7V-U
M<G-O<B`](&=E='!O<R@G+B<I"@H@("`@8V%L;"!C=7)S;W(H,2PQ*0H*("`@
M(&QE="!L.FQN=6T@/2!S96%R8V@H)UQT)RD*"B`@("!W:&EL92!L.FQN=6T@
M(3TC(#`*("`@("`@("!L970@;#IN97=L:6YE(#T@)R<*("`@("`@("!L970@
M;#IC;VQU;6X@(#T@,`H@("`@("`@(&QE="!L.FQI;F5P;W,@/2`Q"@H@("`@
M("`@(&9O<B!L.F,@:6X@<W!L:70H9V5T;&EN92@G+B<I+"`G7'IS)RD*("`@
M("`@("`@("`@:68@;#IC(#T](R`B7'0B"B`@("`@("`@("`@("`@("!L970@
M;#IS<&%C97,@("`](#@@+2`H;#IC;VQU;6X@)2`X*0H@("`@("`@("`@("`@
M("`@;&5T(&PZ8V]L=6UN("`K/2!L.G-P86-E<PH*("`@("`@("`@("`@("`@
M(&QE="!L.FYE=VQI;F4@+CT@<F5P96%T*"<@)RP@;#IS<&%C97,I"B`@("`@
M("`@("`@(&5L<V4*("`@("`@("`@("`@("`@(&QE="!L.F-O;F-E86QE9"`]
M('-Y;F-O;F-E86QE9"AL.FQN=6TL(&PZ;&EN97!O<RD*"B`@("`@("`@("`@
M("`@("!I9B!L.F-O;F-E86QE9%LP72`]/2,@,"!\?"!L.F-O;F-E86QE9%LQ
M72`A/2,@)R<*("`@("`@("`@("`@("`@("`@("!L970@;#IC;VQU;6X@*ST@
M,0H@("`@("`@("`@("`@("`@96YD:68*"B`@("`@("`@("`@("`@("!L970@
M;#IN97=L:6YE("X](&,*("`@("`@("`@("`@96YD:68*"B`@("`@("`@("`@
M(&QE="!L.FQI;F5P;W,@*ST@,0H@("`@("`@(&5N9&9O<@H*("`@("`@("!C
M86QL('-E=&QI;F4H;#IL;G5M+"!L.FYE=VQI;F4I"@H@("`@("`@(&QE="!L
M.FQN=6T@/2!S96%R8V@H)UQT)RD*("`@(&5N9'=H:6QE"@H@("`@8V%L;"!S
D971P;W,H)RXG+"!L.F-U<G)E;G1?8W5R<V]R*0IE;F1F=6X*
`
end
EOF
Expand Down

0 comments on commit 8bab382

Please sign in to comment.