reddit / emacs
I came to the conclusion that I wont learn Elisp...unless...
[deleted] · 2022-04-24 13:38
I think that if I can use Elisp outside of emacs for like... scripting or automation, it would be worth it. Because I do not have the capacity to learn elisp just so I can hack emacs (as much as I would love too... :\[ )
I often use NodeJS to write scripts for my business. If I can replace that with elisp that would be cool.
What else can I do with elisp besides hacking emacs?
(I am aware that elisp = emacs lisp. The answer might be in the name? lol)
AxiomShell · 2022-04-24 13:54
A couple of options:
- Use Eshell for shell scripting + Elisp
- Emacs batch scripts
- Hack on [Rune](https://github.com/CeleritasCelery/rune)
peklaiho · 2022-04-24 14:01
Yes, you can use Emacs to run shell scripts written in Emacs Lisp. For example:
```
$ cat test.el
(print (+ 1 2 3))
$ emacs --script test.el
6
```
jsled · 2022-04-24 14:03
Nothing practical, no, really, it's true.
But learning /any/ lisp will /fundamentally/ and positively impact your knowledge of building software, across the board.
Lisp has this unique property of being sufficiently similar to existing languages to be tractable, while being sufficiently different to be interesting.
I would not evaluate the benefit in learning it based strictly on the utility of being able to apply it directly.
akirakom · 2022-04-24 14:07
> What else can I do with elisp besides hacking emacs?
Elisp can be used to manipulate text, which can be considered an alternative to sed/awk/etc., from inside Emacs. I think you don't have to study elisp to do that. You only have to learn some functions and control macros (e.g. cl, dash, etc.). It's convenient, but it is totally fine to use other options.
lebensterben · 2022-04-24 14:09
You posted a question about whether it's possible to learn Emacs without Elispa about 20 hours ago.
The you made this post.
20 hour is enough to learn Elisp then Python from scratch. Why wasting time asking instead of learning?
jacmoe · 2022-04-24 14:17
Why is that important to you?
​
Emacs Lisp is a Lisp. So, if you want to learn a Lisp, learn Emacs Lisp.
​
You can probably not use it outside of Emacs - and who really ventures outside of Emacs? - but you can use your knowledge of Lisp to become a better programmer in other languages. It's a mindset thing.
​
Perhaps learning it will inspire you to pick up a more fully featured Lisp? Maybe a Scheme like Racket or Guile, or a fully fledged Lisp like Common Lisp?
​
However, sometimes you can learn something for the sake of learning something new. It's not like your brain has a finite capacity for learning.
[deleted] · 2022-04-24 14:45
​
How would you evaluate it - out of curiosity?
[deleted] · 2022-04-24 14:46
Posting a question about making a decision, isn't the same as deciding.
Deciding isnt the same as executing.
Thanks for your input.
[deleted] · 2022-04-24 14:49
>but you can use your knowledge of Lisp to become a better programmer in other languages. It's a mindset thing.
Interesting.
>However, sometimes you can learn something for the sake of learning something new. It's not like your brain has a finite capacity for learning.
Agreed. I am already invested in JS/Node. I think, ultimately, less is more.
[deleted] · 2022-04-24 14:49
interesting... very cool.
djrdjrdjrdjrdjr · 2022-04-24 14:54
Web assembly uses s-expressions. Lisp is everywhere!
jack-of-some · 2022-04-24 15:01
There's a fundamental flaw in your question: the notion that for elisp to be useful outside the purview of emacs, it must run outside emacs.
I would argue that instead the purview of emacs needs to expand.
Let me explain.
I work for a company that makes robots for monitoring retail store inventory. We have hundreds of robots globally and each of them have unique internal names as well as associated store names. Pulling up the correct name for either quickly can be quite the hassle, especially when you're trying to follow customer support requests or bug reports.
Enter emacs. I wrote a function for grabbing this data from our web api, caching it locally for N hours, and throwing it into fuzzy searchable buffer. Then I wrote functions on top of it for either navigating to the correct webpage for the store/robot or to copy the store name into my clipboard. Given that my emacs is one shortcut away, this ends up being extremely convenient.
Similarly my bookmark manager is now emacs, the fuzzy search makes it incredibly convenient.
Finally there's the whole thing where you're trying to make a decision about if this would be worth your time. Considering the fact that I've spent maybe 6 hours max learning elisp which was enough to put together an emacs config from scratch and write a whole lot of my own functions, I think that yes, it would be very worth your time.
[deleted] · 2022-04-24 15:07
I very much appreciate your thoughts here. You have raised some great points.
Firstly, what you built to grab the data via an API and stack functions ontop, you could have built that with other languages too right?
Second, what is the benefit of this: "my bookmark manager is now emacs" - do you mean a bookmark manager in chrome/browser?
​
>There's a fundamental flaw in your question: the notion that for elisp to be useful outside the purview of emacs, it must run outside emacs.
fantastic point. Agreed. Defo a flaw.
ftrx · 2022-04-24 15:08
I use it for my small scale automation, like org-mode clickable elisp: link to run a notmuch query to see certain mails out of my org-mode note, to add a heading with a certain template on click, to run org-ql queries on my notes etc.
Long story short: Emacs is a classic system where anything is integrated in the system because that's the best way to build an operating system, a unique application that different cohort of people can develop in different access levels depending on their skill and will for their own good. That just to been able to programmatically filter personal information without being a developer, download a gazillion of ultrabytes crapplication-framework, craft a few thousand SLoC RAD-style crap no one will ever read but many will have to de-rat, build a package etc just to run a simple bit of code, to been able to solve an ode inside a mail if I need it and I have a CAS installed without reasons to copypaste stuff around as the sole IPC between the MUA and the CAS that from my point of view are just interfaces to the very same system...
That's is: you should not and have not much reason to use elisp "outside" Emacs, but you have many reasons to "live in Emacs" even if you do not own a LispM...
jack-of-some · 2022-04-24 15:10
Sure, I could have used bash and piped the result into fzf and then into chrome. I could have written it in python. It's doable in any other language. But the integration it has now with emacs is very very tight. It's just a lot more comfy than running a shell script.
And yes, I mean I no longer use chrome's bookmark manager. All my bookmarks are in emacs. The benefit is speed/convenience since I can summon emacs with a simple shortcut and automatically get a fuzzy searchable way to navigate to a bookmark.
[deleted] · 2022-04-24 15:14
>All my bookmarks are in emacs
mind blown here.
I am starting to see why people say "emacs is not a text editor".
jsled · 2022-04-24 15:15
As suggested: based on how much it improves your ability to understand the true, underlying concepts of programming, rather than how much you're able to directly apply it to "scripting or automation".
By point of reference, for a long time at Berkeley and MIT (and [a number of other schools](https://mitpress.mit.edu/sites/default/files/sicp/adopt-list.html)), the introduction to programing course was not C or C++ or Java but instead Scheme, via [_Structure and Interpretation of Computer Programs_](https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs) … even then it was not the most "practical" language in terms of task or commercial utility, but it is a /useful/ language for understanding how computation /works/, and how (programming) language /works/.
[deleted] · 2022-04-24 15:16
>That's is: you should not and have not much reason to use elisp "outside" Emacs, but you have many reasons to "live in Emacs" even if you do not own a LispM...
Brilliant point here. This and jack of some points clarified the scope of emacs for me.
thank u
jacmoe · 2022-04-24 15:42
Then it might interest you that Javascript has more in common with Scheme/Lisp than it has with C. In fact, it was inspired by Lisp.
Which means that, if you learn some Lisp, you will become a better Javascript developer.
Andy has made a series about Scheme. He's a Javascript developer. So I figure you'd appreciate that:
[https://www.youtube.com/playlist?list=PLgyU3jNA6VjRMB-LXXR9ZWcU3-GCzJPm0](https://www.youtube.com/playlist?list=PLgyU3jNA6VjRMB-LXXR9ZWcU3-GCzJPm0)
He's using an older version of Racket, by the way. Check it out :)
Speaking of Less is More, you'd be hard pressed to find a more minimal language than Scheme/Elisp.
comproprasad · 2022-04-24 16:20
Recently Emacs master got some addition to improve exactly this thing along with simpler shebang support.
[deleted] · 2022-04-24 16:33
Bro, you have helped a lot with this. You are a true gentleman.
Thank you.
xenodium · 2022-04-24 17:19
\+1 to u/jack-of-some.
We can apply it in endless contexts... We can bend Emacs to do all sorts of things for us. u/Vince_landern, here are a couple of examples of mine:
* [https://xenodium.com/emacs-fuzzy-search-apples-online-docs](https://xenodium.com/emacs-fuzzy-search-apples-online-docs)
* [https://xenodium.com/emacs-clone-git-repo-from-clipboard](https://xenodium.com/emacs-clone-git-repo-from-clipboard)
duckbill_principate · 2022-04-24 18:10
Only answer here that is actually useful and not lecturing OP on their life choices.
ftrx · 2022-04-24 18:38
Your welcome :-)
essentially if you thin in history and overall design terms: classic systems was "an operating system, a sole, vast and easy to mold application" while unix state "that's too expensive, we can made a less demanding system language (C) and a simple but effective glue language able to combine many small programs that act like your functions but demand far less hw horsepower (the shell/shell scripting)". That motto succeed for a little while BUT after that they admit GUIs are needed (older systems are almost all GUIs ones, Xerox series a substantial modern desktop with a tiling WM, mouse etc just for instance, IBM have made it's first touch screen with a pen and a sensible touch-UI in the late '60s, NLS have had the first screen-sharing with contemporary video call, the so called Mother of All the Demos in the 1968 etc), so some start to craft X-alike solution, one of the first was document based, the PostScript-powered NeWS but again judged to expensive in resource terms X see the light quickly, unfortunately loosing Unix command-as-functions composability with simple IPCs: Unix GUIs have no IPCs behind cut/copy/paste, so most modern GUIs while original more complex etc GUIs are text-centered easy to mold and even much more "graphical" than modern Emacs.
Modern Emacs is just a living vestige who lack too many things from past glories/implemented dreams and vision but at least have many others. That's is it's power. A small example: https://youtu.be/B6jfrrwR10k that's just a simple automation much more automated and expandable than shell ones. Personally I wrap much via Emacs because my Elisp knowledge is not that good while I was born in unix so shell is still my most known tool, things like download some podcasts, who happen to be video but I rip them to just audio, nothing more than `yt-dlp` a script to proper rename files and ffmpeg to rip. But wrapped in Emacs is part of an org-mode note, org-roam accessed/managed, where I also takes note about something I here in those podcasts etc, so it's very well integrated in a very natural and easy manner, a thing that can be done only partially in the shell and only with much more code in modern WebUI/GUIs. In the set of org-mode, org-roam managed notes I keep almost all my files (org-attach) so I can access almost anything with search&narrow instead of manually traversing a tree and those files can be accessed directly but are also countered by plain text infos around so in a note I can link the mail of an invoice, the pdf invoice, extra info, the bank transaction (hledger/ledger-mode with org-babel) etc seeing anything glued together. With org-ql I can (not very quick, but easy enough with a bit of practice) query my notes to construct live view of something like I do want to know all insurances I have active, how much I pay for my house or car out of many different notes etc.
takeonrules · 2022-04-24 18:42
For the OP, I had a similar sentiment for my first year of Emacs. I configured Emacs packages in that first year. But wrote scripts in bash or Ruby.
But, I started really paying attention to routine tasks. One of them is writing a pull request (PR) that uses a template. I wrote an Emacs function to tidy up that PR template.
And I wrote an Emacs function to help me write the handful of week-end reports that I need to write.
Or to create a Transient style dashboard of menu options that link me to resources or perform common tasks for my job or my hobbies. My dashboard helps me jump to my pull requests, create a branch based on an issue, and whatever else I want "near" my text editing experience.
The key takeaway with Emacs is:
> Pay attention to the things you do with files and text. With Emacs you can write functions that preserve your working context but help you get things done.
There's so many more things that open up when I look at Emacs as a file/buffer oriented workflow automation/scripting toolkit.
[deleted] · 2022-04-24 19:28
>Or to create a Transient style dashboard of menu options that link me to resources
I would love to see a screenshot of this...?
>There's so many more things that open up when I look at Emacs as a file/buffer oriented workflow automation/scripting toolkit.
I came into emacs expecting a "vim alternative", instead, I found something I can easily become obsessed with.
What is interesting is, i originally picked up NodeJS for scripting CLI automation tools. Maybe I can play around with emacs and test some stuff out.
Having said that, its literally day 2 in emacs for me. Kinda overwhelmed right now haha.
[deleted] · 2022-04-24 20:05
[deleted]
machineperson · 2022-04-24 20:06
Don't learn elisp, learn LISP then you won't need to learn elisp and you will be able to use your knowledge outside emacs land.
tjgrinn · 2022-04-24 20:12
And here's a shebang that does the same thing
$ cat test
#!/usr/bin/env -S emacs -Q --script
;; -*- mode: emacs-lisp; -*-
(print (+ 1 2 3))
$ chmod +x test
$ ./test
6
DWHoman · 2022-04-24 20:51
Just as a practical note, Emacs scripts are certainly good for dealing with random file encodings. Tools like Sed and Awk and most other languages, including Node, don't try to determine whether a file is in UTF-8, ISO 8859-1, etc. and it has support for pretty much any file encoding, which Node doesn't, but there is a Node Iconv package. Emacs also has built-in XML parsing (minus namespaces), which Node doesn't.
AuroraDraco · 2022-04-24 21:24
There are A LOT of things you can automate with elisp. I have written a package to automate significantly large parts of my studying for example and besides that have written probably thousands of lines of elisp to automate so many parts of my daily life.
No, there is nothing it can do outside of emacs. But you can't say you can't use it to script/automate parts of your daily life because of that, as emacs is almost a fully fledged OS, there's a lot it can do. If you use emacs as a text editor, elisp's use is probably limited. If you do almost everything in emacs, elisp is the most powerful and enabling language you could learn.
Furthermore, after learning elisp, it's not so hard to learn Common Lisp as well (I am currently in this process) which is a general purpose language for a lot of things.
takeonrules · 2022-04-25 00:39
I failed to figure out how to upload an image on Reddit.
At the bottom of the page: https://github.com/jeremyf/dotemacs/blob/main/emacs.d/configuration.org
sshaw_ · 2022-04-25 03:15
You can hack Emacs while learning (common) Lisp!
sshaw_ · 2022-04-25 03:16
As a long-time elisp writer I gotta say: um no!
uardum · 2022-04-25 04:15
While Elisp *can* be used for system automation (with the benefit that you can then invoke this automation directly from Emacs), the programming interfaces for certain things are extremely awkward. For example, if you need to do anything with a file, that'll involve opening a buffer, and if you need a network connection, that'll involve opening something called a "process", which is the same object you use to work with subprocesses.
In all these years, nobody has come up with libraries to make these things as simple as they would be if you were using a modern implementation of Common Lisp instead of Emacs Lisp. Or if anyone has, their work was rejected by the community.
[deleted] · 2022-04-25 05:11
If I understand you correctly, you are saying common lisp can be used to hack emacs, as well as elisp?
[deleted] · 2022-04-25 05:12
This is an interesting point. I do not want to start a war (lol) but in the vim community the sentiment is that the emacs community reject a lot of change/improvements.
Why is that?
okflo · 2022-04-25 09:19
There is also [elnode](https://www.emacswiki.org/emacs/Elnode) as a replacement for node.js :)
[deleted] · 2022-04-25 11:47
haha... exactly!
[deleted] · 2022-04-25 11:48
um no to what... specifically?
[deleted] · 2022-04-25 11:50
a very useful insight here. Thank you. You are a true gentleman.
matusaleeem · 2022-04-25 12:26
1 - You won't find usage of ELISP outside Emacs. I'm sorry
2 - Learning Elisp makes you better at lisp in general (maybe Clojure demands more effort when you already know Elisp, because it is the black sheep of Lisp dialects)
3 - You can use Emacs itself as an "framework" for writing custom applications. Org mode, for instance, is a complete application on its own
4 - At least is way more useful and nice to use than Vim extension language
5 - Elisp IS Emacs, I mean, Emacs itself is written in Elisp with a tiny C core. The language was designed to make Emacs customizable in literally every way possible. Since it's purpose in the world is so tied to Emacs, it's the complete opposite of a general purpose language. It's turing complete though, with batteries included, it's a proper language, but its purpose is to give life to Emacs itself.
matusaleeem · 2022-04-25 12:29
Please elaborate more:
Have you tried to use Elisp as general purpose programming language?
What are the drawbacks?
DeerRepresentative91 · 2022-04-25 13:05
What about learning *a* lisp, but not Elisp? Racket is great for scripting. Learn that, and while elisp is a little different, you'll get used to working with sexp.
https://racket-lang.org/
Be warned, once you go functional, it's hard to get back to Node. These days I mostly work on Elixir, I have grown more and more displeased with classic imperative languages.
[deleted] · 2022-04-25 13:38
[deleted]
[deleted] · 2022-04-25 13:39
>https://youtu.be/B6jfrrwR10k
This video is amazing.
I think out of everything I have learned from reddit emacs, this has given me the introduction I needed to understand what is possible.
I really couldn't see it until now.
Nice one. You are a true gentleman.
[deleted] · 2022-04-25 13:40
Funny you say that. I am in the process of learning functional programming for JS. I understand it wasnt designed that way but it seems there is quite a lot of people who are making it work.
DeerRepresentative91 · 2022-04-25 14:01
Yeah, there are some decent functional libraries on JS. Lodash is one I used to use at work.
sshaw_ · 2022-04-25 16:55
Generally, applying the Emacs IO paradigm to non-Emacs concepts does not provide for straightforward, maintainable scripts.
sshaw_ · 2022-04-25 16:59
Aside from the syntax there are overlapping function calls and concepts. See [cl-lib](https://elpa.gnu.org/packages/cl-lib.html). There are differences as well but if you know is Elisp then you can definitely apply that to Common Lisp. Other Lisp variants too but there is less overlap.
sshaw_ · 2022-04-25 17:07
https://www.reddit.com/r/emacs/comments/uauyy8/comment/i65gnkh/?utm_source=reddit&utm_medium=web2x&context=3
sshaw_ · 2022-04-25 22:29
Emacs has everything!
timmymayes · 2022-04-25 23:03
It's a lifestyle.
timmymayes · 2022-04-25 23:07
These are both great! I'll be saving and scouring your blog. (i'm a new emacs user)
Oerm · 2022-04-26 05:00
~~It looks as if you have “answered” a question to elaborate on your first comment by linking back to the initial comment. To me, this reads a little like “Duh, can’t you read?” which was certainly not your intention, right?~~
EDIT: Please ignore this, I just don’t know how to Reddit.
sshaw_ · 2022-04-26 13:38
Wut‽ Did you follow the link? It says:
> Generally, applying the Emacs IO paradigm to non-Emacs concepts does not provide for straightforward, maintainable scripts.
This is a drawback (one of several, I suppose) to using Elisp as a general purpose programming language.
Oerm · 2022-04-26 13:50
My bad, my Reddit app has played tricks on me. For some reason, clicking the link redirected me to your initial comment. Hence my confusion.
(╯°□°)╯︵ ┻━┻
My apologies, I think your point is a very good one and I shall hang my head in shame.
sshaw_ · 2022-04-26 16:01
haha, it's okay dude!
🤗
ftrx · 2022-04-26 19:58
Not at all :-)
Consider that the first time I encounter Emacs, with already a certain experience in unix (years) I say "what?! It's a slow crappy GUI tool!" and back to Vim. I try it again only when I see it in action. And that completely change my mind in a very short period of time.
Probably the main issue is that we know a certain set of programs and we expect to find similar ones, since Emacs is "alien" respect to modern concepts/paradigms we do not really understand it's effectiveness until we see it in action and being able to replicate.
Even now, when I casually do a small presentation, not about Emacs but in Emacs (EXWM, org-mode for slides) I feel the WOW effect it generate and the difficult of even skilled colleagues non-emacser to grasp what happen on my screen. Some thing that are rigid barriers in modern systems in Emacs are blurred, like switching from an org-mode note to an email without really change environment, run some code in various languages out of the same org-table as input data, then plot results in the same buffer, click links to change the UI (a simple `elisp:(sexp)`) etc. Feeling the power and not being confused it's not that easy.
[deleted] · 2022-04-27 15:13
do you have any more videos you can share that show the emacs powers?
ftrx · 2022-04-27 16:24
This https://youtu.be/5ViUBaarsbw a bit extreme IMO, I do not feel the comfort of such usage but I also hate PM stuff and that might be part of the judgment.
Beside mere showcases I suggest skim through Mike Zamansky video series: https://cestlaz.github.io/stories/emacs/ for instance pick the simple dired-narrow (built-in, just hit-a-key and type something, only matching files will be shown in dired) or the one about wgrep where you (rip)grep across a set of files, in the result buffer you change to wgrep mode (writable-grep) and edit matches in the buffer committing changes in all files. Another good source are the numerous Stavrou Protesilaos videos https://www.youtube.com/playlist?list=PL8Bwba5vnQK14z96Gil86pLMDO2GnOhQ6 or David Wilson (System Crafter) https://www.youtube.com/c/SystemCrafters/playlists others much depend on your desire, a webdev showcase might be meaningless if you do not do anything like that...