Subject: bug#11552: 23.4; woman.el bold \e

From: Kevin Ryde <[email-masked]>
Date: Thu, 24 May 2012 11:32:54 +1000

With the esc-face.1 below,

    (woman-find-file "esc-face.1")

produces

     bold \ backslash

with the "\" not in bold, where I expected it would be (man-db+groff
makes it bold).

I think woman.el.esc-face.diff below could correct this.

2012-05-24  Kevin Ryde  <[email-masked]>

	* woman.el (woman-decode-region): Replace escaped-escapes using
	`subst-char-in-region' so bold or underline on \e is preserved.

I struck this in some perl pod2man output.  It uses \e for backslashes
in "verbatim" output paragraphs (bits of sample code usually).  Those
parts are in ".ft CW" font, which comes out of woman.el as woman-unknown
face (which is red).  But the face wasn't on the backslashes.

.TH FOO 1
.SH NAME
.B
bold \e backslash
--- woman.el.orig	2012-05-19 12:08:35.000000000 +1000
+++ woman.el	2012-05-24 07:09:48.000000000 +1000
@@ -2394,17 +2394,20 @@
 	(woman-negative-vertical-space from))
 
     (if woman-preserve-ascii
-	;; Re-instate escaped escapes to just `\' and unpaddable
-	;; spaces to just `space', without inheriting any text
-	;; properties.  This is not necessary, UNLESS the buffer is to
-	;; be saved as ASCII.
+	;; Re-instate escaped escapes to just `\' and unpaddable spaces to
+	;; just `space'.  This is not necessary for display since there's
+	;; display table entries for the escaped chars, but it is necessary
+	;; if the buffer might be saved as ASCII.
+	;;
+	;; `subst-char-in-region' preserves text properties on the
+	;; characters, which is necessary for bold, underline, etc on \e.
+	;; There's usually no face on spaces, but if there is then it's good
+	;; to keep that too.
 	(progn
-	  (goto-char from)
-	  (while (search-forward woman-escaped-escape-string nil t)
-	    (delete-char -1) (insert ?\\))
-	  (goto-char from)
-	  (while (search-forward woman-unpadded-space-string nil t)
-	    (delete-char -1) (insert ?\ ))))
+          (subst-char-in-region from (point-max)
+                                woman-escaped-escape-char ?\\)
+          (subst-char-in-region from (point-max)
+                                woman-unpadded-space-char ?\ )))
 
     ;; Must return the new end of file if used in format-alist.
     (point-max)))

In GNU Emacs 23.4.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-04-08 on biber, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.4/site-lisp:/usr/share/emacs/site-lisp' '--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -DDEBIAN -O2' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''