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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
173 views

Problem with remove-if and cl-remove-if

I have a very useful bit of code in my .emacs file which closes all buffers except the current one, and scratch and TeX_snippets.org buffers: (defun my/kill-all-buffers-except-toolbox () "Kill ...
sgmoye's user avatar
  • 179
3 votes
2 answers
159 views

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 ...
Zeta's user avatar
  • 1,093
1 vote
1 answer
53 views

How to create a structure instance out of a -pkg.el file?

Package foo description is stored inside a file foo-VERSION/foo-pkg.el with a cl-defstruct definition that complies to package.el package-desc structure type with a package-desc-from-define ...
PRouleau's user avatar
  • 796
0 votes
1 answer
58 views

Alternative way to disambiguate "dangling else" in a cl-loop

I need to achieve in a cl-loop the following conditional written in pseudocode. if (flag1) { if (flag2) {return ...} } else { return ... } Note that it is equivalent to if (flag1 && ...
Firmin Martin's user avatar
2 votes
4 answers
990 views

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-...
kdb's user avatar
  • 1,561
3 votes
0 answers
238 views

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 ...
kdb's user avatar
  • 1,561
3 votes
2 answers
196 views

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 ...
Tobias's user avatar
  • 33.1k
1 vote
1 answer
747 views

Symbol's function definition is void: cl-loop

I'm trying to turn off all colored text when using gnu emacs as emacs -nw on linux. This answer gives a snippet of code to use for this purpose: (cl-loop for face in (face-list) do (set-face-...
user avatar
3 votes
1 answer
405 views

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-...
erjoalgo's user avatar
  • 863
18 votes
1 answer
4k views

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 ...
147pm's user avatar
  • 2,957
0 votes
1 answer
582 views

Search for occurrence of character within a string without using the common lisp library?

I need to extract certain information from buffer names, and I'm doing so by extracting substrings based on the position of unique characters within a buffer name string. So, I currently am doing ...
emacsomancer's user avatar
  • 1,041
1 vote
1 answer
90 views

Is it necessary for me to use `cl-labels` in this grouping function, when plain recursion does the job as well?

So I'm reading through some tutorials with Common Lisp, and I came across this function, group: (defun group (source n) (if (zerop n) (error "zero length")) (labels ((rec (source acc) ...
Tariq Kamal's user avatar
9 votes
1 answer
381 views

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) ...
Aquaactress's user avatar
  • 1,443
3 votes
3 answers
420 views

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-...
Tianxiang Xiong's user avatar
1 vote
0 answers
72 views

Suppress creation of slot accessors for cl-defstruct :include slots?

Is it possible to suppress creation of slot accessors for slots included via :include? For example, in the following: (cl-defstruct person name (age 0) sex) (cl-defstruct (astronaut (:include person ...
ebpa's user avatar
  • 7,439
3 votes
1 answer
214 views

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 ...
ebpa's user avatar
  • 7,439
1 vote
2 answers
103 views

cl-lib isn't loaded the first time an autoloaded function is used from it

I'm trying to use cl-lib early in my init.el. The function I'm using (cl-some) is autoloaded, so I expect that don't need an explicit require, yet I get a void-function error if I don't explicitly ...
jpkotta's user avatar
  • 508
0 votes
1 answer
56 views

How can I use edebug with cl-block?

Given the following function using cl-block: (defun wh/with-block (x) (cl-block 'foo (+ x 1))) I can evaluate it, but C-u M-x edebug-eval-defun gives an error: edebug-syntax-error: Invalid ...
Wilfred Hughes's user avatar
2 votes
1 answer
520 views

Using local variables in cl-loop

This is my first time trying to write my own elisp code, so bear with me. I have the following cl-loop: data contains the following: ((refs . [((file . "api/user.js") (start . 266) (end . 269)) ((...
aiguofer's user avatar
  • 588
3 votes
1 answer
810 views

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 ...
antonio's user avatar
  • 1,802
3 votes
3 answers
246 views

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 ...
Mark Karpov's user avatar
  • 4,933
4 votes
2 answers
2k views

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 ...
PythonNut's user avatar
  • 10.3k
7 votes
3 answers
3k views

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 ...
147pm's user avatar
  • 2,957
19 votes
2 answers
909 views

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 ...
Wilfred Hughes's user avatar
7 votes
2 answers
2k views

"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 ...
cg433n's user avatar
  • 285