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

tool to put fonts in source code



Moin again.

No, this will be a constructive message from me :-)

------------------------------------------------------------------------

Does your sources look like this?

1;;; a (simple) primality checker
(defun primep (int)
  "Calculates wether a number is a prime,
returns multiple values: boolean and least non-trivial divisor"
  (declare (values primep divisor))
  (cond ((< int 2) (values nil int))
	((evenp int) (values (eq int 2) 2))
	(t (do ((divisor 3 (+ divisor 2))
		(maxdivisor (floor (sqrt int))))
	       ((> divisor maxdivisor) (values t int))
	     (when (zerop (remainder int divisor))
	       (return (values nil divisor)))))))

(defun primes (int)
  "determines the prime factors of its input, returns them as alist."
  (check-arg int fixp "an integer greater than zero")
  (cond ((< int 2) (list int))
	( t
	 (do ((rest int (// rest prime-factor))
	      (prime-factors nil (cons prime-factor prime-factors))
	      ;; tricky initialization of PRIME-FACTOR:
	      (prime-factor 1))
	     ((= rest 1) (reverse prime-factors))
	   (setq prime-factor (multiple-value-bind (ignore least-divisor)
				  (primep rest)
				least-divisor)))
	 )))

0and you would like to have them look like that instead?

1;2;; a (simple) primality checker
1(defun 3primep1 (int)
  2"Calculates wether a number is a prime,
returns multiple values: boolean and least non-trivial divisor"
1  (declare (values primep divisor))
  (cond ((< int 2) (values nil int))
	((evenp int) (values (eq int 2) 2))
	(t (do ((divisor 3 (+ divisor 2))
		(maxdivisor (floor (sqrt int))))
	       ((> divisor maxdivisor) (values t int))
	     (when (zerop (remainder int divisor))
	       (return (values nil divisor)))))))

(defun 3primes1 (int)
  2"determines the prime factors of its input, returns them as a list."
1  (check-arg int fixp "an integer greater than zero")
  (cond ((< int 2) (list int))
	( t
	 (do ((rest int (// rest prime-factor))
	      (prime-factors nil (cons prime-factor prime-factors))
	      ;2; tricky initialization of PRIME-FACTOR:
1	      (prime-factor 1))
	     ((= rest 1) (reverse prime-factors))
	   (setq prime-factor (multiple-value-bind (ignore least-divisor)
				  (primep rest)
				least-divisor)))
	 )))

0But you don't like to put all those nice fonts in by hand? Now, here's the
solution: Use Fontification! It's cheap, fast and reliable and even
children may use it - just type c-sh-F and get the fonts you'll like.

OK, so much for advertising :-) Actually I'll make my ZMACS tool available
which does all these (and some more) nice things to your code. I've got
quiet a number of requests for this in the past and finally managed to
bring it beyond beta test state.

If you'd like too use it, drop me a message. Based on the number of
requests, I'll look up the appropriate way for distribution. (Due to
transatlantic traffic costs I wouldn't like to send it out a dozen times
from here)

	--jc