Subject: Re: bug#77944: 31.0.50; M-x man on macOS fails with error

From: David Caldwell <[email-masked]>
Date: Sun, 15 Jun 2025 12:21:29 -0700

> From: Eli Zaretskii <eliz <at> gnu.org>
> To: Przemysław Kryger <pkryger <at> gmail.com>
> Cc: 77944 <at> debbugs.gnu.org, gerd.moellmann <at> gmail.com, michael.albinus <at> gmx.de
> Subject: Re: bug#77944: 31.0.50; M-x man on macOS fails with error
> Date: Fri, 30 May 2025 07:42:38 +0300
>
> > Date: Thu, 29 May 2025 17:40:35 +0100
> > From: Przemysław Kryger <pkryger <at> gmail.com>
> > CC: gerd.moellmann <at> gmail.com, eliz <at> gnu.org
> 
> > I can see the fix (fc5e905dc90e21b1a381bde42e22c06f45c17e16) is contained in
> > branch master, but it's not in branch emacs-30 yet.  Does it mean it's not
> > planned to be included in Emacs-30.2 (or Emacs-30.3)?
>
> Indeed, we don't plan to have the fix in Emacs 30.2.  The change is
> not simple, and the handling of system-dependent idiosyncrasies in
> "M-x man" is delicate and fragile, so we prefer not to risk any
> breakage there.

What about something more surgical, like:

diff --git a/lisp/man.el b/lisp/man.el
index dcfab8d2035..060c3f99916 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -650,9 +650,11 @@ Man-init-defvars
 	     (if Man-sed-script
 		 (concat "-e '" Man-sed-script "'")
 	       "")
-             ;; Use octal numbers.  Otherwise, \032 (Ctrl-Z) would
-             ;; suspend remote connections.
-	     "-e '/^[\\o001-\\o032][\\o001-\\o032]*$/d'"
+             (if (eq system-type 'darwin)
+                 ;; Darwin sed doesn't support \o notation.
+                 "-e '/^[[:cntrl:]][[:cntrl:]]*$/d'"
+               ;; Use octal numbers.  Otherwise, \032 (Ctrl-Z) would
+               ;; suspend remote connections.
+	       "-e '/^[\\o001-\\o032][\\o001-\\o032]*$/d'")
 	     "-e '/\e[789]/s///g'"
 	     "-e '/Reformatting page.  Wait/d'"
 	     "-e '/Reformatting entry.  Wait/d'"

That way it only impacts darwin users (which are totally without it).

I'd love to not have to patch emacs or install an alternative sed...

Thanks,
  David