Function: copy-sequence

copy-sequence is a function defined in fns.c.

Signature

(copy-sequence ARG)

Documentation

Return a copy of a list, vector, string, char-table or record.

The elements of a list, vector or record are not copied; they are shared with the original. If the original sequence is empty, this function may return the same empty object instead of its copy.

Probably introduced at or before Emacs version 21.1.

Aliases

copy-soap-xs-attribute-group copy-gdb-table copy-cl--generic copy-package-desc copy-tramp-file-name copy-ewoc--node copy-byte-to-native-func-def copy-soap-namespace copy-nnmaildir--grp copy-mh-thread-message copy-tar-header soap-copy-wsdl copy-comp-args copy-ebrowse-bs copy-ebrowse-cs copy-ebrowse-hs copy-flymake--diag copy-ebrowse-ms copy-debugger--buffer-state copy-ebrowse-ts cl--copy-slot-descriptor-1 copy-mm-uu-entry rmail-mime--copy-display copy-package--bi-desc copy-soap-xs-simple-type copy-ert--test-execution-info copy-flymake--state copy-comp-args-base copy-bindat--type copy-elisp-doc-entry copy-nnmaildir--art copy-gnus-data copy-soap-bound-operation copy-kmacro-register copy-byte-to-native-lambda copy-comp-func-d copy-comp-func-l cl-copy-seq copy-xref-match-item evil-copy-range copy-rst-Stn copy-cvs-tag copy-archive--file-desc copy-mhtml--submode copy-ewoc copy-soap-xs-basic-type copy-js--pitem copy-htmlize-fstruct copy-soap-operation copy-file-notify copy-comp-cstr-ctxt copy-epa-ks-key copy-soap-xs-attribute copy-xref-item copy-mh-thread-container copy-comp-cstr-f copy-comp-mvar copy-ert--stats copy-cl--generic-generalizer copy-shadow-cluster copy-erc-server-user copy-ses--locprn copy-url-future copy-cvs-flags copy-url-queue copy-erc-channel-user copy-comp-nargs copy-nnimap copy-seq (obsolete since 27.1) copy-lisp-indent-state copy-epg-key copy-ert-test-result copy-file-notify--rename copy-mh-buffer-data copy-checkdoc-error copy-xref-file-location -copy copy-ert--ewoc-entry copy-ert-test-passed copy-mail-header copy-ert-test-quit copy-xref-etags-location copy-ert-test-failed copy-xref-etags-apropos-location copy-soap-element comp-cstr-shallow-copy copy-soap-binding copy-erc-input copy-ert-test copy-sgml-tag copy-ert-test-result-with-condition copy-ert-test-aborted-with-non-local-exit ediff-copy-list (obsolete since 28.1) copy-profiler-calltree copy-soap-xs-type copy-soap-port-type copy-soap-xs-element copy-soap-message copy-comp-ctxt copy-js--js-handle copy-senator-register copy-epa-ks-name copy-soap-xs-complex-type copy-edebug--frame copy-tramp-goa-account copy-ebrowse-position copy-comp-data-container copy-frameset-register copy-nnmaildir--srv copy-cl--generic-method copy-gnus-info copy-xref-elisp-location copy-gdb-handler copy-elisp-doc-entry-section copy-evil-jumps-struct copy-ert-test-skipped copy-soap-port copy-profiler-profile copy-prop-match copy-erc-response copy-nrepl-response-queue copy-hierarchy copy-rst-Ado copy-xref-bogus-location copy-xref-buffer-location copy-soap-namespace-link copy-archive--file-summary copy-backtrace-frame copy-file-notify--watch copy-tramp-media-device copy-byte-to-native-top-level

Source Code

// Defined in /usr/src/emacs/src/fns.c
{
  if (NILP (arg)) return arg;

  if (RECORDP (arg))
    {
      return Frecord (PVSIZE (arg), XVECTOR (arg)->contents);
    }

  if (CHAR_TABLE_P (arg))
    {
      return copy_char_table (arg);
    }

  if (BOOL_VECTOR_P (arg))
    {
      EMACS_INT nbits = bool_vector_size (arg);
      ptrdiff_t nbytes = bool_vector_bytes (nbits);
      Lisp_Object val = make_uninit_bool_vector (nbits);
      memcpy (bool_vector_data (val), bool_vector_data (arg), nbytes);
      return val;
    }

  if (!CONSP (arg) && !VECTORP (arg) && !STRINGP (arg))
    wrong_type_argument (Qsequencep, arg);

  return concat (1, &arg, XTYPE (arg), 0);
}