Skip to main content

Questions tagged [elisp]

*ONLY* for questions about Emacs Lisp as a language, compared to other languages, in particular, compared to other Lisp dialects. That is, it is for questions *about the language* itself. *DO NOT USE IT* for questions about *using* Emacs Lisp, because most questions here are about using Elisp, and adding this tag to them is redundant. Emacs Lisp is the scripting and programming language that the Emacs editor is built on.

0 votes
1 answer
45 views

How are markers implemented?

Here is a quote from the Elisp documentation about markers: A “marker” is a Lisp object used to specify a position in a buffer relative to the surrounding text. A marker changes its offset from the ...
Rob N's user avatar
  • 671
0 votes
1 answer
118 views

How to print and read a list to(from) a file?

I'd like to save a (extremely minimal) database made of a lisp list and then read it back. The list will look like something as follows: (:foo "bar" :baz "foobar" :foobaz "baz&...
ygy's user avatar
  • 103
9 votes
3 answers
479 views

Lambda in `defun` Captures the Lexical Environment, But in `let` It Doesn't

My example is simplified: (defvar wtf 10) (defun f (wtf) (lambda () (cl-incf wtf))) (setq f (f 20)) (setq g (let ((wtf 30)) (lambda () (cl-incf wtf)))) (list (funcall f) ...
shynur's user avatar
  • 5,578
4 votes
1 answer
659 views

Is it faster to add an element at the beginning of a list with add-to-list than at the end?

I've noticed that some people use a t at the end of this code: (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) that t makes it append at the end of ...
Zoli's user avatar
  • 451
1 vote
2 answers
235 views

the term “constant” in Elisp

The definition of the term “constant” is clarified in the GNU Emacs Lisp Reference Manual, section 6.2: For purposes of evaluation, the array is a constant—i.e., it evaluates to itself. In the ...
shynur's user avatar
  • 5,578
7 votes
1 answer
137 views

“(equal a b)⇒t” whereas “(equal b a)⇒error”

GNU Emacs Lisp Reference Manual, 2.8 Equality Predicates: Comparing circular lists may therefore cause deep recursion that leads to an error, and this may result in counterintuitive behavior such as (...
shynur's user avatar
  • 5,578
4 votes
3 answers
298 views

the Term “Hash Notation“ in the Elisp Manual

I'm reading GNU Emacs Lisp Reference Manual, and I see the phrase "hash notation". Two places in the document seem to have different interpretations, so I have 2 questions. 2.1 Printed ...
shynur's user avatar
  • 5,578
4 votes
2 answers
657 views

Is there any function that allows me to execute code on the run?

I'm a Vim user who is trying to migrate to emacs. On Vim, I've been using the following vimscript function to execute code: function! ExecuteOnTerminal(type) range if (&ft=='bash' || &ft=='...
raylight's user avatar
  • 237
1 vote
0 answers
37 views

Insert output of slow external process in current buffer, character-by-character

Imagine in the current buffer I have the text: Hello Bye I want to call an external program and add the output of it at the end of the buffer. The tricky thing is that the external program provides ...
scaramouche's user avatar
  • 1,786
4 votes
4 answers
5k views

How can I create block (multiline) comments in Lisp code?

How can I do multiline / block comments in Lisp code - e.g. in the init.el. In Python I would do it like this """Block comment """ In C/C++ like this /* Block comment */ ...
buhtz's user avatar
  • 739
1 vote
1 answer
258 views

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)...
naugiedoggie's user avatar
1 vote
1 answer
245 views

Does elisp have a way to jump to (goto) labels in the code, ala common lisp's go?

Does elisp have a way to jump to (goto) labels in the code, ala common lisp's go? (tagbody (setq val 2) (go lp) (incf val 3) lp (incf val 4)) => NIL val => 6 PS: This is a ...
HappyFace's user avatar
  • 860
1 vote
1 answer
128 views

Access hash table by value, not key?

Q: how can I access a hash table by its value, not its key? Association lists can be accessed via either their key or their value: (setq alist '((a .1) (b . 2) (c . 3))) (assoc 'a alist) ...
Dan's user avatar
  • 33.2k
7 votes
2 answers
1k views

Underscore in if-let

I often find myself wanting to do something like this: (if-let* ((foo (get-foo)) (_ (conditionp foo)) (bar (get-bar-from-foo foo))) ...) As an alternative to: (let ((foo (get-...
C4ffeine Add1ct's user avatar
2 votes
4 answers
1k 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,571

15 30 50 per page
1
2 3 4 5
28