Subject: [bug#77387] [PATCH 0/2] man-db: Better parsing of man macros.

From: Sergey Trofimov <[email-masked]>
Date: Sun, 30 Mar 2025 16:25:46 +0200

Hey guix, I've noticed that quite a lot man pages are reported to belong to a wrong section by `man -k`:

--8<---------------cut here---------------start------------->8---
$ man -k "" | grep "(0)"
...
ssh-pkcs11-helper (0) - (unknown subject)
ssh-sk-helper (0)    - (unknown subject)
ssh_config (0)       - (unknown subject)
sshd (0)             - (unknown subject)
sshd_config (0)      - (unknown subject)
sudo (0)             - (unknown subject)
sudo.conf (0)        - (unknown subject)
tc-cgroup (0)        - control group based traffic control filter
tc-connmark (0)      - (unknown subject)
...
--8<---------------cut here---------------end--------------->8---

A side-effect of it is that `M-x man` doesn't list such pages in auto-completion. I've attempted to fix that, see the following patch.

With the patch `man -k` and `M-x man` work properly:

--8<---------------cut here---------------start------------->8---
$ man -k sudo
cvtsudoers (1)       - (unknown subject)
sudo (8)             - (unknown subject)
sudo.conf (5)        - (unknown subject)
sudo_logsrv.proto (5) - (unknown subject)
sudo_logsrvd (8)     - (unknown subject)
...
--8<---------------cut here---------------end--------------->8---

Note, that synopsis extraction also needs improvement, however it turns out to
be more complicated as proper formatting requires cleaning up / expanding macros.

Sergey Trofimov (2):
  man-db: Parse man macro arguments better.
  man-db: Support mdoc-formatted man pages.

 guix/man-db.scm | 52 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 9 deletions(-)

base-commit: 2ed28b5c24c599b2f9bc60dfc93151cf489ca477
-- 
2.49.0