home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / interfaces / Emacs-cl-shell / cl-clos.el < prev    next >
Encoding:
Text File  |  1990-12-10  |  3.9 KB  |  97 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; FILE:          cl-clos.el
  3. ;;; DESCRIPTION:   Extensions to cl-shell.el for CLOS
  4. ;;; AUTHOR:        Eero Simoncelli, 
  5. ;;;                Vision Science Group, 
  6. ;;;                MIT Media Laboratory.
  7. ;;; CREATED:       December, 1989
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  9.  
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  12. ;; accepts responsibility to anyone for the consequences of using it
  13. ;; or for whether it serves any particular purpose or works at all,
  14. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  15. ;; License for full details.
  16.  
  17. ;; Everyone is granted permission to copy, modify and redistribute
  18. ;; GNU Emacs, but only under the conditions described in the
  19. ;; GNU Emacs General Public License.   A copy of this license is
  20. ;; supposed to have been given to you along with GNU Emacs so you
  21. ;; can know your rights and responsibilities.  It should be in a
  22. ;; file named COPYING.  Among other things, the copyright notice
  23. ;; and this notice must be preserved on all copies.
  24.  
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26.  
  27. ;;; This file contains additional hacks for use with code in
  28. ;;; cl-shell.el when using the Common Lisp Object System provided with
  29. ;;; lucid.  It is loaded automatically by run-cl if :LCL4.0 and :PCL
  30. ;;; are on the *features* list in the CL world.
  31.  
  32. (require 'cl-shell)
  33.  
  34. ;;; Add some more special forms to the indentation list.  See
  35. ;;; cl-indent.el for more confusion.  Basically, the number refers to
  36. ;;; the number of "special" - i.e. non-body forms passed as arguments
  37. ;;; to these things. 
  38. (put 'defgeneric  'common-lisp-indent-hook 'defun)
  39. (put 'defmethod  'common-lisp-indent-hook 'defun)
  40. (put 'defclass   'common-lisp-indent-hook 'defun)
  41. (put 'with-slots 'common-lisp-indent-hook 2)
  42. (put 'with-accessors 'common-lisp-indent-hook 2)
  43. (put 'with-added-methods 'common-lisp-indent-hook 1)
  44. (put 'symbol-macrolet 'common-lisp-indent-hook 1)
  45. (put 'generic-flet 'common-lisp-indent-hook 1)
  46. (put 'generic-function 'common-lisp-indent-hook 1)
  47. (put 'generic-labels 'common-lisp-indent-hook 1)
  48.  
  49. ;;;; ---------- Allow direct compilation of CLOS methods ---------
  50.  
  51. ;;; Modify this so that CLOS methods are compiled directly (along with
  52. ;;; functions and macros):
  53. (setq cl-fast-compile-regexp "(def\\(un\\|macro\\|method\\)[ \t\n]+")
  54.  
  55. ;;; Modify the compile-def macro to allow direct compilation of CLOS
  56. ;;; methods!
  57. (cl-send-string
  58.  "#+(and LCL4.0 CLOS)
  59.   (progn
  60.    (defmacro user::compile-def (thing)
  61.      (if (and (listp thing) (eq (car thing) 'clos:defmethod))
  62.        `(clos-sys:compile-method ,thing)
  63.        `(compile ,thing)))
  64.    (values))\n")
  65.  
  66.  
  67. ;;;; ---------- Source file recording enhancements for CLOS in Lucid ---------
  68.  
  69. ;;; These are helpful if the file source-file-extensions.lisp is
  70. ;;; loaded into lisp.  Nothing breaks if this is not the case.
  71. ;;; *** Need to do pushnew here.
  72. (if (featurep 'cl-lucid)
  73.     (setq *cl-definition-regexp-alist*
  74.       (append *cl-definition-regexp-alist*
  75.           '((CLASS . "(defclass[ \t\n]*%s")
  76.             (METHOD . cl-make-clos-method-regexp)))))
  77.  
  78. ;;; Type-spec defined in source-file-extensions.lisp is
  79. ;;; '(METHOD <name> . argument-classes)
  80. (if (featurep 'cl-lucid)
  81.     (defun cl-make-clos-method-regexp (symbol type-spec)
  82.       (setq type-spec (cdr type-spec))    ;strip 'method
  83.       (setq type-spec (car (cdr type-spec))) ;strip method name
  84.       (let ((the-regexp (format "(defmethod[ \t\n]*%s[ \t\n]*(" symbol)))
  85.     (while type-spec
  86.       (setq the-regexp
  87.         (concat
  88.          the-regexp
  89.          (if (or (eq (car type-spec) t) (eq (car type-spec) 'T))
  90.              (format "[ \t\n]*\\(\\w*\\|(\\w*[ \t\n]*%s[ \t\n]*)\\)"
  91.                  (cl-strip-package (car type-spec)))
  92.              (format "[ \t\n]*(\\w*[ \t\n]*%s[ \t\n]*)"
  93.                  (cl-strip-package (car type-spec))))))
  94.       (setq type-spec (cdr type-spec)))
  95.     the-regexp)))
  96.        
  97.