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

Re: Removing Fonts From Files

    Date: Tue, 19 Jan 88 13:33 EST
    From: Jeffrey Mark Siskind <Qobi@ZERMATT.LCS.MIT.EDU>

	    Date: Fri, 15 Jan 88 09:59:35 CST
	    From: Daniel A Haug <aihaug@AUSTIN.LOCKHEED.COM>

	    What I would like to do is maintain my "pretty" version on the symbolics,
	    and dump the "non-pretty" version to the sun when necessary, by simply
	    executing m-X "Write File <filename> With Character Styles Removed", or

    I am interested in doing exactly the opposite. I have never got into the habit
    of using character styles in my Lisp code for various reasons. I would like to
    start though. 

Not quite automatically, but close.  This hack will prompt for the
style, and then change all the comments in the buffer to that style.

Don't send me money, instead, adapt this code to make it work only on
regions, on more than one buffer, on tag tables and systems.  Then, send
me the changes.  Thanks....  :)

Note: all of the magic is performed by lisp-bp-syntactic-context.  Sigh,
if this were only documented.  Or even better, if there was a documented
mechanism within the editors to allow the user to parse the code in a
buffer in any of the languages....

Jerry Bakin.


1;;; See if we can force every lisp file into my favorite font.
0(defcom com-change-lisp-comment-style
	  "Changes all lisp comments in a buffer to font b" (r)
 (let ((save-bp (copy-bp (point)))			1; Remember where we started
0       (style (si:style-index
			       "Change comment style of buffer to ")
   (move-bp (point)
	     (line-next (bp-line (interval-first-bp *interval*)))
  1;; For the first semicolon in each line, DO!
  (do ((comment-bp (search (point) ";") (search (point) ";")))	1; Looking for a semicolon
0      ((not comment-bp) (move-bp (point) save-bp))     1; Exit and restore bp if none found
   (setq comment-bp (copy-bp comment-bp :normal))  
   (move-bp (point) comment-bp)			1; Jump to semicolon
   1;; Ok, are we in a comment, or in a string?
   (multiple-value-bind (ignore ignore in-comment)
      (lisp-bp-syntactic-context (point))
    (if in-comment
	(dbp (point))						1; Backup over the semicolon
0	(my-push-mark)				
	(move-bp (point) (end-line (point) 0 t))		1; Goto end of line
0	(change-style-interval (mark) (point) t style nil)

1;;; Change the font in the given area 
;;; but, you don't have to mark the buffer as modified
;;; From change-style-interval

0(defun 1change0-style-interval
       (start-bp &optional end-bp in-order-p (style-num *style*) (mung-p t))
  (get-interval start-bp end-bp in-order-p)
  (undo-save start-bp end-bp t "change character style")
  (when mung-p
    (mung-bp-interval start-bp))
  (change-style-interval-internal start-bp end-bp t style-num)