[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ZWEI Sectionizing Code
From: dmittman%beowulf@Warbucks.AI.SRI.COM (David Mittman)
I am looking for some code which will automatically pretty-up zmacs buffers
by recognizing function names, defvars, local args, etc. and put them in a
defined character style. Anyone have this?
Here's the comment at the front of an electric mode that we (some students
from MIT AI) use. If you are interested (and anybody else), I'll send the file.
- Mark Shirley
;;; Styled-Lisp: A combination of Electric Style-Lock Mode,
;;; Electric Shift-Lock Mode, and DJB's Def-Lock mode
;;; The basic idea is to combine these modes into one so there's only one
;;; command hook. Then we control character styles and case in the various
;;; lisp syntactic contexts by setting a group of zmacs variables. The
;;; contexts are:
;;; STRING - This includes the "'s at either end
;;; SLASH - The character after #\
;;; COMMENT - This includes the ";"
;;; DEFINITION - This only includes alphabetic characters within the first
;;; sexpr after "(def". This should be smarter some day.
;;; To turn on this minor mode, execute m-X Styled-Lisp Mode. Alternatively,
;;; call TURN-ON-STYLED-LISP from the lisp mode hook, e.g.,
;;; (setf lisp-mode-hook #'(lambda () (ignore-errors (turn-on-styled-lisp))))
;;; M-x Commands:
;;; Convert to Styled Lisp File - Sets up the character styles in an existing
;;; buffer. Give this an argument, and it
;;; reindents all the code too (which can change
;;; depending upon styles). Watch out for
;;; The zmacs variables which control Styled Lisp are:
;;; Character style for normal lisp code.
;;; Character style for lisp strings.
;;; Character style for backslash contexts.
;;; Character style for lisp comments.
;;; Character style for definition names.
;;; Control the case of characters in normal lisp code
;;; Control the case of characters in lisp comments
;;; Control the case of characters in lisp definition names
;;; Yes if defining forms have to start at the margin. No otherwise.
;;; In your init file, you can assign to these variables just like normal
;;; globals. Here's a template for seting up the character style
;;; (setq *STYLED-LISP-COMMENT-STYLE*
;;; (si:style-index (si:parse-character-style '(nil :italic nil)) t))
;;; Note that the likely possibilities are covered by these variables, but not
;;; all possibilities. E.g., case control for strings is missing. Maybe