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

Font stripper



    Date: Thu, 20 Sep 90 12:36:29 -0400
    From: kanderso@dino.bbn.com


    Here is a GNU EMACS command that will strip Symbolics font information
    from a buffer.

But it's buggy.  For example, if you run it on a file containing
itself, it will destroy itself!

    (defun strip-fonts (arg)
      ;; Strip symbolics fonts out of a file.
      (interactive "p")
      (save-excursion
	(goto-char (point-min))
	(while (re-search-forward "" nil t)
--> This will strip out ""'s that should not be
--> stripped, i.e. that actually appear as text
--> in the buffer before any actual style changes.
--> Strip no epsilons before the first password.
	  (backward-delete-char 1)
	  (let ((start (point)))
	    (if (looking-at "D,#TD1Ps....Begin using 006 escapes")
		(progn (re-search-forward "")
		       (backward-char)
--> This is not the right way to find the string to remove.
--> There can be an arbitrary amount of text between the
--> password and the first style change, and this will kill
--> it all, instead of just type password.  It's a constant
--> string; just kill it.  (You really should check the version
--> number included in the password, and complain if it's
--> not ascii 1, but that's a refinement).
--> Fortunately, Zmacs happens to always fall into this pattern,
--> so you probably haven't trashed any of your files yet, but
--> it's a bug, nonetheless!
		       (kill-region start (point)))
		(if (looking-at "(")
		    (progn (forward-sexp)
			   (kill-region start (point)))
--> This will delete any ""'s that have been quoted with
--> "", i.e. ones that appear in the buffer after the
--> first style change.
--> You also ignore the unpassword.
		    (delete-char 1)))))))