Lacking Natural Simplicity

Random musings on books, code, and tabletop games.

Making a newer version of groff work with man and emacs on macOS

I'm posting this mostly to remind myself if I ever have to fiddle with this again.

I use a version of groff installed from git because some of my documents depend on fixes that are coming out in the next release, 1.23.0. I install it on my macOS machine in /usr/local/sw/versions/groff/git. (The directory hierarchy under /usr/local/sw/versions is where I put programs that I compile from scratch, to keep them separated from the programs that come from the operating system and/or package managers. I often have more than one version of a program installed, therefore the versions component of the name.)

Because the groff that is first in my path is the new one I installed, and because man on macOS knows to look for man pages according to what your PATH is, when I say man groff_ms I get the new man page for groff_ms. Yay! Unfortunately, it gets rendered with the old groff that macOS supplies, version 1.19.2, which doesn't include the .SY macro that current versions of groff supply in their man macros, and which they use in their man pages, so it renders wrong. A typical example is that when it renders groff_ms(7) the groff -ms and groff -m ms are missing from the lines in the SYNOPSIS section. Boo!

Luckily, man takes a -C option that lets you specify an alternate configuration file (on macOS the default one is in /private/etc/man.conf), so you can supply one that specifies the absolute path to the newer groff you are using. So I added

alias man='man -C ~/local/etc/man.conf'

to the appropriate shell startup file. And I can add

(setq Man-switches "-C ~/local/etc/man.conf")

to my emacs configuration so it uses the right version of groff too.

But a modern groff produces ANSI escapes for bold and underline, rather than the older convention of over-striking via the backspace character with the same character for bold or with the underscore character for underlining. My pager, less, can deal with that, but something in emacs doesn't like that, leaving the buffer with groff_ms(7) with underlining on every line.[1]

Eventually I figured out that the old style over-striking via backspaces worked just fine with emacs, so I added the -P-c option to the invocation of groff in the NROFF definition in my modified man.conf file. That tells groff to pass the -c option to the grotty output driver, which tells it to use old-style backspace over-striking.

This seems overly complicated.

I suspect I'll need to do something different on the Linux boxes I use.


Aannnd I was right. Fedora 33 has a similar problem, which I fixed by creating a ~/.manpath file with

DEFINE       nroff   /sw/versions/groff/git/bin/nroff -mandoc -P-c

in it. I found the information I needed in manpath(5), which documents the format of the /etc/man_db.conf file. (Why isn't it man_db.conf(5), then?)

Last edited: 2021-09-09 10:11:03 EDT

Print Friendly and PDF


Comments powered by Disqus