16

There are all kind of cool programming language modes in Emacs, written in elisp, but apparently no special support for elisp itself.

Since slime is not working for elisp, I ask myself if all that elisp code is just hacked in the scratch buffer? Is there no need for something like slime when writing elisp, or is it simply not there? Is anybody using ECB and semantic for bigger elisp projects?

Thorsten
  • 3,451
  • 3
  • 20
  • 25
  • 1
    What features are you looking for? Admittedly I don't use other lisps, so I'm unfamiliar with the likes of slime, but I've never found Emacs lacking in its support for elisp development. There may be existing ways of doing what you want. – phils Mar 08 '11 at 21:32
  • 3
    Since I'm starting out with elisp, it's more a general question. I would like to know how others approach elisp programming, just to make sure I don't miss something important. The google-space is almost empty for 'elisp setup'. If it's just opening an .el file, using the loaded emacs-lisp-mode and the build in debugger (or edebug), I'm reassured. – Thorsten Mar 08 '11 at 21:58

7 Answers7

29

ielm is the Emacs Lisp REPL: Interactive Emacs Lisp Mode.

M-x ielm gets you there.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
  • but there doesn't seem to be a good way send parts of a buffer to the process. I'd like to do what elpy or ess let me do, which is send a region, buffer, or file to the interactive process, so I can play with it there – Dodgie Dec 18 '16 at 21:02
  • @Dodgie: to "send a region" do `M-x eval-region RET`. Usually you'd use either `C-M-x` or `C-x C-e`, tho. – Stefan Oct 26 '17 at 02:16
15

Emacs itself comes with Emacs Lisp support. Basic-to-intermediate things like completion (M-TAB), library search (M-x apropos), documentation (C-h f, C-h v, C-h S), running code on-the-fly (C-M-x, M-:) operate directly in the running Emacs.

Slime's primary purpose is interaction with an external process. You don't need that for Emacs Lisp (unless you're developing for a different version of Emacs, but that's a rare concern).

The features of ECB and semantic are mostly useful for large projects (consisting of more than a handful of source files). People don't tend to write large projects in Emacs Lisp.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
  • 8
    One could even say that the point of Slime is to make CL development almost as convenient as Elisp is out of the box. –  Mar 08 '11 at 23:32
13

There's always emacs-lisp-mode, which (at least in Emacs 23) is automatically loaded whenever you edit a .el file. This appears to be what many emacs lisp hackers use to write their programs. It has a few nice features (like compiling or evaluating a buffer, some debugging tools, profiling). The *scratch* buffer is by default edited from lisp-interaction-mode, which is a bit different.

It's not quite as full featured as, say, slime (elisp has a much smaller community than common lisp), but it definitely works. You'd have to poke around the documentation and experiment with the mode to see what kind of features you can use.

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
  • 2
    So there are 3 choices: scratch-buffer and ielm for interactive use and emacs-lisp-mode for more "serious" elisp programming. Just a moment ago I found a huge collection of Yasnippets for elisp, even for the file header, that might speed up things even further: http://www.emacswiki.org/emacs-en/AndyStewart_YasnippetTemplate#toc2 – Thorsten Mar 09 '11 at 18:53
  • 3
    SLIME was written because an elisp hacker wanted something as nice as edebug, ielm, and related tools for Common Lisp. It would be hard to verify, but I'd guess that the number of elisp programmers is much greater than the number of Common Lisp programmers. – Xach Mar 09 '11 at 19:10
10

As indicated, Emacs is already the definitive elisp development environment, and internally provides you with most of the functionality you are likely to want.

You might potentially also use ctags/etags to generate an external index for your elisp code base, if you were wanting to jump to function definitions which were not already loaded (and lacked autoload declarations). M-x find-function RET handles this otherwise. (I bind that to C-hC-f)

The "apropos" functions are key to finding things in general. I use the following bindings for easy access:

(define-prefix-command 'Apropos-Prefix nil "Apropos (a,c,d,i,l,v,C-v)")
(global-set-key (kbd "C-h C-a") 'Apropos-Prefix)
(define-key Apropos-Prefix (kbd "a")   'apropos)
(define-key Apropos-Prefix (kbd "C-a") 'apropos)
(define-key Apropos-Prefix (kbd "c")   'apropos-command)
(define-key Apropos-Prefix (kbd "d")   'apropos-documentation)
(define-key Apropos-Prefix (kbd "i")   'info-apropos)
(define-key Apropos-Prefix (kbd "l")   'apropos-library)
(define-key Apropos-Prefix (kbd "v")   'apropos-variable)
(define-key Apropos-Prefix (kbd "C-v") 'apropos-value)

;; Use prefix arg (C-u) to see more results for a call,
;; or uncomment the next line to do this by default:
;; (setq apropos-do-all t)
;; See C-h v apropos-do-all RET for details.

I also enable eldoc-mode and I have imenu-ido-goto-symbol bound (but very rarely utilised).

There are other libraries that may prove useful. I know that some people swear by ParEdit, for example. Admittedly, it's a bit difficult to target a search for elisp libraries which are useful for writing elisp. I'm not sure if the Emacs Wiki has a category for this?

phils
  • 71,335
  • 11
  • 153
  • 198
6
  • I generally use emacs-lisp-mode in preference to the default mode for *scratch*. 99% of the time I want to save even throw-away, interactive tests (at least temporarily), so I more often use a *.el file than *scratch*.

  • Icicles can help a lot when interacting with Emacs Lisp. The ways are too numerous to list here. Here are two overviews that can give an idea:

http://www.emacswiki.org/emacs/EmacsNewbieWithIcicles

http://www.emacswiki.org/emacs/Icicles_-_Nutshell_View

Drew
  • 29,895
  • 7
  • 74
  • 104
1

I think add this to you .emacs

(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)

will be very helpful.

algking
  • 367
  • 3
  • 7
  • `M-.` already does that by default (via the `xref` library) in recent enough versions of Emacs. – Stefan Oct 26 '17 at 02:14
0
M-x edebug-defun 

to debug the function I think these is the best debug tools for elisp.

algking
  • 367
  • 3
  • 7