20
votes
Accepted
When/why should I use progn?
progn is typically used when dealing with macros. Some macros (use-package is a macro, last I checked) accept only 1 form, where others consume all remaining forms.
progn is used in the former case ...
17
votes
When/why should I use progn?
The most important reason for progn is described in the first line of the progn documentation (emphasis added):
progn is a special form that causes each of its arguments to be evaluated in sequence ...
13
votes
When/why should I use progn?
A better way to understand what progn is is by comparing it to the family: prog1 and prog2. The n or 1 or 2 part of the name stands for the statement from the list whose result you are interested in. ...
9
votes
Accepted
Find out, which mode is in use
See major-mode variable to find out major mode:
Symbol for current buffer’s major mode.
See cond function to do something depending on mode:
Try each clause until one succeeds.
Each clause ...
8
votes
Accepted
Shortening trees list with (setcdr (nthcdr 2 trees) nil)
Formal answer
In your expanded example you set the variable trees to a new value in:
(setq trees '(pine birch))
That is not what happens in the original example. In the original example really the ...
7
votes
How to properly use emacs and slime to program in Common Lisp
It is simple as:
Open emacs
Open your lisp file with fibonacci function
Issue M-x slime
Place you cursor over fibonacci function and press C-c C-c to evaluate/compile it in Slime.
switch to slime ...
5
votes
Accepted
How to pop an arbitrary element from a list?
Simply (pop (nthcdr n my-list)):
(let ((x '(a b c d e)))
(list (pop (nthcdr 2 x))
x))
;; => (c (a b d e))
3
votes
Accepted
how to specify an Cyclic list in lisp?
See the Elisp manual, node Circular Objects.
A circular list is one way to implement an infinite list.
For example (from the doc), this creates a list in which the first element recurs as the third ...
3
votes
Accepted
Confused by what Paul Graham says about locality in his book "On Lisp"
He's talking about side-effects of calling a function (and whether they can be avoided).
A purely functional language would not allow a call to f(x) to modify the value of the argument being passed to ...
2
votes
Accepted
Adjusting indenting for lisp if statements
Why is Emacs so weird?
Emacs indents lisp code as if it were Emacs Lisp, where if accepts unlimited else forms; unlike in Common Lisp, where if accepts at most 3 arguments.
What to do?
Tell Emacs ...
1
vote
Accepted
Is there a code example demonstrating a meaningful usage of the built-in function `funcall`?
Virtually all of the "real" examples are variations of the following theme: you have a list of functions and you want to call each function in turn (e.g. hooks are lists of functions - when ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
lisp × 13list × 3
slime × 2
common-lisp × 2
indentation × 1
elisp × 1
osx × 1
major-mode × 1
yasnippet × 1
functions × 1
variables × 1
elisp-macros × 1
repl × 1
arguments × 1
emacs-lisp-mode × 1
funcall × 1
localization × 1
ielm × 1