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-pcl.el < prev    next >
Encoding:
Text File  |  1990-10-02  |  4.3 KB  |  104 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; FILE:          cl-pcl.el
  3. ;;; DESCRIPTION:   Extensions to cl-shell.el for PCL
  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 Portable Common Loops.  It was written to
  29. ;;; work with the 12/88 release.  It seems to work with Victoria Day
  30. ;;; (5/89) also.  It is loaded automatically by run-cl if :PCL is on
  31. ;;; the *features* list in the CL world.
  32.  
  33. (require 'cl-shell)
  34.  
  35. ;;; Add some more special forms to the indentation list.  See
  36. ;;; cl-indent.el for more confusion.  Basically, the number refers to
  37. ;;; the number of "special" - i.e. non-body forms passed as arguments
  38. ;;; to these things. 
  39. (put 'defgeneric  'common-lisp-indent-hook 'defun)
  40. (put 'defmethod  'common-lisp-indent-hook 'defun)
  41. (put 'defclass   'common-lisp-indent-hook 'defun)
  42. (put 'with-slots 'common-lisp-indent-hook 2)
  43. (put 'with-accessors 'common-lisp-indent-hook 2)
  44. (put 'with-added-methods 'common-lisp-indent-hook 1)
  45. (put 'symbol-macrolet 'common-lisp-indent-hook 1)
  46. (put 'generic-flet 'common-lisp-indent-hook 1)
  47. (put 'generic-function 'common-lisp-indent-hook 1)
  48. (put 'generic-labels 'common-lisp-indent-hook 1)
  49.  
  50. ;;; Modify this so that methods are compiled the fast way (along with
  51. ;;; functions and macros):
  52. (setq cl-fast-compile-regexp "(def\\(un\\|macro\\|method\\)[ \t\n]+")
  53.  
  54. ;;; Modify the compile-def macro to call a new function called
  55. ;;; compile-function-and-methods.  This comes from the PCL file high.lisp.
  56. (cl-send-string
  57.  "(progn
  58.    (defmacro user::compile-def (thing)
  59.     (let ((val (gensym)))
  60.       (if (and (listp thing) (eq (car thing) 'pcl:defmethod))
  61.         `(progn ,thing
  62.                 (user::compile-function-and-methods ',(cadr thing)))
  63.         `(compile ,thing))))
  64.    (defun user::compile-function-and-methods (the-symbol)
  65.      (let ((the-function (symbol-function the-symbol))
  66.        func meth name)
  67.        (when (not (compiled-function-p the-function)) (compile the-symbol))
  68.        (when (pcl::generic-function-p the-function)
  69.      (dolist (m (pcl::generic-function-methods the-function))
  70.        (multiple-value-setq (func meth name) (pcl::parse-method-or-spec m))
  71.        (setq func (pcl::method-function meth))
  72.        (when (not (compiled-function-p func))
  73.          (compile name func)
  74.          (setf (pcl::method-function meth) (symbol-function name))))))
  75.      the-symbol)
  76.   (values))\n")
  77.  
  78. ;;;; ---------- Source file recording enhancements for Lucid ---------
  79.  
  80. ;;; These are helpful if the file source-file-extensions.lisp is
  81. ;;; loaded into lisp.  Nothing breaks if this is not true.
  82. ;;; *** Need to do pushnew here.
  83. (if (featurep 'cl-lucid)        ;if Lucid CL
  84.     (setq *cl-definition-regexp-alist*
  85.       (append *cl-definition-regexp-alist*
  86.           '((:CLASS . "(defclass[ \t\n]*%s")
  87.             (:METHOD . cl-make-clos-method-regexp)))))
  88.  
  89. ;;; Type-spec defined in source-file-extensions.lisp is
  90. ;;; '(:method . argument-classes)
  91. (if (featurep 'cl-lucid)
  92.     (defun cl-make-clos-method-regexp (symbol type-spec)
  93.       (setq type-spec (cdr type-spec))
  94.       (let ((the-regexp (format "(defmethod[ \t\n]*%s[ \t\n]*(" symbol)))
  95.     (while type-spec
  96.       (setq the-regexp
  97.         (concat
  98.          the-regexp
  99.          (format "[ \t\n]*(\\w*[ \t\n]*%s[ \t\n]*)"
  100.              (cl-strip-package (car type-spec)))))
  101.       (setq type-spec (cdr type-spec)))
  102.     the-regexp)))
  103.        
  104.