Skip to content

Commit 9aed01e

Browse files
committed
Backport cl-struct-define from master emacs.
Some package(https://github.com/haskell/haskell-mode) would report an error if `cl-struct-define` is not defined.
1 parent 5421fe0 commit 9aed01e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

custom.el

+22
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,25 @@ inversion of gas-comment-region"
6262
(delete-char 1))
6363
(next-line))
6464
(goto-char end)))
65+
66+
(defun cl-struct-define (name docstring parent type named slots children-sym
67+
tag print-auto)
68+
(cl-assert (or type (equal '(cl-tag-slot) (car slots))))
69+
(cl-assert (or type (not named)))
70+
(if (boundp children-sym)
71+
(add-to-list children-sym tag)
72+
(set children-sym (list tag)))
73+
(let* ((parent-class parent))
74+
(while parent-class
75+
(add-to-list (intern (format "cl-struct-%s-tags" parent-class)) tag)
76+
(setq parent-class (get parent-class 'cl-struct-include))))
77+
;; If the cl-generic support, we need to be able to check
78+
;; if a vector is a cl-struct object, without knowing its particular type.
79+
;; So we use the (otherwise) unused function slots of the tag symbol
80+
;; to put a special witness value, to make the check easy and reliable.
81+
(unless named (fset tag :quick-object-witness-check))
82+
(put name 'cl-struct-slots slots)
83+
(put name 'cl-struct-type (list type named))
84+
(if parent (put name 'cl-struct-include parent))
85+
(if print-auto (put name 'cl-struct-print print-auto))
86+
(if docstring (put name 'structure-documentation docstring)))

0 commit comments

Comments
 (0)