aboutsummaryrefslogtreecommitdiff
path: root/g.tmac
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-20 22:57:57 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-20 23:56:28 +0200
commit195edc5e418fa7383bd7882a3b53fe76811e288a (patch)
tree299998bc1108e83fb18064bac39bb9610a7ec524 /g.tmac
parent7dcca5ce75b007eb06adacc59f744d6691b529a2 (diff)
downloadmk-195edc5e418fa7383bd7882a3b53fe76811e288a.tar.gz
Add w (want space) macro
It takes, as its arguments, a specification describing the amount of space desired. .w s p requests space for a subheading and a paragraphs line. .w s pp requests space for a subheading and TWO paragraph lines.
Diffstat (limited to 'g.tmac')
-rw-r--r--g.tmac32
1 files changed, 30 insertions, 2 deletions
diff --git a/g.tmac b/g.tmac
index 3739c8d..3fda230 100644
--- a/g.tmac
+++ b/g.tmac
@@ -286,7 +286,7 @@ ___________________
.\" h -- heading
.de h
. br
-. ne 3 \" may need to be adjusted
+. w h p
. _e h
.
..
@@ -306,7 +306,7 @@ ___________________
.\" s -- subheading
.de s
. br
-. ne 3 \" may need to be adjusted
+. w s p
. _e s
..
.
@@ -349,4 +349,32 @@ ___________________
. if !'\n(dn'0' .wh -\n[_dn]u-\n(mbu-12p _tn
..
.
+. \" w -- want space
+.de w
+. br
+. *w 0 \$@
+..
+.de *w
+. nr s \$1 \" accumulated space
+. length n \$2 \" number of lines in environment
+. ds __e \$2 \" environment
+. nr n -1
+. substring __e 0 0
+.
+. \" add environment sp/sq
+. nr s +\n[\*[__e]_sp]
+. nr s +\n[\*[__e]_sq]
+.
+. \" add environment vs
+. _E \*[__e]
+. nr _v \n(.v
+. _E
+. nr s +(\nn*\n(_v)
+. shift 2
+.
+. \" request space or recurse
+. ie \n(.$=0 .ne \nsu
+. el .*w \ns \$@
+..
+.
.ec \" re-enable backslash escapes