Function: woman-strings

woman-strings is a byte-compiled function defined in woman.el.gz.

Signature

(woman-strings &optional TO)

Documentation

Process ?roff string requests and escape sequences up to buffer position TO.

Strings are defined/updated by .ds xx string requests and interpolated by \*x and \*(xx escapes.

Source Code

;; Defined in /usr/src/emacs/lisp/woman.el.gz
(defun woman-strings (&optional to)
  "Process ?roff string requests and escape sequences up to buffer position TO.
Strings are defined/updated by `.ds xx string' requests and
interpolated by `\\*x' and `\\*(xx' escapes."
  ;; Add support for .as and .rm?
  (while
      ;; Find .ds requests and \* escapes:
      (re-search-forward "\\(^[.'][ \t]*ds\\)\\|\\\\\\*" to t)
    (cond ((match-beginning 1)		; .ds
	   (skip-chars-forward " \t")
	   (if (eolp)			; ignore if no argument
	       ()
	     (re-search-forward "[^ \t\n]+")
	     (let ((string (match-string 0)))
	       (skip-chars-forward " \t")
	       (if (= ?\" (following-char))
		   ;; Double-quote starts a string, eg.
		   ;;   .ds foo "blah...
		   ;; is value blah... through to newline.  There's no
		   ;; closing " (per the groff manual), but rather any
		   ;; further " is included literally in the string.  Eg.
		   ;;   .ds foo ""
		   ;; sets foo to a single " character.
		   (forward-char))
	       (setq string (cons string
				  (buffer-substring (point)
						    (line-end-position))))
	       ;; This should be an update, but consing a new string
	       ;; onto the front of the alist has the same effect:
	       (setq woman-string-alist (cons string woman-string-alist))
	       ))
	   (beginning-of-line)
	   (woman-delete-line 1))
	  (t				; \*
	   (let ((beg (match-beginning 0)))
	     (woman-match-name)
	     (let* ((stringname (match-string 0))
		   (string (assoc stringname woman-string-alist)))
	       (cond (string
		      (delete-region beg (point))
		      ;; Temporary hack in case string starts with a
		      ;; control character:
		      (if (bolp) (insert-before-markers "\\&"))
		      (insert-before-markers (cdr string)))
		     (t
		      (WoMan-warn "Undefined string %s not interpolated!"
			       stringname)
		      (cond (woman-ignore
			     ;; Output above message once only per call
			     (delete-region beg (point))
			     (setq woman-string-alist
				   (cons (cons stringname "")
					 woman-string-alist))))))))))))