Subject: bug#54745: Subject: 28.1; woman fails on "file"

From: Andreas Röhler <[email-masked]>
Date: Wed, 6 Apr 2022 17:47:04 +0200

Am 06.04.22 um 13:14 schrieb Eli Zaretskii:
>> Date: Wed, 6 Apr 2022 11:20:52 +0200
>> From: Andreas Röhler<[email-masked]>
>>
>> M-x woman RET file RET
>>
>> errors saying:
>>
>> Debugger entered--Lisp error: (error "WoMan can only format man pages
>>    written with the usual ‘-man’ macros") signal(error ("WoMan can only
>>    format man pages written with the usual ‘-man’ macros"))
>>    error("WoMan can only format man pages written with the usual `-man'
>>    macros") woman-decode-region(1 21597) woman-decode-buffer()
>>    woman-process-buffer()
>>    woman-really-find-file("/usr/share/man/man1/file.1.gz" t "*WoMan 1
>>    file*<2>") woman-find-file("/usr/share/man/man1/file.1.gz")
>>
>> However from bash, manpage appears correctly.
>> Also would read nicely from:  "man file > file.txt"
> woman.el doesn't use the 'man' program.  It is implemented completely
> in Emacs Lisp.  So what 'man' does is not really relevant; what _is_
> relevant is that Someone(TM) should step up and volunteer to keep
> woman.el up-to-date with all the recent advances in roff markup.
> Until that happens, the error you see above is intentional, meant to
> alert you, the user, to the fact that the man page cannot be reliably
> formatted this way.

That workaround attached does it here.
diff --git a/lisp/woman.el b/lisp/woman.el
index c0c8f34348..2f923c5455 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1644,7 +1644,9 @@ woman-really-find-file
     (setq default-directory (file-name-directory filename))
     (setq-local backup-inhibited t)
     (set-visited-file-name "")
-    (woman-process-buffer)))
+    (or (ignore-errors (woman-process-buffer))
+        (erase-buffer) 
+        (shell-command (concat "man " (replace-regexp-in-string "^\\([^\\.]+\\).\\(.*\\)" "\\1" (file-name-nondirectory (file-name-sans-extension filename)))) bufname))))
 
 (defun woman-process-buffer ()
   "The second half of `woman-really-find-file'!"