Questions tagged [lisp]

Questions relating to editing code in Lisp-like languages (i.e., Common Lisp, Scheme and similar), and working with Lisp read-eval-print loops. Questions about specific languages should use the tag for that language (e.g., [common-lisp], [guile]). Note that Emacs's Lisp dialect is Emacs Lisp, with the tag [elisp]. Note: questions about editing Lisp in Emacs are on-topic, but general LIsp programming questions are not.

13 questions
29
votes
3 answers

When/why should I use progn?

I have seen progn being used quite a lot as I browse the configuration files of experienced Emacs users. I found this nice explanation of progn, but what I am really curious about is, what is the benefit of using this function? Take for example this…
elethan
  • 4,755
  • 3
  • 29
  • 56
6
votes
1 answer

Shortening trees list with (setcdr (nthcdr 2 trees) nil)

I am starting to learn elisp and working through this tutorial https://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dnew-function.html and I do not understand this basic example: (setq trees '(maple oak pine birch)) ⇒ (maple oak…
wolfv
  • 1,403
  • 1
  • 13
  • 30
2
votes
1 answer

Adjusting indenting for lisp if statements

I am learning common lisp and am trying to follow the style guide suggested by lisp-lang.org. In this style guide is an if statement style that I think makes the code more readable: (if (cond) (true-branch) (false-branch)) That is, the…
CL40
  • 123
  • 3
2
votes
1 answer

how to specify an Cyclic list in lisp?

How to specify a list, which's last element is referring to the first element? By specify I mean, for example, how to write a setq statement with this list. I have seen this in the documentation, but I can't find it anymore. Here some pointers: …
jue
  • 4,476
  • 8
  • 20
1
vote
1 answer

Validating Arguments to a Function

I would like to validate the argument to a function before its action is executed. The main concern is the passing of a void variable. How can I trap this? (defun is-it-bound(item) (if (boundp 'item) (message "bound") (message "not…
naugiedoggie
  • 334
  • 1
  • 8
1
vote
0 answers

What's the value in using a REPL for ELISP development?

What's the value in using a REPL? I've always wondered the advantages/disadvantages of using a REPL are (if there are any) as opposed to eval-print-last-sexp and then undoing the text printed (or saving it if that's what you're into). In other…
John DeBord
  • 550
  • 3
  • 13
1
vote
0 answers

SLIME not starting properly on MacOS Emacs

Pretty new to Emacs && Lisp, trying to get started.... I'm trying to get SBCL working via SLIME in Emacs 27.1 (9.0). After following the instructions to add the MELPA repo to my .emacs and installing slime from there, my .emacs looks like…
wr0ngway
  • 11
  • 2
1
vote
0 answers

Autodocument function for C Code

Suppose i have this line of code presenting a C function prototype: int sum_Func(int a, int *b) I want an Emacs lisp function that adds the function description (initialization) according to its elements: /** *sum_func- *@a: *@b: …
Ghost_tn
  • 11
  • 2
1
vote
1 answer

Find out, which mode is in use

Suppose I want to code something like this case mode in lisp-mode) do-something ;; shell-mode) do-other ;; latex-mode) do-different ;; esac What would be the best way to do this in lisp?…
Jan
  • 373
  • 2
  • 12
1
vote
1 answer

How to properly use emacs and slime to program in Common Lisp

I'm brand-spanking new to LISP. I'm trying to get started with it, and I installed Steel Bank Common Lisp as well as SLIME so I can program in emacs. As far as I know, Slime simply provides an interactive mode, whereas editting .lisp and .el files…
middleman3
  • 11
  • 1
  • 2
1
vote
1 answer

How to pop an arbitrary element from a list?

Q: how do I pop an arbitrary element from a list? Given the list '(a b c d e), pop returns a and destructively modifies the list to '(b c d e). How can I generalize this function so I could pop an arbitrary element (say, c)? I'm almost sure I've…
Dan
  • 32,584
  • 6
  • 98
  • 168
0
votes
3 answers

Is there a code example demonstrating a meaningful usage of the built-in function `funcall`?

In order to understand what the symbol funcall means I have checked out its documentation. If I understand it right after reading the docs this symbol represents a function which in my eyes can be always easily removed from the elisp expression…
Claudio
  • 410
  • 2
  • 11
0
votes
1 answer

Confused by what Paul Graham says about locality in his book "On Lisp"

https://sep.yimg.com/ty/cdn/paulgraham/onlisp.pdf On page 36 Paul writes the following: The conditions above do not guarantee the perfect locality you get with purely functional code, though they do improve things somewhat. For example, suppose…
John DeBord
  • 550
  • 3
  • 13