X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=calist.el;h=fbef6808a08863ff8d80b690c6e47d9d1592556e;hb=6735de899c312cadf00a812c038882be505d411f;hp=504476ae05a94a4b6c6ec101de7db1e8cf21a941;hpb=533a9a089717345fdfe5ff49b9798b54124cdd56;p=elisp%2Fapel.git diff --git a/calist.el b/calist.el index 504476a..fbef680 100644 --- a/calist.el +++ b/calist.el @@ -1,8 +1,10 @@ ;;; calist.el --- Condition functions -;; Copyright (C) 1998 MORIOKA Tomohiko. +;; Copyright (C) 1998 Free Software Foundation, Inc. +;; Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. +;; Licensed to the Free Software Foundation. -;; Author: MORIOKA Tomohiko +;; Author: MORIOKA Tomohiko ;; Keywords: condition, alist, tree ;; This file is part of APEL (A Portable Emacs Library). @@ -26,13 +28,49 @@ (eval-when-compile (require 'cl)) -(defvar calist-field-match-method-obarray [nil]) +(require 'alist) + +(defvar calist-package-alist nil) +(defvar calist-field-match-method-obarray nil) + +(defun find-calist-package (name) + "Return a calist-package by NAME." + (cdr (assq name calist-package-alist))) (defun define-calist-field-match-method (field-type function) "Set field-match-method for FIELD-TYPE to FUNCTION." (fset (intern (symbol-name field-type) calist-field-match-method-obarray) function)) +(defun use-calist-package (name) + "Make the symbols of package NAME accessible in the current package." + (mapatoms (lambda (sym) + (if (intern-soft (symbol-name sym) + calist-field-match-method-obarray) + (signal 'conflict-of-calist-symbol + (list (format "Conflict of symbol %s"))) + (if (fboundp sym) + (define-calist-field-match-method + sym (symbol-function sym)) + ))) + (find-calist-package name))) + +(defun make-calist-package (name &optional use) + "Create a new calist-package." + (let ((calist-field-match-method-obarray (make-vector 7 0))) + (set-alist 'calist-package-alist name + calist-field-match-method-obarray) + (use-calist-package (or use 'standard)) + calist-field-match-method-obarray)) + +(defun in-calist-package (name) + "Set the current calist-package to a new or existing calist-package." + (setq calist-field-match-method-obarray + (or (find-calist-package name) + (make-calist-package name)))) + +(in-calist-package 'standard) + (defun calist-default-field-match-method (calist field-type field-value) (let ((s-field (assoc field-type calist))) (cond ((null s-field) @@ -43,13 +81,15 @@ ((equal (cdr s-field) field-value) calist)))) +(define-calist-field-match-method t (function calist-default-field-match-method)) + (defsubst calist-field-match-method (field-type) - (condition-case nil - (symbol-function - (intern-soft - (symbol-name field-type) calist-field-match-method-obarray)) - (error (symbol-function 'calist-default-field-match-method)) - )) + (symbol-function + (or (intern-soft (if (symbolp field-type) + (symbol-name field-type) + field-type) + calist-field-match-method-obarray) + (intern-soft "t" calist-field-match-method-obarray)))) (defsubst calist-field-match (calist field-type field-value) (funcall (calist-field-match-method field-type) @@ -285,6 +325,7 @@ even if other rules are matched for ALIST." ;;; @ end ;;; -(provide 'calist) +(require 'product) +(product-provide (provide 'calist) (require 'apel-ver)) ;;; calist.el ends here