Hacking FreeBSD to change manual page width

I don’t like the fixed width of manual pages, since I have such a wide terminal, but the man pages only occupied the left part.
By inspecting the process launched, it seems like that there are several processes related:
sh -c (cd /usr/share/man/en.UTF-8 ; /usr/bin/zcat /usr/share/man/en.UTF-8/man1/ls.1.gz | /usr/bin/tbl | /usr/bin/groff -S -Wall -mtty-char -man -Tutf8 | /usr/bin/col | less)
I tried to skip the most processes, and simplify the calling sequence, and finally I found that the most important process is groff.
After unzipped the ls.1.gz, I found that there’s no clear marks of line ending. This encouraged me, since this makes possible to adjust the output width in later steps.
I did some experiments, and I found that the -man and -Tutf8 arguments are critical to the page width. I read the man page of groff, and found that if -Tutf8 is specified, then groff use grotty as postprocessor. I turned to the man page of grotty, but found nothing useful. However, the man page of groff_man supplied useful information: -rIN seems hopeful.
However, when I tried -rIN=130, the output is nothing different from the original. Finally, I turned to Google, and found this post: http://www.cygwin.com/ml/cygwin/2004-11/msg01003.html
So I know that first I should use -rLL and -rLT, and secondly I should use 130n instead of 130.
After adding these to the command line, the output looked like what I wanted. I want to automate the process, so I tried a method similar to the one in the post: changing the source of man by hand.
I greped and found /usr/src/gnu/usr.bin/man/Makefile.inc is the source of the command arguments. However, changing this is not so easy, since it would be interpreted by sed, and then by sh. So I changed /usr/src/gnu/usr.bin/man/lib/config.h instead. With some experiments, finally it worked. I added  -rLL=`echo $MANWIDTH`n -rLT=`echo $MANWIDTH`n into #define NROFF.
The last thing to do is to set MANWIDTH. I Googled about finding terminal width, and found this:
It is said that `tput cols` would do the work, and really it worked.
So I added setenv MANWIDTH `tput cols` into ~/.cshrc, and everything worked like a charm~
Now I can fully utilize my screen width!~

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.