From 3f6e4c1ce54d995b977ba762513666cb21243c2b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 18 Feb 2019 23:11:25 -0500 Subject: [PATCH] * lisp/mh-e/mh-acros.el (mh-defstruct): Minor simplification --- lisp/mh-e/mh-acros.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/mh-e/mh-acros.el b/lisp/mh-e/mh-acros.el index 893564419bc..3bbf509989d 100644 --- a/lisp/mh-e/mh-acros.el +++ b/lisp/mh-e/mh-acros.el @@ -143,6 +143,8 @@ check if variable `transient-mark-mode' is active." ;;;###mh-autoload (defmacro mh-defstruct (name-spec &rest fields) + ;; FIXME: Use `cl-defstruct' instead: shouldn't emit warnings any + ;; more nor depend on run-time CL functions. "Replacement for `defstruct' from the \"cl\" package. The `defstruct' in the \"cl\" library produces compiler warnings, and generates code that uses functions present in \"cl\" at @@ -160,15 +162,17 @@ more details." (constructor (or (and (consp name-spec) (cadr (assoc :constructor (cdr name-spec)))) (intern (format "make-%s" struct-name)))) - (field-names (mapcar #'(lambda (x) (if (atom x) x (car x))) fields)) - (field-init-forms (mapcar #'(lambda (x) (and (consp x) (cadr x))) - fields)) + (fields (mapcar (lambda (x) + (if (atom x) + (list x nil) + (list (car x) (cadr x)))) + fields)) + (field-names (mapcar #'car fields)) (struct (gensym "S")) (x (gensym "X")) (y (gensym "Y"))) `(progn - (defun* ,constructor (&key ,@(mapcar* #'(lambda (x y) (list x y)) - field-names field-init-forms)) + (defun* ,constructor (&key ,@fields) (list (quote ,struct-name) ,@field-names)) (defun ,predicate (arg) (and (consp arg) (eq (car arg) (quote ,struct-name)))) -- 2.39.2