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.

Emacs Lisp is a dialect of the Lisp programming language used as a scripting language by Emacs. It is used for implementing most of the editing functionality built into Emacs, the remainder being written in C (as is the Lisp interpreter itself).

The most common way to customize Emacs is by Emacs Lisp expressions in your init file, ~/.emacs or ~/.emacs.d/init.el.

Emacs packages are also predominantly written in Emacs Lisp. See A guide to learning Emacs Lisp for non-programmers for reference. The Emacs Lisp Reference is also viewable in Emacs with C-him elisp RET.

Use for questions about the language itself, in particular, its relation to other Lisp dialects and differences from them.

Please DO NOT use for questions about using Elisp, e.g., snippets of code in your customizations or questions about how to write an application. Use only for questions about the nature of the language itself.

When available and appropriate, use more specific tags about the aspects of the language, such as elisp-macros, variables, lexical-scoping, etc. You can use such tags for questions about using such things, as well as questions about their nature/meaning.

Wisdom from the Stack

414 questions
46
votes
2 answers

Why does elisp not have namespaces?

Q: Why does elisp not have namespaces, and how could we get them? Elisp does not have namespaces other than the global one, which has led to the coding convention of prefixing all global functions, variables, and constants with a unique…
Dan
  • 32,980
  • 7
  • 102
  • 169
40
votes
2 answers

Optional parameter defaults

Emacs Lisp does not have syntactical support for non-nil defaults of optional parameters. What is the recommended idiom for supplying these parameters? To clarify my point, here is one overly explicit way of doing so. (defun command (a &optional…
Matthew Piziak
  • 6,038
  • 3
  • 31
  • 79
25
votes
1 answer

What is the function `purecopy` needed for?

I was browing through compile.el and I noticed this construction: (defcustom compile-command (purecopy "make -k ")) The purecopy docs state: purecopy is a built-in function in `C source code'. (purecopy OBJ) Make a copy of object OBJ in pure…
dgtized
  • 4,199
  • 21
  • 41
22
votes
4 answers

How to get element number in a list?

Q: how do I get the element number in a list? nth gets element number n from a list: (nth 2 '(a b c d)) ; => c I'd like to do the reverse: get the element number given the element: (some-function 'c '(a b c d)) ; =>…
Dan
  • 32,980
  • 7
  • 102
  • 169
21
votes
3 answers

Swap two variables in Elisp

Suppose I have (setq a 1 b 2) How can I elegantly swap the values of a and b without using a temporary variable?
PythonNut
  • 10,363
  • 2
  • 30
  • 76
14
votes
2 answers

Is there a general way to 'expand' a list for to be used as individual arguments to another function?

For example, say I have a list of strings L, perhaps from an &rest argument. What can I do to L that would have the same effect as the following? (concat (first L) (second L) ... (last L)) (I know mapconcat would work here for this example, but…
Sean Allred
  • 6,921
  • 18
  • 86
13
votes
3 answers

What's the easiest way to implement a function like format-time-string

The format-time-string function takes a string, and replaces a set of special constructs in that string (characters preceeded by %) with some specific text. I'd like to implement a functionality like that in a function of my own: I have an alist…
Malabarba
  • 23,148
  • 6
  • 79
  • 164
13
votes
1 answer

Rename local variable refactoring

Is there an elisp refactoring tool that can rename local variables and function arguments? I would like to be able to turn: (defun my-func (s r) ... (use s .. r)) into: (defun my-func (string replacement) ... (use string ..…
Gracjan Polak
  • 1,102
  • 6
  • 21
13
votes
3 answers

Move selected lines up and down

I have been using eclipse for a little while now and I did find some shortcuts highly useful, in particular the ability to move a rectangular selection of lines up and down using Alt+Up/Down. I have been looking around for this functionality in…
hfhc2
  • 308
  • 3
  • 13
12
votes
2 answers

Elisp reimplementations

Emacs implements an interpreter for elisp in C which serves as the de facto reference implementation. Are there any other implementations of elisp in other languages (particularly Javascript)? What is a minimal set of primitives necessary to fully…
Paul Miller
  • 301
  • 1
  • 4
12
votes
2 answers

How can I modify Elisp's reader?

Modifying the reader would allow introducing new read-syntax (such as #(hash table) and '(quoted)). Many Lisps have this​​​​​ capability, but no such facility seems to exist for elisp.
Sean Allred
  • 6,921
  • 18
  • 86
12
votes
3 answers

String equality, ignore case?

Q: how does one test string equality but ignore case? I've got a situation in which I'd like to compare strings but ignore case. Case is significant for string-equal, and apparently is insensitive to case-fold-search: (string-equal "string"…
Dan
  • 32,980
  • 7
  • 102
  • 169
11
votes
2 answers

Is using require multiple times on the same symbol idempotent?

Is require idempotent? i.e. do (require 'helm) and (require 'helm) (require 'helm) end with the same result?
PythonNut
  • 10,363
  • 2
  • 30
  • 76
11
votes
2 answers

An efficient set data structure in elisp

Does elisp provide a builtin efficient set data structure, similar to set in Python and std::set in C++?
xuhdev
  • 1,899
  • 14
  • 31
11
votes
3 answers

How can I answer a minibuffer prompt from elisp?

I occasionally find myself using interactive functions inside of a function that I'm writing for my own use. If a function asks for some information (e.g. "Output file: ~/") is there a general elisp way to add text to the minibuffer and then press…
Seth Rothschild
  • 380
  • 1
  • 11
1
2 3 4 5 6