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
14
votes
4 answers

How do I fix the cursor to the middle of the screen in Emacs, so that the page moves, not the cursor?

I'd like to fix the cursor to the centre line of the screen, so that when I press Ctrl-N or Ctrl-P, the page itself moves up or down, and the cursor stays still. Has anyone got any tips on how to achieve this? Thanks Ed
Singletoned
  • 5,089
  • 3
  • 30
  • 32
14
votes
4 answers

buffer-local function in elisp

I would like to redefine an existing function foo, but for a specific buffer only. (defun foo () (message "Not done:(")) I was hopping this will do: (make-local-variable 'foo) (fset 'foo #'(lambda () (message "Done!"))) But it does not. Any…
VitoshKa
  • 8,387
  • 3
  • 35
  • 59
14
votes
1 answer

Get path to current emacs script file when loaded with -l parameter

From within a lisp file being loaded and run with emacs -l path/to/script/foo.el can I get the path to file being run? For example, is there some way to determine what path/to/script is from within foo.el? I am not very experienced with lisp so…
Jesse Vogt
  • 16,229
  • 16
  • 59
  • 72
14
votes
3 answers

Simplest Emacs syntax highlighting tutorial?

I would like to create only a syntax highlighting minor mode for Emacs. I have the "Writing GNU Emacs Extensions" by O'Reilly, but it does not go into any depth of detail. Is there a simple tutorial for a real or fake programming language…
Eli Schneider
  • 4,903
  • 3
  • 28
  • 50
14
votes
1 answer

How to configure spacemacs so that it executes code when you start it?

Foreword I know the title looks subjective, but I want this question to be a smooth introduction to spacemacs for newcomers not coming from emacs at all (which is my case). You might wonder why I decided to use spacemacs, which is a highly custom…
Zoé Martin
  • 1,887
  • 1
  • 16
  • 28
14
votes
2 answers

Emacs: annoying Flymake dialog box

I have the following lines in my ~/.emacs.d/init.el (custom-set-variables '(flymake-allowed-file-name-masks (quote ( ("\\.cc\\'" flymake-simple-make-init) ("\\.cpp\\'" flymake-simple-make-init))))) (add-hook…
baol
  • 4,362
  • 34
  • 44
14
votes
2 answers

What's so inferior about inferior-lisp?

As I've started learning about lisp, emacs, and ess (Emacs Speaks Statistics), I've come across this concept of inferior-this-or-that. For instance, there's an inferior-ess-mode, inferior-lisp, and Inferior Emacs Lisp Mode. In all these cases, it…
Ben Ogorek
  • 497
  • 7
  • 21
14
votes
2 answers

Check if a string ends with a suffix in Emacs Lisp

Is there a function that checks that a string ends with a certain substring? Python has endswith: >>> "victory".endswith("tory") True
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
14
votes
2 answers

How do I programatically set a Custom variable in Emacs Lisp?

In Emacs, some variables have special behaviors when set via M-x customize that do not get triggered when you set the same variable via setq. Is there a programmatic way to set such variables such that the special behavior will be triggered as if…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
14
votes
5 answers

How to write a key bindings in emacs for easy repeat?

Let's say I bind the key to a certain function as follows: (global-set-key (kbd "C-c =") 'function-foo) Now, I want the key binding to work as: After I press C-c = for the first time, if I want to repeat the function-foo, I don't need to press C-c…
shelper
  • 10,053
  • 8
  • 41
  • 67
14
votes
6 answers

How do I automatically (re)compile ELPA packages?

I'm now installing as much as I can through MELPA and Marmalade, and I manage my ~/.emacs.d using git. However, I have git ignore *.elc files. This means that when I install a package on one system and then start using another system, git pull only…
Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
14
votes
4 answers

How do I delete the newline from a process output?

I call git get the toplevel dir (according to Is there a way to get the git root directory in one command? ). (let ((tmpbuffer (get-buffer-create (make-temp-name "git")))) (call-process "git" nil tmpbuffer nil "rev-parse" "--show-toplevel") …
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
13
votes
3 answers

Get Emacs to ignore contents of \Sexpr{} command in Sweave document to prevent incorrect $-based syntax highlighting

When editing an Sweave document in LaTeX (using the Noweb mode), Emacs knows to "ignore" code that is in <<>>= blocks. However, for interstitial \Sexpr{} blocks, this isn't the case. Given that R references by columns via '$' and LaTeX uses $ to…
John Horton
  • 4,122
  • 6
  • 31
  • 45
13
votes
1 answer

How to pipe content in Emacs' buffer to external program, and print the result?

How to pipe the selected content in Emacs' buffer to external bash script and then print its output? The script can read data from pipe.
kuanyui
  • 782
  • 13
  • 23
13
votes
6 answers

Can I use ido-completing-read instead of completing-read everywhere?

I'm a big fan of ido-mode, so much so that I would like to use it for things like describe-function or find-tag and so on, without having to write something like in "Can I get ido-mode-style completion for searching tags in Emacs?" for each…
haxney
  • 3,358
  • 4
  • 30
  • 31