reddit / emacs

How to start developing for emacs?

Gus_Gustavsohn · 2022-08-27 16:24
I’m new to emacs and lisp, but I’m familiar with programming. I was wondering how to you guys develop and test for emacs or elisp, is there an interactive elisp interpreter available? How do you do it? Thanks in advance, I apologize in advance for my noob question.
lebensterben · 2022-08-27 16:45
> is there an interactive elisp interpreter available - you don't need an interpreter for writing code. - emacs is already a lisp interpreter
yigitemres · 2022-08-27 17:08
You can use `ielm` for REPL. In order to learn emacs and lisp you can look followings: [GNU Emacs Manual](https://www.gnu.org/software/emacs/manual/pdf/emacs.pdf) [GNU Emacs Lisp Reference Manual](https://www.gnu.org/software/emacs/manual/pdf/elisp.pdf) [An Introduction to Programming in Emacs Lisp](https://www.gnu.org/software/emacs/manual/pdf/eintr.pdf) And also I suggest following package [`lispy`](https://github.com/abo-abo/lispy) when you get familiar emacs bindings. I think best way to learn with these materials is that writing emacs functions/macros for your needs. For example I create library like file for controlling yee light from emacs. It basically sends powershell commands to [`yeecli`](https://github.com/skorokithakis/yeecli). After I develop this library I find that `(read-number)` function of emacs don't have any number range controller. So I build one by looking how `(read-number)` works. ;;;###autoload (defun my/read-number-range (prompt &optional default &key low &key high) "Modifies `read-number' to check if the number is between intervals." (unless (and (numberp low) (numberp high)) (unless (numberp low) (user-error "Please enter number instead of: %s(%s)" low (type-of low))) (user-error "Please enter number instead of: %s(%s)" high (type-of high))) (unless (< low high) (user-error "Please enter values correct order: %s ≰ %s" low high)) (let ((check (read-number prompt default))) (if (<= low check high) check (message "Please enter valid value between %d and %d." low high) (sit-for 1) (my/read-number-range prompt default :low low :high high))))
MitchellMarquez42 · 2022-08-27 17:16
Emacs is its own interpreter. You can write any lisp code, go to the closing parentheses, and type `C-x C-e`, and it will execute that code and display the result at the bottom. EDIT: you can also get built-in help for functions with `C-h f`, and variables with `C-h v`. To view all the keybindings, `C-h m`.
xtifr · 2022-08-27 20:21
A good starting place is the Elisp tutorial included with Emacs (this is separate from the *Emacs* tutorial). It can be found via `Help->More Manuals->Introduction to Emacs Lisp`. There's also a very detailed reference manual at `Help->More Manuals->Emacs Lisp Reference`. Elisp functions and variables also have useful help text attached to them which can be seen by typing `C-h f` for a function or `C-h v` for a variable, and then entering the name of the function or variable (will default to the one under the cursor). This will include a link to the actual source! In addition, there are several useful lisp libraries that come with Emacs, and the reference manuals for those are also included, and can be found with `C-h i`, which takes you to the index of manuals. Useful libraries include CL-Lib, which adds a *whole lot* of functionality borrowed from Common Lisp, and EIEIO, which adds a simple object system based *very* loosely on Common Lisp's OO features. A lot of third-party elisp libraries also add their manuals to the index of manuals. As far as interactive use of lisp, you can always execute a single line of lisp by pressing `M-:`, or you can start an interpreter loop with the `ielm` command. (That stands for "inferior emacs lisp mode", as it's an instance of Emacs Lisp running *under* the main Emacs Lisp interpreter, but I think of it as "interactive emacs lisp mode". I find the latter easier to remember.)
[deleted] · 2022-08-27 23:05
[deleted]
Acebulf · 2022-08-28 02:58
My general approach is to develop into my .emacs file, and then just M-x load-file when I want to see if it works.
flaviusmaximus7 · 2022-08-28 03:35
This [Youtube Channel](https://youtube.com/c/SystemCrafters) has a lot of emacs development, even there's a course to learn emacs lisp.
bitwize · 2022-08-28 13:43
Create or open a .el file, start typing defun's and stuff. C-M-x evaluates the defun point is on. That's the thing about Emacs. There's no setup. You just... change the running editor, save your changes, and you've created an extension.
Gus_Gustavsohn · 2022-08-28 13:49
Thanks! This is what I needed to get started. Simple, to the point, and clear. Thanks fellow redditor!