]> code.delx.au - gnu-emacs/blob - lisp/emacs-lisp/cl-preloaded.el
Recognize more format variation. Automatically reshow decrypted text.
[gnu-emacs] / lisp / emacs-lisp / cl-preloaded.el
1 ;;; cl-preloaded.el --- Preloaded part of the CL library -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc
4
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; The expectation is that structs defined with cl-defstruct do not
25 ;; need cl-lib at run-time, but we'd like to hide the details of the
26 ;; cl-struct metadata behind the cl-struct-define function, so we put
27 ;; it in this pre-loaded file.
28
29 ;;; Code:
30
31 (defun cl-struct-define (name docstring parent type named slots children-sym
32 tag print-auto)
33 (if (boundp children-sym)
34 (add-to-list children-sym tag)
35 (set children-sym (list tag)))
36 ;; If the cl-generic support, we need to be able to check
37 ;; if a vector is a cl-struct object, without knowing its particular type.
38 ;; So we use the (otherwise) unused function slots of the tag symbol
39 ;; to put a special witness value, to make the check easy and reliable.
40 (unless named (fset tag :quick-object-witness-check))
41 (put name 'cl-struct-slots slots)
42 (put name 'cl-struct-type (list type named))
43 (if parent (put name 'cl-struct-include parent))
44 (if print-auto (put name 'cl-struct-print print-auto))
45 (if docstring (put name 'structure-documentation docstring)))
46
47 (provide 'cl-preloaded)
48 ;;; cl-preloaded.el ends here