this post was submitted on 22 Nov 2023
3 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I'm a new emacs user and I've been using doom emacs for a while now and i'm willing to learn Elisp, but found out that it might not be as easy as it might seem at first, because as i found out, lisp is quite different from other programming languages that i'm used to, especially knowing that i'm not a programmer by any means and my programming knowledge is very little, not mentioning that elisp is pretty old so the learning resources might not be as much as other more popular programming languages

so my question is, Is it worth it?

like what is the level of mastery do i need to achieve to start implementing custom elisp in my configs to enhance my emacs experience?

and how exactly can i improve my emacs experience if i learned elisp?

in other words, how rewarding it would be

top 43 comments
sorted by: hot top controversial new old
[–] WatermellonSugar@alien.top 2 points 1 year ago

Lisp and Scheme are marvelous 60s-70s hippie acid-head languages. "Hey, let's use a small set of primitives and treat code and data the same and we can run huge worlds with a tiny, recursive interpreter!"

By the time you get to Emacs though, many huge worlds have been built, and navigating the huge world(s) that small set of primitives has created can be..uh..daunting -- both because of 1000s of people's contributions and because of the weight of history (e.g. booleans are "predicates" -- from calculus -- thus all the "_p" names).

That said, at it's core, it's elegant and lovely.

https://preview.redd.it/g641rtwx502c1.jpeg?width=640&format=pjpg&auto=webp&s=1d6fe005a93830eb624d5fd0324ae97c84135f86

[–] sleekelite@alien.top 1 points 1 year ago

It’s sort of a silly question.

To customise emacs beyond clicking around in ‘customise’ you need to write elisp. If you learn little elisp then you can only customise it using other people’s code, if you learn a lot of it then you can write an mua.

You decide where you want to be on that spectrum.

[–] rileyrgham@alien.top 1 points 1 year ago

Well, if you want to customise Emacs - obviously it's worth learning. Im not quite sure where you get that idea that because its "old" then its support is somehow worse than "more popular" languages. It has great documentation - in editor too.

[–] 7890yuiop@alien.top 1 points 1 year ago

If you're sold on sticking with Emacs, then learning elisp will unquestionably pay dividends, and the more you learn the more you'll be able to do (but you don't need to understand everything in order to do anything).

and how exactly can i improve my emacs experience if i learned elisp?

That's the thing -- it's up to you. The ability to "scratch any itch" is what elisp give you. That doesn't mean any given thing is easy to do (although it might be) but, to a significant extent, if you can identify a problem then implementing a solution is also a possibility.

[–] cazzipropri@alien.top 1 points 1 year ago (1 children)

I'm not in love with elisp but I learned enough of it to make emacs do what I want.

I'll admit without shame that the for complicated stuff, I do it all in python helpers, and I just use elisp to marshall data to and from python.

A better elisp developer than me would do everything in elisp... but I need to get things done quickly and dirty.

[–] centzon400@alien.top 1 points 1 year ago

I'll admit without shame that the for complicated stuff, I do it all in python helpers

Have to laugh. One of my first paying jobs in tech was to mungle DSSSL/SGML and make presentable HTML.

Because all I knew was Perl… I tried this using regular expressions.

TL;DR don't let zoology undregrads near computers.

[–] void_linux@alien.top 1 points 1 year ago

You need surprisingly little if you already have general lisp knowledge to actually be able to write your own configs. Hell, you don't need any knowledge just work with it as if it's some config file grammar. I started with doom and after a year or so took a step into vanilla Emacs. My Emacs config is exactly how I want it now. Don't get me wrong it's not life changing compared to Doom but if you have a weekend spare and you are feeling up the challenge, give it a shot.

[–] chandaliergalaxy@alien.top 1 points 1 year ago

It was for me.

After reading Paul Graham wax lyrical about lisp ( see essay Beating the Averages), I wanted to learn a lisp. Emacs is the most practical lisp in the sense that even a small amount of it can do something immediately useful (for emacs), and I wasn't going to replace R / Python / Fortran with Common Lisp or Scheme for my scientific computing needs.

Not sure it expanded my mind like I had expected in the end. Apart from the homoiconicity and macros, most major ideas introduced by lisp has made its way into other mainstream languages.

But it's a beautiful language and at least I know now that I'm not missing out on something huge, and that gives me piece of mind (maybe macros are huge and I'm toying with them in Julia at the moment).

[–] ClerkOfCopmanhurst@alien.top 1 points 1 year ago (1 children)

When I want to add an automatic garage door, I don't go on r/ElectricalEngineering and ask how rewarding learning EE can be. I decide wtf I want to have happen, then google accordingly.

[–] emacs-ModTeam@alien.top 1 points 1 year ago

This has been removed, as it is not very civil; please attack ideas, not people.

[–] MitchellMarquez42@alien.top 1 points 1 year ago (1 children)

Yes. It's worth it.

If you've ever tweaked your Doom config, you're already writing elisp. Going from setting options to writing new modes will certainly take time, but lisp is a language that builds on itself.

In fact, Emacs+elisp is one of the best systems for learning by doing. C-h f, C-h v, C-x C-e, etc will get you far. The built in tutorial is absolutely worth going thru, and understanding lisp will improve your understanding of other languages as well.

[–] _Lycea_@alien.top 1 points 1 year ago (2 children)

There is a buildin tutorial ? where can I find it , since I also would love to get started learning more elisp!

[–] spauldo@lemmy.ml 1 points 1 year ago* (last edited 1 year ago)

There's a tutorial for using Emacs - the key combination to enter the tutorial is on the welcome screen (I think it's "CTRL-h t" but I don't have it in front of me). It doesn't cover elisp.

There are two elisp manuals available via the info system (CTRL-h i), a reference manual and an introductory text. They're also available in other formats and are online as well. The reference manual is kept current with every release. I'm not sure about the introductory text, but the core of elisp hasn't changed (I think) since lexical scoping was made the default several years ago.

Edit: added availability of manuals in non-info formats.

[–] a-concerned-mother@alien.top 1 points 1 year ago

If you prefer a more modern looking interface there is also https://emacsdocs.org/docs/elisp/Emacs-Lisp

[–] Nondv@alien.top 1 points 1 year ago

In my experience, you don't really need to know much elisp (if any) to be able to configure your editor unless you're building your own plugin. Once you have a specific problem, you just Google and use Emacs internal docs.

That said, elisp has an interesting trait: variables are dynamic by default. It's quite different from other languages so it may be amusing to learn more about (if you do find that interesting, check out PicoLisp)

[–] unix_hacker@alien.top 1 points 1 year ago

Emacs Lisp is probably one of my favorite and most used programming languages outside of work. Emacs is a very pleasant environment to program in, because it's a Lisp image that you can poke and prod. I literally will do everyday math in Emacs Lisp now if I am at my computer.

Also, helpful tip: since Emacs Lisp is so old and LLMs are often based on old data, I find that tools like ChatGPT are very good at producing working Emacs Lisp.

This is helpful because I find that many Emacs functions and macros are not named in a way that is easy to search by.

[–] codemuncher@alien.top 1 points 1 year ago

Elisp isn’t just a programming language it’s an execution environment and it doesn’t make a lot of sense to consider them separately.

For example the largest abstraction in elisp is the buffer. A lot of core language features revolve around and are greatly modified by the buffer. For example variable bindings can typically be overrides in buffer-local variables.

Furthermore there’s a lot of editor specifics that are interesting. Text properties are the least of which. Buffer narrowing is another. But what about… fields? Judicious use of fields limits where you can type into a buffer. Consider the customize user interface for example.

Basically emacs is a complete tui development environment.

[–] elimik31@alien.top 1 points 1 year ago (1 children)

Emacs Lisp was one of my first programming languages. As a physics student I had learned C++ (badly) as my first programming language, choose Emacs as an editor for that and also started using Lisp for configuration (maybe not a smart choice for productivity and in hindsight, but I had fun). Compared to an old-school compiled language I found Lisps to be easier, no worrying about types, no weird syntax, just functions (and macros). And most importantly coding in Elisp (and other Lisps) is incredibly interactive, just C-x C-e to eval any expression and see the result of any expression. For ELisp Emacs has excellent "IDE" features out of the box, you with ELdoc you see signatures of the function at point, can jump to defenitions, see docstrings etc. Also it helps that Emacs functions and variables have excellent docstrings (which the first physicist-written C++ codebases that I had worken on had not, in some cases basic Doxygen but it's not as nice. Later I learned Python and I think it's the better programming language today for learning how to code, and as an interpreted languages it also has some interactivity with its REPL (IPython) and Jupyter, docstring support, ducktyping etc. But I really appreciate how "friendly" Lisps are in relative terms considering how old they are, no wonder they had been used for introductory computing courses at MIT in the past. But there's a lot of weirdness and naming conventions that seem archaic today (things like cddar).

Regarding how rewarding it is, I think very much so! In other programming languages I found it hard to find project ideas that are really useful to me in my every day. But I use an editor daily and it's incredibly easy to find something that I'd like to tweak and I can come up with a function in a *scratch* butter, evaluate it and use it interactively or hook it to some mode for example.

Most of my coding I had done was just doing configuration and some interactive helper functions, things like adding a custom completion backend (capf) to a special mode, a confirmation warning when I forget to add an email subject and things like that. But in total I wrote more Elisp than the recreational coding I had done in most of my other programming languages.

Despite saying I studied physics in my research I leaned heavily on the coding-heavy work and am soon entering an IT job in industry, so I'm totally someone who enjoys coding. But I think Emacs gave me a slight push in that direction.

[–] arensb@alien.top 1 points 1 year ago

naming conventions that seem archaic today (things like cddar).

I remember the bumper sticker “my other car is a cdr”.

[–] github-alphapapa@alien.top 1 points 1 year ago (2 children)

Is it just me or have there been a lot of posts lately from accounts with overall negative comment karma.

[–] invsblduck@alien.top 1 points 1 year ago

In this case, his negative comment karma comes from heavy involvement in subs regarding overseas affairs (i.e., opinions about current events in Israel). His question about learning elisp was genuine.

[–] fragbot2@alien.top 1 points 1 year ago (1 children)

Not just you and it's not just /r/emacs or /r/org-mode, I've seen them in other places as well. While the guy in /r/org-mode wasn't one, most of them write so poorly that they must be ESL people and argue about minute things that well-adjusted (genuine?) people wouldn't argue about.

The other thing I'm seeing is an increase in duplicated posts to multiple forums asking fragmentary, barely coherent questions. Writing this, I just had the obvious epiphany that my assumption--there's a person at the other end--might be wrong.

[–] github-alphapapa@alien.top 1 points 1 year ago

Hm, yeah, imagine some kind of service that takes a question from a user and posts it on Reddit, then feeds the answers into its own ML model and gives something back to the user (with a significant delay, obviously, so maybe more for training purposes).

There was a post here within the past couple of months that, when I looked at its account history, seemed to be obviously some kind of bot, but its writing was coherent enough to seem authentic in isolation.

Seems like a dark time for the Web is coming. :/

[–] thetemp_@alien.top 1 points 1 year ago

Lisp (and especially Emacs Lisp) isn't harder than other languages. I'm not a professional programmer either, but I've dabbled in languages from BASIC to bash to PERL, JavaScript, and Python. In my experience, Elisp has been the easiest of all of them.

Once you wrap your head around how lists work in Lisp, it all comes together pretty quickly. And Emacs's self-documenting nature makes learning it that much easier.

The syntax is more consistent than any other language I've come across. It's lists all the way down.

Just do "C-h R eintro RET" and start learning. Do "M-x find-library RET" to read the code of your favorite package and figure out how it works.

[–] Psionikus@alien.top 1 points 1 year ago (3 children)

It's pretty tiny compared to a lot of languages considering that most of what you use it for is working with Emacs, which has a small number of intrinsic types like buffers, windows, frames, text properties etc.

Compared to being the kind of person who reads use-package like JSON and treats it like a declaration language, you will be light years ahead at configuration if you just know lists, quoting, alists, plists, and writing functions. Users who don't go at least that far will be constantly shooting themselves in the foot and spending much more time with minor, novice level bugs that are completely obvious.

[–] need_a_nick@alien.top 1 points 1 year ago (1 children)

Do you have a good resource for learning this?

[–] Psionikus@alien.top 1 points 1 year ago

I'm making what I believe to be a better one.

The elisp manual is not bad. Between shortdocs and that, using the scratch buffer or ielm, it's pretty fast to get going. I would save an elisp buffer to a file at first. Scratch is ephemeral by default. Like anything, reinforcement and consistent effort go farther than having the perfect approach.

[–] deaddyfreddy@alien.top 1 points 1 year ago

Compared to being the kind of person who reads use-package like JSON and treats it like a declaration language, you will be light years ahead at configuration if you just know lists, quoting, alists, plists, and writing functions.

Hey, use-package user here. I switched from my half-baked NIH init framework with a bunch of functions and other stuff you're talking about, and never looked back.

My 1670kLoC config doesn't contain any definitions and mostly declarative. If I need to defun something (so, there's no package with similar functionality) - there's definitely time to start another package. I don't even need to publish it on MELPA, since installation from git sources hasn't been an issue since Quelpa appeared (like 10 years ago).

Users who don't go at least that far will be constantly shooting themselves in the foot and spending much more time with minor, novice level bugs that are completely obvious.

Debugging use-package forms is very easy if you know about macro expansion.

[–] invsblduck@alien.top 1 points 1 year ago

It's pretty tiny compared to a lot of languages

Correction: It's actually rather sprawling and one of the least "compact" languages. [1] Doesn't mean we shouldn't read and write it, though.

[1] See section 2, "Compactness and Orthogonality", in Chapter 4 of The Art of Unix Programming, by Eric Raymond (2003).

[–] chris_thoughtcatch@alien.top 1 points 1 year ago

"i'm not a programmer by any means" what do you use Emacs for? (sincere question, I know non-programers use Emacs)

[–] noooit@alien.top 1 points 1 year ago

Actually learning elips itself is the reward.

[–] SlowValue@alien.top 1 points 1 year ago

Let me cite RMS to answer that:

The editor itself was written entirely in Lisp. Multics Emacs proved to be a great success—programming new editing commands was so convenient that even the secretaries in his office started learning how to use it. They used a manual someone had written which showed how to extend Emacs, but didn't say it was a programming. So the secretaries, who believed they couldn't do programming, weren't scared off. They read the manual, discovered they could do useful things and they learned to program.

source: https://www.gnu.org/gnu/rms-lisp.html

Programming in elisp is fun, too. Since it's (typical for Lisp!) interactive programming features.

[–] sg2002@alien.top 1 points 1 year ago

Learning Elisp is definitely worth it. If you learn it, you'd be able to immediately improve your workflow in minor ways, the moment you spot any things that can be improved.

In terms of mastery - Lisp is a very easy language to learn, it's just that it's a bit alien to the current C-imperative crowds, so takes maybe 1 month until you'll be able to read it comfortably.

Learning resources are pretty great. Just go through the "An Introduction to Programming in Emacs Lisp". The fact that you're not a professional programmer is even better here, because those get too bored with it quickly. After that you can just read Elisp Reference on the need to know basis. Of course I also highly recommend you learn info too, because there's a reason why us, Emacs people, love doing everything through Emacs. Anyway, a good goal for Elisp knowledge is being able to program in it comfortably without ever needing to google anything, just relying on the Elisp Reference alone.

P.S. Don't listen to all the people(mostly from other Lisp communities) who say that Elisp is clunky and sucks. The fact stands that the Elisp community has produced Emacs and what did all those superior Lisps produce?

You can get a lot done with very basic knowledge. Much of the packages offer example configuration, and as emacs-lisp is self-documenting (through docstrings), being able to read and write basic hooks, functions and setting variables is enough for most configuration.

I personally think after that the challenge becomes emacs, not lisp. For example understanding startup, MIME-types, faces and window/frame rules is a lot to learn - and those are independent of the language

[–] arensb@alien.top 1 points 1 year ago

Learning a new programming language is like learning a new spoken language: not only does it give you additional skills, but it gives you perspective on your “native” language. The usual way of doing things in C++ is not the best way to do things in Python or Lisp, and vice versa.

One cool feature of Lisp is that the code is the parse tree.

[–] janoc@alien.top 1 points 1 year ago (1 children)

in other words, how rewarding it would be

I wonder how do you expect anyone to sensibly answer that?

Any feeling of reward (or lack of it) is a completely subjective thing - that's like a woman trying to explain to a man how pregnancy or nursing a baby feels or a man to a woman an erection. I.e. good luck with it.

You need to try it yourself and see for yourself whether or not the journey will be rewarding for you or not. Why are you afraid to try? It is not like it costs you anything (beyond time).

not mentioning that elisp is pretty old so the learning resources might not be as much as other more popular programming languages

Did you try to actually look? There are plenty of resources on ELisp and even Youtube videos. While it is not a general purpose language (as Common Lisp or something like Clojure or Racket would be) and it is quite old, indeed (as is Emacs), there is plenty of very good documentation available. I would dare to say even more and better than for some of much more recent and popular languages out there.

like what is the level of mastery do i need to achieve to start implementing custom elisp in my configs to enhance my emacs experience?

Very minimal. Moreover, Lisp is a very minimal language that has almost no syntax that you need to learn compared to something like Javascript, Python or C++.

and how exactly can i improve my emacs experience if i learned elisp?

If you are 100% happy with how your Doom Emacs works, then you don't need to bother with learning it. However, if you ever wanted to customize Emacs in any way, then you can't do it without being at least somewhat proficient with ELisp.

And if you don't want to customize Emacs at all - why are you using it in the first place? There are editors with much better out-of-the-box experience than this old dinosaur. The whole point of using Emacs is that you can completely customize it to your needs - something most other editor can't reach.

[–] ClerkOfCopmanhurst@alien.top 1 points 1 year ago

that's like a man trying to explain to a woman how an erection feels, I.e. good luck with it

That's easy. She just gotta hold her hand out.

[–] mitch_feaster@alien.top 1 points 1 year ago

I think it's enjoyable, especially if it's your first functional programming language. Go through the built in elisp tutorial (somewhere under ctl-h i, I think) and see if you're enjoying it. If you enjoy it keep going, if not, find something else to do with your time.

[–] erez@alien.top 1 points 1 year ago

I'll start from the last question, to me, if you don't use elisp, don't use emacs. To me this is why I still use it, because there is a lisp machine running under it and everything can be manipulated and configured with elisp. Otherwise there are probably better editors these days. You can obviously use it without elisp, if there's a library or mode that you love and (thanks to the power of elisp) have not found elsewhere, but even that is limited, since you need elisp to configure and manipulate it to fit your use-case the best. And to be honest, copy-pasting stuff without understanding will take you so far and you won't know why things don't work when they do, like with every programming language.

But is lisp worth learning? A definitive yes. As you found out, it's a different animal. Not just the syntax, but the way everything works. It requires you to think differently. I often say that learning new languages mean "how does if/else work, how does for/while works" basically figure out how do all the regular tools for logic and flow control look like in that language and your mostly set, only lisp does not have those "regular tools for logic and flow control". And on top of that, it's based on a wholly different paradigm than what the other languages are based on. It's a hefty task to climb and you must climb it if you want to get to the stuff that is important, like writing stuff that you can run and get results from, and that's before we get to the real insane stuff, the true homoiconicity (here's another word for you) of lisp, the idea that code is data is code, which is truly rare in computing (despite what some fans of other languages will tell you, there are only 2-3 actual homoiconic programming languages and lisp is the most commonly used of them all) and is very hard to wrap your head around.

So is it worth it? yes, for two reasons. Learning languages that use different paradigms always improves your abilities since you now have more ways of thinking about stuff. Learning Erlang made me a better Javascript programmer just because Erlang has a different way of thinking about everything that C languages take for granted.

Second, learning lisp in particular will improve you as a programmer. I don't know why exactly (Not a CS theoretician), but I believe it has to do with the way computers actually "think". Lisp, as its many detractors will say, is written in a way that is closely connected with the way a computer runs a program, after it's been disassembled away all the niceties of syntax and suchlike, but before its been interpreted down to assembly. It's the closest you get to programming in AST trees (another word for you) without actually doing that (and without going insane). Once you climb that mountain you will, guaranteed, be a better programmer, just because you will have better understanding of how is your code being run (guarantee not guaranteed).

[–] arthurno1@alien.top 1 points 1 year ago

How rewarding learning Elisp can be?

How rewarding learning anything is?

how exactly can i improve my emacs experience if i learned elisp?

You can program Emacs to do stuff you want it to do, the way you want it to do. It is like asking how can I improve my computer usage if I learn a programming language.

[–] a-concerned-mother@alien.top 1 points 1 year ago

I can personally say yes ... yes it is everything you learn has a use case and can be applied everywhere in emacs and in other languages

[–] nv-elisp@alien.top 1 points 1 year ago (1 children)

so my question is, Is it worth it?

It's worth more than a bunch of other people's opinions.

[–] emacs-ModTeam@alien.top 1 points 1 year ago

This has been removed, as it is not very civil; please attack ideas, not people.