[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:
;;;
;;; *STYLED-LISP-NORMAL-STYLE*
;;;     Character style for normal lisp code.
;;; 
;;; *STYLED-LISP-STRING-STYLE*
;;;     Character style for lisp strings.
;;; 
;;; *STYLED-LISP-SLASH-STYLE*
;;;     Character style for backslash contexts.
;;; 
;;; *STYLED-LISP-COMMENT-STYLE*
;;;     Character style for lisp comments.
;;; 
;;; *STYLED-LISP-DEFINITION-STYLE*
;;;     Character style for definition names.
;;; 
;;; *STYLED-LISP-NORMAL-CASE*
;;;     Control the case of characters in normal lisp code
;;; 
;;; *STYLED-LISP-COMMENT-CASE*
;;;     Control the case of characters in lisp comments
;;; 
;;; *STYLED-LISP-DEFINITION-CASE*
;;;     Control the case of characters in lisp definition names
;;; 
;;; *STYLED-LISP-DEFINITIONS-MUST-START-AT-LEFT-MARGIN*
;;;     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
;;; variables:
;;;   (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
;;; someday.