Hot answers tagged

12

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 to turn a sequence of forms into a single form. In your examples, the first one uses progn and thus there is 1 form after :config. In the second, there are 3 ...


11

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 and then returns the value of the last one. Addendum: Without progn, sequence is not guaranteed, especially if subsequent expressions are dependent on the ...


11

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. In other words, progn will return the result of the last statement it contains, whereas prog1 will return the first, and similar for prog2. Today this ...


8

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 looks like (CONDITION BODY...). CONDITION is evaluated and, if the value is non-nil, this clause succeeds: then the expressions in BODY are evaluated and ...


8

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 cdr of (nthcdr 2 trees) is set. If you want to assign the intermediate value to a variable for better understanding you should introduce a new one, e.g., trees-...


5

It is simple as: Open emacs Open your lisp file with fibonachi function Issue M-x slime Place you cursor over fibonachi function and press C-c C-c to evaluate/compile it in Slime. switch to slime window and call (fibonachi 10) Screenshot example with hello-world function:


5

Simply (pop (nthcdr n my-list)): (let ((x '(a b c d e))) (list (pop (nthcdr 2 x)) x)) ;; => (c (a b d e))


1

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 to indent Lisp as if it were Common Lisp: (custom-set-variables '(lisp-indent-function 'common-lisp-indent-function)) (autoload 'common-lisp-indent-function "...


1

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 element: (setq x '(#1=(a) b #1#)) In your case: (setq ys '(1 2 3 4)) (setq ll (last ys)) (setcdr ll ys) C-h v ys: #1=(1 2 3 4 . #1#)


Only top voted, non community-wiki answers of a minimum length are eligible