Path: utzoo!utgpu!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ARISIA.XEROX.COM!cutting From: cutting@ARISIA.XEROX.COM (Doug Cutting) Newsgroups: comp.sys.xerox Subject: Re: Changing fonts to differentiate comments from code Message-ID: <8905242103.AA00581@bopp.parc.xerox.com> Date: 24 May 89 21:03:17 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 51 Date: 23 May 89 09:15:31 GMT From: gupta%prlhp1.uucp%idec.uucp%stl.uucp%ukc.uucp%mcvax.uucp (gupta) What I want is for comments to appear in a different font to code. Therefore typing #| or ; must change the font and typing |# or hitting must reset the font. (Of course hitting after having typed #| should not reset the font). I've tried to set traces on some low-level read and write routines so as to determine which routines could be advised to set/reset the font. That's the wrong approach. A better approach is to make a readtable in which ";" is defined to, rather than ignoring the text after it, reads it in as an object. The print method for these objects can then do the font changes. E.g.: (defstruct (comment (:print-function print-comment)) contents) (defvar *comment-readtable* (copy-readtable)) (set-macro-character #\; #'(lambda (stream char) (declare (ignore char)) (make-comment :contents (read-line stream))) *comment-readtable*) (defun print-comment (comment stream depth) (declare (ignore depth)) ;; need the somehow set the font here (format stream ";~A" (comment-contents comment))) (defun pp-file (file &optional (to-stream *standard-output*)) (with-open-file (stream file) (let ((*readtable* *comment-readtable*) (eof (list nil))) (loop (let ((form (read stream nil eof))) (when (eq form eof) (return)) (pprint form to-stream)))))) Of course this is really fairly useless, as you'll not see the font changes in the editor, where you most often look at code. Perhaps if you had a structure editor and an interpreter & compiler which knew to strip comment structures and a database of definitions . . . Doug