Questions tagged [cl-lib]

Use this tag for questions about functions, macros, and variables defined in cl-lib. Furthermore, use it for questions about the package cl-lib.el itself, about the old package cl.el and about the compatibility layer cl-compat.el.

Use this tag for question about functions, macros, and variables defined in packages cl-lib.el, cl-macs.el, and cl-seq.el.

You can also use this tag for questions about the libraries themselves, about the old package cl.el, or about the compatibility layer cl-compat.el.

25 questions
19
votes
2 answers

What's the correct replacement for flet on new emacsen?

I have some code that uses flet to temporarily change the behaviour of functions. ;; prevent changing the window (flet ((pop-to-buffer (buffer &rest args) (switch-to-buffer buffer))) (compilation-next-error-function n…
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
18
votes
1 answer

require 'cl or require 'cl-lib

In order to include Common Lisp compatibility I've seen both (require 'cl) and (require 'cl-lib) Which is correct? As I understand the cl-lib is the later of the two, but is it safe to use just it?
147pm
  • 2,907
  • 1
  • 18
  • 39
9
votes
1 answer

indent cl-loop to respect `if else` statements

I have a hard time writing and reading cl-loops with they way they're indented by default as I can't easily tell what the control flow is: (cl-loop for x below 10 if (cl-oddp x) collect x into odds and if (memq x…
Aquaactress
  • 1,393
  • 8
  • 11
7
votes
2 answers

"Symbol's function definition is void: cl-macroexpand-all" when trying to install php-mode

I'm trying to install php-mode, but I keep encountering this error when I run M-x php-mode: Symbol's function definition is void: cl-macroexpand-all The error persists whether I install php-mode via MELPA or manually. Environment: Emacs 24.3.94.1…
cg433n
  • 285
  • 2
  • 6
7
votes
3 answers

Is using cl-lib crucial for writing good Emacs Lisp code?

As a beginner I understand that including cl-lib will allow me to use some code from Common Lisp. However, whenever I see this included in elisp code I wonder again, Should I really start with Common Lisp, then learn elisp? Is cl-lib giving elisp…
147pm
  • 2,907
  • 1
  • 18
  • 39
4
votes
2 answers

Alternative to lexical-let

I'd rather not use cl-lib and cl at the same time. However, I really like using lexical-let to specify the usage of lexical binding on a more granular level. Is there any equivalent in cl-lib or vanilla Emacs Lisp?
PythonNut
  • 10,243
  • 2
  • 29
  • 75
3
votes
2 answers

Why does pp-macroexpand return nonsense for cl-loop?

Consider the following cl-loop: (cl-loop for x across "abc" for y across "123" concat (string x y)) This evaluates to "a1b2c3", i.e. it zips both strings together. However, if I look at the expansion of cl-loop it seems like that…
Zeta
  • 1,045
  • 9
  • 18
3
votes
0 answers

What kind of destructuring does cl-loop support?

1. Summary Is it possible to destructure an unordered plist in cl-loop's for-clauses? 2. Details From the documentation I would have expected destructuring to be universal, e.g. I would have expected for (a . b) = data and for (a &rest b) =…
kdb
  • 1,561
  • 12
  • 21
3
votes
2 answers

Why is cl-loop autoloaded on byte-compilation?

This question is motivated by a question about the "void function" error on cl-loop in the init file. The following test shows that (require 'cl-lib) is not needed for byte-compilation: Assume you have a file ~/tmp/test.el with the following…
Tobias
  • 32,569
  • 1
  • 34
  • 75
3
votes
1 answer

with-slots with defstruct "class" instance

Is it possible to use a with-slots-type macro with an instance of a defstruct-defined class in emacs lisp? I tried and I'm getting this error: eieio-oset: Wrong type argument: eieio-object, "some-string", obj. Sample code: (progn (defstruct…
erjoalgo
  • 853
  • 1
  • 5
  • 18
3
votes
3 answers

Indenting `cl-flet` etc

Is there a way to indent cl-flet, cl-labels etc. using the CL style without resorting to (setq lisp-indent-function #'common-lisp-indent-function)? cl-indent.el claims that: common-lisp-indent-function is also a suitable function for indenting…
Tianxiang Xiong
  • 3,848
  • 16
  • 27
3
votes
1 answer

Equivalent of EIEIO's make-instance for cl-lib structs?

What equivalents exist for EIEIO's make-instance in cl-lib? (make-instance 'my/class :slot-a "value" :slot-b "value") I would like to create an instance of an arbitrary struct identified by a supplied symbol without reliance on knowledge of the…
ebpa
  • 7,319
  • 26
  • 53
3
votes
1 answer

Defining a generic function and implementing specialised methods

Emacs provides support for polymorphism, supporting "generic functions", like in CLOS. According to Emacs manual: A generic function specifies an abstract operation, by defining its name and list of arguments, but (usually) no implementation. …
antonio
  • 1,762
  • 12
  • 24
3
votes
3 answers

Where is cl-constantly and what to use instead?

In Common Lisp, there is constantly function, which creates new function without side-effects that takes any number of arguments and always returns specified value. For some reason cl-lib doesn't provide cl-constantly, so I guess it should exist in…
Mark Karpov
  • 4,893
  • 1
  • 24
  • 53
2
votes
4 answers

Equivalent of `continue' in `cl-loop'?

Does the cl-loop macro implement an equivalent to the continue keyword of other languages? The behavior of break can be achieved by using until or while clauses by placing them in the middle of cl-loop, e.g. (cl-loop item in '(1 2 3 4) do…
kdb
  • 1,561
  • 12
  • 21
1
2