]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ztree/ztree-util.el
* ztree/ztree-diff-model.el (ztree-diff-node): Use cl-defstruct
[gnu-emacs-elpa] / packages / ztree / ztree-util.el
index 85df4446d6203e71975563c536ecd84035577543..40fe12ef0930c6923f35f7200d07e9e584aad8d1 100644 (file)
@@ -1,4 +1,4 @@
-;;; ztree-util.el --- Auxulary utilities for the ztree package -*- lexical-binding: t; -*-
+;;; ztree-util.el --- Auxiliary utilities for the ztree package -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2013-2015  Free Software Foundation, Inc.
 ;;
@@ -65,68 +65,6 @@ Used since `car-safe' returns nil for atoms"
     (insert text)
     (put-text-property start (point) 'face face)))
 
-
-(defmacro ztree-defrecord (record-name record-fields)
-  "Create a record (structure) and getters/setters.
-
-Record is the following set of functions:
- - Record constructor with name \"RECORD-NAME\"-create and list of
-arguments which will be assigned to RECORD-FIELDS
- - Record getters with names \"record-name\"-\"field\" accepting one
-argument - the record; \"field\" is from \"record-fields\" symbols
- - Record setters with names \"record-name\"-set-\"field\" accepting two
-arguments - the record and the field value
-
-Example:
-\(ztree-defrecord person (name age))
-
-will be expanded to the following functions:
-
-\(defun person-create (name age) (...)
-\(defun person-name (record) (...)
-\(defun person-age (record) (...)
-\(defun person-set-name (record value) (...)
-\(defun person-set-age (record value) (...)
-
-To test expansion one can use GNU Emacs's pp library:
-\(require 'pp)
-\(pp-macroexpand-expression
- '(ztree-defrecord person (name age)))"
-  (let ((ctor-name (intern (concat (symbol-name record-name) "-create")))
-        (rec-var (make-symbol "record")))
-    `(progn
-       ;; constructor with the name "record-name-create"
-       ;; with arguments list "record-fields" expanded
-       (defun ,ctor-name (,@record-fields)
-         (let ((,rec-var))
-           ,@(mapcar #'(lambda (x)
-                         (list 'setq rec-var (list 'plist-put rec-var (list 'quote x) x)))
-                     record-fields)))
-       ;; getters with names "record-name-field" where the "field"
-       ;; is from record-fields
-       ,@(mapcar #'(lambda (x)
-                     (let ((getter-name (intern (concat (symbol-name record-name)
-                                                        "-"
-                                                        (symbol-name x)))))
-                       `(progn
-                          (defun ,getter-name (,rec-var)
-                            (plist-get ,rec-var ',x)
-                            ))))
-                 record-fields)
-       ;; setters wit names "record-name-set-field where the "field"
-       ;; is from record-fields
-       ;; arguments for setters: (record value)
-       ,@(mapcar #'(lambda (x)
-                     (let ((setter-name (intern (concat (symbol-name record-name)
-                                                        "-set-"
-                                                        (symbol-name x)))))
-                       `(progn
-                          (defun ,setter-name (,rec-var value)
-                            (setq ,rec-var (plist-put ,rec-var ',x value))
-                            ))))
-                 record-fields))))
-
-
 (provide 'ztree-util)
 
 ;;; ztree-util.el ends here