From: tmorioka Date: Mon, 24 Feb 1997 09:12:12 +0000 (+0000) Subject: (define-structure): New macro; Don't require tl-misc.el. X-Git-Tag: Hokutetsu-Ishikawa-new~303 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4e99fd7e3300da3fd048763dbe82511f1eaac04;p=elisp%2Fsemi.git (define-structure): New macro; Don't require tl-misc.el. --- diff --git a/mime-parse.el b/mime-parse.el index a63ce2a..bbd1d8f 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko -;; Version: $Id: mime-parse.el,v 0.2 1997-02-22 16:10:50 morioka Exp $ +;; Version: $Id: mime-parse.el,v 0.3 1997-02-24 09:12:12 tmorioka Exp $ ;; Keywords: MIME, multimedia, mail, news ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). @@ -26,9 +26,38 @@ ;;; Code: (require 'std11) -(require 'tl-misc) (require 'mime-def) +(defmacro define-structure (name &rest slots) + (let ((pred (symbol-concat name '-p))) + (cons 'progn + (nconc + (list + (` (defun (, pred) (obj) + (and (vectorp obj) + (eq (elt obj 0) '(, name)) + )) + ) + (` (defun (, (symbol-concat name '/create)) (, slots) + (, (cons 'vector (cons (list 'quote name) slots))) + ) + )) + (let ((i 1)) + (mapcar (function + (lambda (slot) + (prog1 + (` (defun (, (symbol-concat name '/ slot)) (obj) + (if ((, pred) obj) + (elt obj (, i)) + )) + ) + (setq i (+ i 1)) + ) + )) slots) + ) + (list (list 'quote name)) + )))) + ;;; @ field parser ;;;