1

I am trying to setup a package named cnfonts, in which below lines is required in .emacs initail file:

(defvar my-line-spacing-alist '((9 . 0.1) (10 . 0.9) (11.5 . 0.2) (12.5 . 0.2) (14 . 0.2) (16 . 0.2) (18 . 0.2) (20 . 1.0) (22 . 0.2) (24 . 0.2) (26 . 0.2) (28 . 0.2) (30 . 0.2) (32 . 0.2))) (defun my-line-spacing-setup (fontsizes-list) (let ((fontsize (car fontsizes-list)) (line-spacing-alist (copy-list my-line-spacing-alist))) (dolist (list line-spacing-alist) (when (= fontsize (car list)) (setq line-spacing-alist nil) (setq-default line-spacing (cdr list)))))) (add-hook 'cnfonts-set-font-finish-hook #'my-line-spacing-setup) 

but, I got below error:

symbols function definition is void: copy-list 

I believe that I should import the package in which copy-list belongs to. But I can not figure out exactly which package I should use and how to import it.

Any ideas?

1

1 Answer 1

1

Function copy-list is defined in library cl.el in older Emacs releases. You'd need to load that library before trying to call the function.

But in recent releases you need to load library cl-lib.el instead, and the function is now called cl-copy-list.

You don't say what release you're using. A guess is that you're using a recent release, where copy-list is no longer even an alias for cl-copy-list. In any case, unless you have a very old release you need to load cl-lib.el: (require 'cl-lib).

To find the package where it's defined, try C-h f copy-list TAB TAB, then choose cl-copy-list. In buffer *Help* you then see this, which tells you that function is in library cl-lib.el:

cl-copy-list is a byte-compiled Lisp function in cl-lib.el.

(cl-copy-list LIST)

Return a copy of LIST, which may be a dotted list.

The elements of LIST are not copied, just the list structure itself.

3
  • I am using emacs 29.2: GNU Emacs 29.2 (build 2, x86_64-w64-mingw32) of 2024-02-02 Commented Jul 22, 2024 at 3:00
  • 1
    loading cl-lib.el with (require 'cl-lib) and replacing copy-list with cl-copy-list seems solved my problem Commented Jul 22, 2024 at 3:13
  • 1
    There is also copy-alist which is still available in recent Emacs releases. Looks like it would do the job as well. Commented Jul 22, 2024 at 5:18

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.