[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing character styles from files.



    Date: Wed, 11 Dec 1991 15:21 PST
    From: TAIT@INTELLICORP.COM (Mark Tait)

    This has probably been asked before, but I couldn't find it in the
    archives.  We have a customer that wants to get some code written for
    TI and Symbolics and move some of it over to a Sun running Lucid lisp
    4.0.  He made a tar tape with the files on it, read it in on the Sun
    and noticed that character styles were in some files.  He also noticed
    that the files didn't have linefeeds in it.  Has anyone come up with a
    filter to strip character styles out of files, and anyone got a
    workaround for the linefeed problem.

I haven't seen the linefeed problem but you probably want to do the following
in (Gnu)Emacs
	M-X replace-string
	^Q^M
	^Q^J


    Thanks,

    Mark Tait
    -------


Barmar sent out a font-info-stripping GnuEmacs function a while back...


We have a system that we run on both Symbolics and Lucid, from the same
source.  The code below ignores the font changes (inter-word, not intra-word).
I also do
	(sys:add-debugger-binding '*readtable* *readtable*)
to have my top level readtable be passed down (so fonts are ignored when
I do compilations inside the debugger).

If you are using the ILISP interface (via Emacs), I have patches to it
to ignore font info when doing Meta-.

;;; -*- Mode: LISP; Syntax: Common-lisp; Package: USER; Base: 10 -*-

(in-package "USER")

;;; The intent of this is to allow Symbolics files with fonts to be used
;;; on another lisp system.

;;; Restriction:  Symbols must all be in one font (no font changing during the middle)

;;; Control-F is the Symbolics font character.
(defun ignore-symbolics-font-info (stream char)
  (declare (ignore char))
  (let ((char (read-char stream)))
    (cond ((char-equal char #\()
	   ;; This reads a character style.  Just ignore it
	   (unread-char #\( stream)
	   (read stream)
	   )
	  ((char-equal char (code-char 5 0 0))
	   (dotimes (i 10) (read-char stream))	;Read rest of password
	   (setq char (read-char stream))
	   (unless (char-equal char (code-char 2 0 0))
	     (error "Unknown font info level after font password: ~A" char))
	   (dotimes (i 25) (read-char stream)))
	  (t nil))				;Otherwise a digit (indicating a character style) or *
    (values)))					;Return nothing so it doesn't pay attention to it

(setq *ignore-symbolics-font-info-readtable* (copy-readtable *readtable*))
(set-macro-character (code-char 6 0 0) #'ignore-symbolics-font-info nil *ignore-symbolics-font-info-readtable*)
(setq *readtable* *ignore-symbolics-font-info-readtable*)

(defun ignore-font-info ()
  (setq *ignore-symbolics-font-info-readtable* (copy-readtable *readtable*))
  (set-macro-character (code-char 6 0 0) #'ignore-symbolics-font-info nil *ignore-symbolics-font-info-readtable*)
  (setq *readtable* *ignore-symbolics-font-info-readtable*))