~theorytoe/mman

adafa4502e43cde8d530d863a886418379de9e90 — theorytoe 6 months ago 342323c
add: view only views first page it finds
3 files changed, 42 insertions(+), 31 deletions(-)

M mman
M no-scdoc.patch
M no-troff.patch
M mman => mman +6 -2
@@ 16,10 16,10 @@ ACTION=view
[ -d "$SRCDIR" ] || mkdir -p "$SRCDIR"

# add coloring to manpages
export LESS_TERMCAP_md=$(tput bold; tput setaf 2)
export LESS_TERMCAP_md=$(tput bold; tput setaf 4)
export LESS_TERMCAP_me=$(tput sgr0)
export LESS_TERMCAP_mb=$(tput blink)
export LESS_TERMCAP_us=$(tput smul; tput setaf 1)
export LESS_TERMCAP_us=$(tput smul; tput setaf 2)
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
export LESS_TERMCAP_so=$(tput smso)
export LESS_TERMCAP_se=$(tput rmso)


@@ 100,16 100,20 @@ viewman() {
		if [ -f "$file" ]; then
			if istty; then
				man -mandoc "$file"
				return $?
			else
				man -mandoc "$file"
				return $?
			fi
		fi
		file=${MMANDIR}/$1.$i.txt
		if [ -f "$file" ]; then
			if istty; then
				$PAGER "$file"
				return $?
			else
				cat "$file"
				return $?
			fi
		fi
	done

M no-scdoc.patch => no-scdoc.patch +28 -11
@@ 1,5 1,5 @@
--- mman	2022-11-21 17:03:43.686944791 -0700
+++ mman.in	2022-11-21 17:02:17.936950039 -0700
--- mman	2022-11-21 17:51:33.263436013 -0700
+++ mman.in	2022-11-21 18:21:15.426660404 -0700
@@ -4,7 +4,6 @@
 # script for editing custom manual pages
 


@@ 8,7 8,7 @@
 EDITOR=${EDITOR:-nano}
 PAGER=${PAGER:-less}
 
@@ -63,29 +62,6 @@
@@ -63,37 +62,6 @@
 	done
 }
 


@@ 17,12 17,13 @@
-		file=${SRCDIR}/$1.$i.scd
-		if [ -f "$file" ]; then
-			"$EDITOR" "$file"
-			compilepage "$1" # compile manpages after edit
-			return $?
-		fi
-	done
-	for i in $SECTION; do
-		"$EDITOR" "${MMANDIR}/$1.$i.man"
-		compileman # compile manpages after edit
-		"$EDITOR" "${SRCDIR}/$1.$i.scd"
-		compilepage "$1" # compile manpages after edit
-		return $?
-	done
-}


@@ 31,14 32,21 @@
-compileman() {
-	for i in $(find $SRCDIR -type f); do
-		dest=${MMANDIR}/$(basename -s .scd $i).man
-		scdoc < $i > ${MMANDIR}/$(basename -s .scd $i).man
-		scdoc < $i > $dest
-	done
-}
-
-compilepage() {
-	echo "Compiling mmanpage $1($SECTION)"
-	dest=${MMANDIR}/$1.$SECTION.man
-	in=${SRCDIR}/$1.$SECTION.scd
-	scdoc < $in > $dest
-}
-
 viewman() {
 	for i in $SECTION; do
 		file=${MMANDIR}/$1.$i.man
@@ -109,11 +85,9 @@
@@ -121,11 +89,9 @@
 
 usage() {
 	cat << EOF


@@ 51,7 59,7 @@
     -l List available pages
 What mmanual do you want?
 EOF
@@ -129,13 +103,6 @@
@@ -141,13 +107,6 @@
 		-t)
 			ACTION=edittroff
 			shift;;


@@ 65,7 73,16 @@
 		-l)
 			find ~/.mman/ -type f \
 				-exec sh -c "basename {} | rev | cut -d '.' -f3,2 | rev" ';' |\
@@ -169,13 +136,6 @@
@@ -166,8 +125,6 @@
 				view)
 					viewman "$1"
 					exit $?;;
-				compile)
-					exit $?;;
 				edit)
 					if ! istty; then
 						echo "Not running in a tty!"
@@ -182,13 +139,6 @@
 					fi
 					edittroff "$1"
 					exit $?;;


@@ 79,8 96,8 @@
 				*)
 					usage
 					exit 0;;
--- mman.1	2022-11-21 16:59:20.486960883 -0700
+++ mman.1.in	2022-11-21 17:04:25.196942251 -0700
--- mman.1	2022-11-21 18:22:50.483321264 -0700
+++ mman.1.in	2022-11-21 18:22:58.536654103 -0700
@@ -5,14 +5,14 @@
 
 .SH SYNPOSYS

M no-troff.patch => no-troff.patch +8 -18
@@ 1,5 1,5 @@
--- mman	2022-11-21 17:03:43.686944791 -0700
+++ mman.in	2022-11-21 17:05:36.633604551 -0700
--- mman	2022-11-21 17:51:33.263436013 -0700
+++ mman.in	2022-11-21 18:24:55.853313604 -0700
@@ -48,21 +48,6 @@
 	done
 }


@@ 22,7 22,7 @@
 editscdoc() {
 	for i in $SECTION; do
 		file=${SRCDIR}/$1.$i.scd
@@ -109,9 +94,8 @@
@@ -121,9 +106,8 @@
 
 usage() {
 	cat << EOF


@@ 33,7 33,7 @@
     -s Edit an scdoc manpage
     -c Compile scdoc manpages
     -l List available pages
@@ -126,9 +110,6 @@
@@ -138,9 +122,6 @@
 		-e)
 			ACTION=edit
 			shift;;


@@ 43,7 43,7 @@
 		-s)
 			ACTION=editscdoc
 			shift;;
@@ -162,13 +143,6 @@
@@ -175,13 +156,6 @@
 					fi
 					editman "$1"
 					exit $?;;


@@ 57,9 57,9 @@
 				editscdoc)
 					if ! istty; then
 						echo "Not running in a tty!"
--- mman.1	2022-11-21 16:59:20.486960883 -0700
+++ mman.1.in	2022-11-21 17:06:24.003601645 -0700
@@ -5,14 +5,14 @@
--- mman.1	2022-11-21 18:22:50.483321264 -0700
+++ mman.1.in	2022-11-21 18:25:26.483311724 -0700
@@ -5,7 +5,7 @@
 
 .SH SYNPOSYS
 .B mman


@@ 68,16 68,6 @@
 .RI [ section ]
 .I name
 
 .SH DESCRIPTION
-Create man pages for personal documentation using plaintext, \fBtroff\fR(1), and \fBscdoc\fR(1)
-syntax. Pages are organized by section, similar to traditional manpages, but without the strict
-requirement to conform to those standards. If a 
+Create man pages for personal documentation using plaintext and \fBscdoc\fR(1)
+syntax. Pages are organized by section, similar to traditional manpages, but
+without the strict requirement to conform to those standards. If a 
 .I secion
 Is not specified, new pages will default to secion 0, a non-standard section.
 
@@ -21,10 +21,6 @@
 Edit a txt man page.