Subject: Re: Format conundrum...
From: Erik Naggum <>
Date: 1999/02/08
Newsgroups: comp.lang.lisp
Message-ID: <>

* "Frederick C. Gibson, Architect" <>
| I have a lisp program with the following function that uses format:
| (defun format-concept (concept &key ((:stream stream) t))
|  (format stream "~a~20t~a~39t~a~57t~a~&"
|     (capitalize(name concept))
|     (capitalize(part-of-speech concept))
|     (capitalize(first(genus concept)))
|     (mapcar #'downcase (mapcar #'first (differentia concept)))))

  case manipulation is part of FORMAT's rich language and it does not cons,
  which your function does quite a bit of.  may I suggest

(defun format-concept (concept &key (stream t))
  (format stream "~@(~A~)~20T~@(~A~)~39T~@(~A~)~57T~(~A~)~&"
	  (name concept)
	  (part-of-speech concept)
	  (first (genus concept))
	  (mapcar #'first (differentia concept))))

  it could also be that you're better off not writing the list as such, but
  using the iterator construct, as in

(defun format-concept (concept &key (stream t))
  (format stream "~@(~A~)~20T~@(~A~)~39T~@(~A~)~57T~(~{~A~^ ~}~)~&"
	  (name concept)
	  (part-of-speech concept)
	  (first (genus concept))
	  (mapcar #'first (differentia concept))))

| What I would like to have happen is to have the differentia all print out
| on the same line rather than printing one word per line when the whole
| line exceeds 80 characters.

  the right margin is controlled by the *PRINT-RIGHT-MARGIN* variable, and
  filling normally happens during printing of well-known object types such
  as lists because a number of useful things happen to pretty-printed code.
  if you turn off pretty-printing, the right margin no longer matters.
  pretty-printing is controlled by *PRINT-PRETTY*.

  the particular way in which you saw the lines wrap near the right margin
  is called miser-mode, and is in effect for objects started less than
  *PRINT-MISER-WIDTH* columns from the right margin.  you can set this
  variable to NIL and see that the words no longer line up vertically, but
  fill normally.

  see the HyperSpec for the gory details on FORMAT.


  Y2K conversion simplified: Januark, Februark, March, April, Mak, June,
  Julk, August, September, October, November, December.