aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-03-10 04:12:44 +0000
committerGlenn Morris2007-03-10 04:12:44 +0000
commita353f3f408f29729cdf3aa7faeb99e9eb220af61 (patch)
tree8e5198383838a9b4192156f1306ff4081cdcdbcc
parenteebe9a296e7e7700b88373bfa2d44ec5e7c23076 (diff)
downloademacs-a353f3f408f29729cdf3aa7faeb99e9eb220af61.tar.gz
emacs-a353f3f408f29729cdf3aa7faeb99e9eb220af61.zip
(woman-change-fonts): Add a hack to deal with
font-escape followed by "." at start of a line. (woman2-IP): Add a hack to deal with consecutive requests. (woman2-tagged-paragraph): Extend existing hack to handle "sp".
-rw-r--r--lisp/woman.el127
1 files changed, 80 insertions, 47 deletions
diff --git a/lisp/woman.el b/lisp/woman.el
index 728bf347d9f..9c73a365b61 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -3284,7 +3284,7 @@ If optional arg CONCAT is non-nil then join arguments."
3284 ;; Find font requests, paragraph macros and font escapes: 3284 ;; Find font requests, paragraph macros and font escapes:
3285 (re-search-forward 3285 (re-search-forward
3286 "^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1) 3286 "^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
3287 (let (font beg notfont) 3287 (let (font beg notfont fescape)
3288 ;; Match font indicator and leave point at end of sequence: 3288 ;; Match font indicator and leave point at end of sequence:
3289 (cond ((match-string 2) 3289 (cond ((match-string 2)
3290 ;; .ft request found 3290 ;; .ft request found
@@ -3299,7 +3299,8 @@ If optional arg CONCAT is non-nil then join arguments."
3299 (setq font 'default)) 3299 (setq font 'default))
3300 ((match-string 4) 3300 ((match-string 4)
3301 ;; \f escape found 3301 ;; \f escape found
3302 (setq beg (match-beginning 0)) 3302 (setq beg (match-beginning 0)
3303 fescape t)
3303 (woman-match-name)) 3304 (woman-match-name))
3304 (t (setq notfont t))) 3305 (t (setq notfont t)))
3305 (if notfont 3306 (if notfont
@@ -3321,6 +3322,13 @@ If optional arg CONCAT is non-nil then join arguments."
3321 ;; Delete font control line or escape sequence: 3322 ;; Delete font control line or escape sequence:
3322 (cond (beg (delete-region beg (point)) 3323 (cond (beg (delete-region beg (point))
3323 (if (eq font 'previous) (setq font previous-font)))) 3324 (if (eq font 'previous) (setq font previous-font))))
3325 ;; Deal with things like \fB.cvsrc\fR at the start of a line.
3326 ;; After removing the font control codes, this would
3327 ;; otherwise match woman-request-regexp. The "\\&" which is
3328 ;; inserted to prevent this is removed by woman2-process-escapes.
3329 (and fescape
3330 (looking-at "^\\.")
3331 (insert "\\&"))
3324 (woman-set-face previous-pos (point) current-font) 3332 (woman-set-face previous-pos (point) current-font)
3325 (if beg 3333 (if beg
3326 ;; Explicit font control 3334 ;; Explicit font control
@@ -3665,39 +3673,39 @@ expression in parentheses. Leaves point after the value."
3665 (unwind-protect 3673 (unwind-protect
3666 (while 3674 (while
3667 ;; Find next control line: 3675 ;; Find next control line:
3668 (re-search-forward woman-request-regexp nil t) 3676 (re-search-forward woman-request-regexp nil t)
3669 (cond 3677 (cond
3670 ;; Construct woman function to call: 3678 ;; Construct woman function to call:
3671 ((setq fn (intern-soft 3679 ((setq fn (intern-soft
3672 (concat "woman2-" 3680 (concat "woman2-"
3673 (setq request (match-string 1))))) 3681 (setq request (match-string 1)))))
3674 ;; Delete request or macro name: 3682 ;; Delete request or macro name:
3675 (woman-delete-match 0)) 3683 (woman-delete-match 0))
3676 ;; Unrecognised request: 3684 ;; Unrecognised request:
3677 ((prog1 nil 3685 ((prog1 nil
3678 ;; (WoMan-warn ".%s request ignored!" request) 3686 ;; (WoMan-warn ".%s request ignored!" request)
3679 (WoMan-warn-ignored request "ignored!") 3687 (WoMan-warn-ignored request "ignored!")
3680 ;; (setq fn 'woman2-LP) 3688 ;; (setq fn 'woman2-LP)
3681 ;; AVOID LEAVING A BLANK LINE! 3689 ;; AVOID LEAVING A BLANK LINE!
3682 ;; (setq fn 'woman2-format-paragraphs) 3690 ;; (setq fn 'woman2-format-paragraphs)
3683 )) 3691 ))
3684 ;; .LP assumes it is at eol and leaves a (blank) line, 3692 ;; .LP assumes it is at eol and leaves a (blank) line,
3685 ;; so leave point at end of line before paragraph: 3693 ;; so leave point at end of line before paragraph:
3686 ((or (looking-at "[ \t]*$") ; no argument 3694 ((or (looking-at "[ \t]*$") ; no argument
3687 woman-ignore) ; ignore all 3695 woman-ignore) ; ignore all
3688 ;; (beginning-of-line) (kill-line) 3696 ;; (beginning-of-line) (kill-line)
3689 ;; AVOID LEAVING A BLANK LINE! 3697 ;; AVOID LEAVING A BLANK LINE!
3690 (beginning-of-line) (woman-delete-line 1)) 3698 (beginning-of-line) (woman-delete-line 1))
3691 (t (end-of-line) (insert ?\n)) 3699 (t (end-of-line) (insert ?\n))
3692 ) 3700 )
3693 (if (not (or fn 3701 (if (not (or fn
3694 (and (not (memq (following-char) '(?. ?'))) 3702 (and (not (memq (following-char) '(?. ?')))
3695 (setq fn 'woman2-format-paragraphs)))) 3703 (setq fn 'woman2-format-paragraphs))))
3696 () 3704 ()
3697 ;; Find next control line: 3705 ;; Find next control line:
3698 (set-marker to (woman-find-next-control-line)) 3706 (set-marker to (woman-find-next-control-line))
3699 ;; Call the appropriate function: 3707 ;; Call the appropriate function:
3700 (funcall fn to))) 3708 (funcall fn to)))
3701 (if (not (eobp)) ; This should not happen, but ... 3709 (if (not (eobp)) ; This should not happen, but ...
3702 (woman2-format-paragraphs (copy-marker (point-max) t) 3710 (woman2-format-paragraphs (copy-marker (point-max) t)
3703 woman-left-margin)) 3711 woman-left-margin))
@@ -4193,7 +4201,27 @@ If tag doesn't fit, place it on a separate line."
4193 (let ((i (woman2-get-prevailing-indent 'leave-eol))) 4201 (let ((i (woman2-get-prevailing-indent 'leave-eol)))
4194 (beginning-of-line) 4202 (beginning-of-line)
4195 (woman-leave-blank-lines) ; must be here, 4203 (woman-leave-blank-lines) ; must be here,
4196 (woman2-tagged-paragraph to i)))) 4204 ;;
4205 ;; The cvs.1 manpage contains some (possibly buggy) syntax that
4206 ;; confuses woman, although the man program displays it ok.
4207 ;; Most problems are caused by IP followed by another request on
4208 ;; the next line. Without the following hack, the second request
4209 ;; gets displayed raw in the output. Note that
4210 ;; woman2-tagged-paragraph also contains a hack for similar
4211 ;; issues (eg IP followed by SP).
4212 ;;
4213 ;; i) For IP followed by one or more IPs, we ignore all but the
4214 ;; last (mimic man). The hack in w-t-p would only work for two
4215 ;; consecutive IPs, and would use the first.
4216 ;; ii) For IP followed by SP followed by one or more requests,
4217 ;; do nothing. At least in cvs.1, there is usually another IP in
4218 ;; there somewhere.
4219 (unless (or (looking-at "^\\.IP")
4220 (and (looking-at "^\\.sp")
4221 (save-excursion
4222 (and (zerop (forward-line 1))
4223 (looking-at woman-request-regexp)))))
4224 (woman2-tagged-paragraph to i)))))
4197 4225
4198(defun woman-find-next-control-line-carefully () 4226(defun woman-find-next-control-line-carefully ()
4199 "Find and return start of next control line, even if already there!" 4227 "Find and return start of next control line, even if already there!"
@@ -4208,17 +4236,21 @@ Format paragraphs upto TO. Set prevailing indent to I."
4208 (if (not (looking-at "\\s *$")) ; non-empty tag 4236 (if (not (looking-at "\\s *$")) ; non-empty tag
4209 (setq woman-leave-blank-lines nil)) 4237 (setq woman-leave-blank-lines nil))
4210 4238
4211 ;; Temporary hack for bash.1 and groff_mmse.7 until code is revised 4239 ;; Temporary hack for bash.1, cvs.1 and groff_mmse.7 until code is revised
4212 ;; to process all requests uniformly: 4240 ;; to process all requests uniformly.
4213 (cond ((and (= (point) to) (looking-at "^[.'][ \t]*\\(PD\\|br\\|ta\\) *")) 4241 ;; This hack deals with IP requests followed by other requests (eg
4214 (if (string= (match-string 1) "br") 4242 ;; SP) on the very next line. We skip over the SP, otherwise it gets
4215 (woman-delete-line 1) 4243 ;; inserted raw in the rendered output.
4216 (woman-delete-match 0) 4244 (cond ((and (= (point) to)
4217 (if (string= (match-string 1) "ta") ; for GetInt.3 4245 (looking-at "^[.'][ \t]*\\(PD\\|br\\|ta\\|sp\\) *"))
4218 (woman2-ta to) 4246 (if (member (match-string 1) '("br" "sp"))
4219 (woman-set-interparagraph-distance))) 4247 (woman-delete-line 1)
4220 (set-marker to (woman-find-next-control-line-carefully)) 4248 (woman-delete-match 0)
4221 )) 4249 (if (string= (match-string 1) "ta") ; for GetInt.3
4250 (woman2-ta to)
4251 (woman-set-interparagraph-distance)))
4252 (set-marker to (woman-find-next-control-line-carefully))
4253 ))
4222 4254
4223 (let ((tag (point))) 4255 (let ((tag (point)))
4224 (woman-reset-nospace) 4256 (woman-reset-nospace)
@@ -4274,6 +4306,7 @@ Delete line from point and eol unless LEAVE-EOL is non-nil."
4274 (let ((i (woman-get-numeric-arg))) 4306 (let ((i (woman-get-numeric-arg)))
4275 (woman-delete-line) (or leave-eol (delete-char 1)) 4307 (woman-delete-line) (or leave-eol (delete-char 1))
4276 ;; i = 0 if the argument was not a number 4308 ;; i = 0 if the argument was not a number
4309 ;; FIXME should this be >= 0? How else to reset to 0 indent?
4277 (if (> i 0) (setq woman-prevailing-indent i)))) 4310 (if (> i 0) (setq woman-prevailing-indent i))))
4278 woman-prevailing-indent) 4311 woman-prevailing-indent)
4279 4312