;;; -*- Mode:LISP; Package:USER; Patch-File:T; Base:10; Readtable:ZL -*-
;;; Patch file for System version 124.6
;;; Reason:
;;;  Additional support within ZMacs for Mode:CommonLISP or Mode:Common-LISP.
;;;  
;;;  Now, a file can be read into a buffer with the CommonLISP mode translation, and
;;;  the :readtable and :syntax attributes will be preset to CommonLISP values.  This
;;;  means that (again, within ZMacs only), these files -- which probably came from a
;;;  LISP machine distributed by other companies who shall go nameless -- will get read
;;;  in properly.
;;;  
;;;  At this point, the user should still do 'Update Attribute List' manually, 
;;;  otherwise s/he will never see the values of the attributes that get set
;;;  for CommonLISP mode.
;;; Written 26-May-88 13:53:11 by keith at site Gigamos Cambridge
;;; while running on Fish food from band 1
;;; with Experimental System 124.5, Experimental Local-File 74.0, Experimental File-Server 23.0, Experimental Unix-Interface 12.0, Experimental ZMail 72.0, Experimental Tape 23.0, Experimental Lambda-Diag 16.0, microcode 1756, SDU Boot Tape 3.14, SDU ROM 103.
;;; Copied from patch 123.284 -KmC




; From modified file DJ: L.ZWEI; MODES.LISP#162 at 19-May-88 13:58:21
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; MODES  "

(defun set-lisp-attributes-from-mode-with-translations (&optional (buffer *interval*) &aux realmode)
  (declare(values set-attributes error-flag))
  (check-type buffer zmacs-buffer "a ZMacs buffer")
  (cond
    ;;If no real mode determined, punt
    ((null (setq realmode (send buffer :get-attribute :mode))) (values nil :no-mode-attribute))
    ;;Must be a LISP mode buffer
    ((not (eq (send buffer :major-mode) 'lisp-mode)) (values nil :not-lisp-mode))
    ;;If mode says LISP, default as usual
    ((string-equal realmode "LISP") (values nil :must-be-zetalisp))
    ;;If mode is not a valid LISP mode translation, punt.
    ;;See the global *major-mode-translations* for OK modes.
    ((not (string-equal (cdr (assoc realmode *major-mode-translations*)) "LISP"))
     (values nil :not-translated-to-lisp))
    ;;If mode says COMMON-LISP or COMMONLISP, set stuff.
    ((mem #'string-equal realmode '(:COMMON-LISP :COMMONLISP))
     (or (send buffer :get-attribute :readtable)
	 (send buffer :set-attribute :readtable :CL))
     (or (send buffer :get-attribute :syntax)
	 (send buffer :set-attribute :syntax :CL))
     t)
    ;;Apparently the mode is some other translation that may not
    ;;be Common-LISP.
    (t nil)))

))

; From modified file DJ: L.ZWEI; MODES.LISP#162 at 19-May-88 13:58:24
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; MODES  "


(DEFMAJOR COM-LISP-MODE LISP-MODE "LISP"
  "Sets things up for editing Lisp code.
Puts Indent-For-Lisp on Tab, sets readtable, 
sets escape character handling, etc."
  ()
  (SETQ *SPACE-INDENT-FLAG* T)
  (SETQ *PARAGRAPH-DELIMITER-LIST* NIL)
  (SETQ *COMMENT-START* 'LISP-FIND-COMMENT-START-AND-END)
  (SET-COMTAB *MODE-COMTAB* '(#/TAB COM-INDENT-FOR-LISP
			      #/RUBOUT COM-TAB-HACKING-RUBOUT
			      #/C-RUBOUT COM-RUBOUT
			      #/M-Z COM-COMPILE-AND-EXIT
			      #/C-M-Z COM-EVALUATE-AND-EXIT))
  ;;Pre-set readtable, syntax from real mode [e.g, Mode:COMMON-LISP]. -KmC
  (progn(set-lisp-attributes-from-mode-with-translations))
  (SETQ *READTABLE* (OR (SI:FIND-READTABLE-NAMED
			  (SEND *INTERVAL* :GET-ATTRIBUTE :READTABLE)
			  :FIND)
			*READTABLE*
			si:standard-readtable))
  (SET-CHAR-SYNTAX (IF (= (SI:PTTBL-SLASH *READTABLE*) #//)
		       LIST-SLASH LIST-ALPHABETIC) *MODE-LIST-SYNTAX-TABLE* #//)
  (SET-CHAR-SYNTAX (IF (= (SI:PTTBL-SLASH *READTABLE*) #/\)
		       LIST-SLASH LIST-ALPHABETIC) *MODE-LIST-SYNTAX-TABLE* #/\))

))
