Questions tagged [elisp]

Emacs Lisp is the extension language for the GNU Emacs text editor, and in fact, most of the functionality of Emacs is implemented using Emacs Lisp. Users generally customize Emacs' behavior by adding Emacs Lisp statements to their `~/.emacs`, or writing separate packages.

Emacs Lisp is the extension language for the GNU Emacs text editor, and in fact, most of the functionality of Emacs is implemented using Emacs Lisp. Users generally customize Emacs' behavior by adding Emacs Lisp statements to their ~/.emacs or ~/.emacs.d/init.el file, or writing separate packages. A guide to learning Emacs Lisp for non-programmers can be found here.

Emacs Lisp differs from most other lisps in two main ways:

  1. It has special features for scanning and parsing text, as well as features for handling files, buffers, arrays, displays, and subprocesses. This is due to the fact that it is designed to be used in a text editor.
  2. It uses primarily dynamic scope as opposed to lexical scope. This was done very intentionally, the reasons are well explained in the 1981 paper on Emacs. Lexical scope has been introduced only recently and, while not yet widely adopted, is expected to become increasingly important in future versions according to the manual.

Wisdom from the Stack

Emacs on Stack Exchange

3773 questions
52
votes
9 answers

emacs list-buffers behavior

In GNU emacs, every time I hit Ctrl-x Ctrl-b to see all of my buffers, the window is split to show the buffer list, or if I have my window already split in 2 (for instance, I will have a shell running in the lower window), the buffer list appears in…
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
51
votes
4 answers

How can I check if a current buffer exists in Emacs?

I would like to write a function which takes action if a give buffer name already exists. For example: (if (buffer-exists "my-buffer-name") ; do something ) Does elisp have a function that will check the for the existence of a buffer similar…
oneself
  • 38,641
  • 34
  • 96
  • 120
51
votes
2 answers

How to capture standard output of a shell command in elisp?

I want to run a shell command within Emacs and capture the full output to a variable. Is there a way to do this? For example, I would like to be able to set hello-string to "hello" in the following manner: (setq hello-string…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
51
votes
7 answers

Ctrl+U in emacs when using evil key bindings

I'm using the wonderful evil package for vim bindings in emacs. The one key that is not right is Ctrl+U. It is still the emacs prefix, rather than "up". Does anybody have a solution for that in some lisp code for my .emacs? Thanks.
justingordon
  • 12,553
  • 12
  • 72
  • 116
51
votes
4 answers

Confusing about the Emacs custom system

There are several similar setting functions: set & setq set-default defcustom custom-set-value custom-set-variables customize-set-value customize-set-variable so, what's the difference between these functions? If I want setting my own…
hbin
  • 2,657
  • 1
  • 23
  • 23
50
votes
8 answers

Render Markdown in Emacs buffer

Is it possible to present Markdown rendered in an Emacs buffer using Emacs' own buffer text formatting capabilities? Emacs in graphical environments has rich text presentation capabilities (font styles, colors, links and even images) so it should be…
Markus Miller
  • 3,695
  • 2
  • 29
  • 33
50
votes
10 answers

How to modularize an emacs configuration?

I've decided to rewrite my .emacs from the ground up, and I want to setup something that's modular, in order to avoid a dreaded 1k+ LoC init.el file... I think there are some basic concerns that each configuration needs to address : global…
julien
  • 1,879
  • 2
  • 20
  • 29
49
votes
2 answers

emacs lisp call function with prefix argument programmatically

I want to call a function from some elisp code as if I had called it interactively with a prefix argument. Specifically, I want to call grep with a prefix. The closest I've gotten to making it work is using execute-extended-command, but that still…
mgalgs
  • 15,671
  • 11
  • 61
  • 74
48
votes
2 answers

Elisp List Contains a Value

How do you check, in elisp, if a list contains a value? so the following would return t: (contains 3 '(1 2 3)) but (contains 5 '(1 2 3)) would return nil.
Nathaniel Flath
  • 15,477
  • 19
  • 69
  • 94
46
votes
4 answers

Tips for profiling misbehaving Emacs Lisp?

I customize Emacs a lot. Recently, I added something to my .emacs configuration that sporadically pegs my CPU at 100%, but I really don't know what it is. If I press C-g a bunch of times, eventually I'll get a message below the minibuffer asking me…
EnigmaCurry
  • 5,597
  • 2
  • 23
  • 15
45
votes
15 answers

How to maximize Emacs on Windows at startup?

This is driving me crazy: I simply want Emacs to maximize to whatever screen resolution I have at startup. Ideally I like a cross-platform (Windows & Linux) solution that works on any screen resolution, but I can't even get it to work on just Window…
polyglot
  • 9,945
  • 10
  • 49
  • 63
45
votes
3 answers

When should Emacs #'function syntax be used?

Basically, when should I use Emacs Lisp's function procedure? I haven't found any examples in which there's a difference in behavior if you pass functions as arguments 'like-this or #'like-this. In fact, if I evaluate (eq 'goto-char #'goto-char) it…
Josh Tilles
  • 1,281
  • 11
  • 19
44
votes
6 answers

Emacs comment/uncomment current line

I know there's already an Emacs question on this, and that it was closed, but I find it quite relevant and important. Basically, I want to comment/uncomment the current line. I was expecting this to be fairly easy with a macro, but I found that it…
David Gomes
  • 5,644
  • 16
  • 60
  • 103
43
votes
3 answers

How to remove a key from a minor-mode keymap in Emacs?

I have globally assigned C-c/ to ace-jump-mode but reftex-mode (a minor mode for citations used with AucTeX) overrides this key with some function I never use. I tried local-unset-key but it only unbinds keys from the current major mode's map. How…
malana
  • 5,045
  • 3
  • 28
  • 41
43
votes
4 answers

How easily change font size in spacemacs?

How do change the font size in spacemacs? Do I need to download additional packages such as source code font? I tried changing the font size in the configuration file, but the font size does not change. I am having trouble installing source code…
linuxfreebird
  • 799
  • 2
  • 8
  • 16