Hot answers tagged

5 votes
Accepted

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

(defvar wtf 10) made wtf bound dynamically so the variable g would get a closure which captured nothing. This is correct. However, this cannot explain what (f 20) returned. It can if, under lexical ...
phils's user avatar
  • 49k
5 votes
Accepted

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

No, it is always faster to add in the beginning (except that add-to-list has to scan the whole list anyway - as pointed out by @phils in a comment). However, performance is never an issue with add-to-...
sds's user avatar
  • 5,958
4 votes

the Term “Hash Notation“ in the Elisp Manual

Just for the second question: The “Hash Notation” is just a kind of notation using “#”. The mark “#” is named “hash mark”, so there is nothing to do with “hash function”.
Segrece's user avatar
  • 83
4 votes

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

Normally for that style of work, there's the concept of inferior shells, where Emacs launches an inferior process (a.k.a. a subprocess) for an interpreter linked to a buffer that shows a REPL and ...
JoL's user avatar
  • 191
4 votes

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

Naturally shell-command-to-string cannot return a string until the shell command in question has exited. In Emacs you generally can and should work directly with buffers -- there is often no need to ...
phils's user avatar
  • 49k
4 votes

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

A long comment instead of an answer. (SE limits the length of a comment.) Hi phils, this is my comment on your answer. potentially causing other functions, called later in the stack, to obtain an ...
shynur's user avatar
  • 4,282
3 votes

Advantages of setting variables with setq instead of custom.el?

Emacs 29 introduced a macro, setopt, for setting options outside of the customization interface. Like Drew explained, setq doesn't work right for options that use :set: for example try (setq show-...
Arch Stanton's user avatar
  • 1,555
3 votes
Accepted

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

Great question! Emacs detects the circularity of a and reports it before it descends far enough into b to discover that they are equal. The reason for the asymmetry is that Emacs only has to check for ...
sds's user avatar
  • 5,958
2 votes

Why does lisp-interaction-mode exist, and do we ever need it?

Besides the differences mentioned in the other answers, there is a small but major difference between 'lisp-interaction-mode' and 'emacs-lisp-mode', which is that in 'lisp-interaction-mode' lexical ...
dalanicolai's user avatar
  • 6,188
2 votes

the Term “Hash Notation“ in the Elisp Manual

It seems that the GNU Emacs Lisp Reference Manual has actually cleared up this misunderstanding. See Chapter 8 Hash Tables: Hash notation, the initial ‘#’ character used in the printed ...
shynur's user avatar
  • 4,282
1 vote

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

This answer is an extension of Phils answer. Your question shows the potential danger of locally binding special-declared variables. The convention of prefixing symbol names with library names ...
Tobias's user avatar
  • 32.6k
1 vote

the term “constant” in Elisp

Does it have only one definition just mentioned in that section? You also won't like the other usage of "constant". defconst can be used to define an intended-to-be-constant variable, but ...
phils's user avatar
  • 49k
1 vote
Accepted

the Term “Hash Notation“ in the Elisp Manual

I’m not really sure that there is a widely–recognized name for these things in Emacs Lisp. The language has grown and changed over time, and things have been added to the language as needed. You could ...
db48x's user avatar
  • 16k

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