Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
Don't get me wrong, I'm not planning on creating an Emacs killer, nor suggest anyone do that. But, hypothetically, what are some fundamental pitfalls of this foundational application?
339 comments
[ 4.1 ms ] story [ 256 ms ] threadMost developers do not like writing Lisp. That's just a fact, slamming the downvote button won't change it. I am not among those developers, I like writing Lisp, but most, flatly put, do not.
So by choosing Scheme you are competing with a remarkable number of little-used editors which can be extended in Scheme or Common Lisp, as well as Emacs, far and away the top dog in the extensible-in-Lisp-editor niche. Neovim has achieved the best of both worlds, because it can be extended in a rather nice Lisp, and also in Lua, which, while some find the quirks of the language annoying, is at least Algolic in structure, matching the mode of thinking and writing used by the vast majority of devs.
No it has not. Fennel doesn't have the same level of integration into Neovim, like Elisp has in Emacs. Emacs is essentially a Lisp interpreter with a text editor built on top of it. This tight coupling allows Elisp to interact with and modify every aspect of Emacs, providing a level of customization and extensibility that is difficult to replicate with external languages.
While Neovim's approach with Lua and Fennel is commendable, it is unlikely that these languages will achieve the same level of seamless integration as Elisp within Emacs.
- Design a more modular architecture to make it easier to extend and maintain different components.
- Design a more robust plugin system for development and distribution of extensions.
- Implement better sandboxing and security measures for extensions.
- Better APIs for extension developers.
- better multi-threading support baked into the editor.
Interesting, why not a scheme? Is it because the popularity in the industry? I don't know much about Emacs or lisps and looking to understand better
https://github.com/yfuna/paip-el
[0] : https://github.com/lem-project/lem
Why, pray tell, should this be of any concern at all? Sandboxing is used when the host is concerned about running programs that he doesn't trust. There is no reason that an Emacs package would require security measures around it, unless it were knowingly potentially malware. The only reality in which I could see this is if people were using proprietary Emacs extensions, in which case I would entirely understand it, because then people would be willingly running malware inside their editor. Perhaps this the stance VS Code users like to take towards extensions?
I don't really see how the XZ backdoor is relevant to this conversation, since these types of exploits are the fear of server operators, and generally not people who run user programs like Emacs on their desktop. A rogue Elisp function could delete all of the files in your home directory if it wanted to, but people don't really complain about that because being able to delete files is a desirable function.
If you ask me, Emacs is a program where user freedom is and should be the ultimate goal. Adding security features that the user has to jump around 'for his own good' and only really serve as idiot nets are dubiously effective and only hinder this freedom. If someone wants to install a package from a source other than the official archives, then the trust is placed in him to actually look at the source code he's received. Even if you install an official package you should still look at the code, as it's quite useful to know what's going on inside it when you want to configure it or add functionality. The vast majority of packages I use are a single file and tend to not take up more than a few screens, so they are easily understandable.
Trust? Trusting criminals doesn't stop them from committing crime.
You may trust your emacs color theme author. Pretty colors from an innocent artist. You run the theme code without any sandboxing. Everything is going well. Then the author adds a keyloger, project code scrapper, and phone-home feature in his theme.
You update all your emacs packages automatically without any code review. Then you start getting emails from your companies security team asking why you uploaded sensitive projects to a 3rd party.
Wouldn't it make more sense to restirct color themes to color and font related tasks? Why should a color theme be allowed to scrape sensitive code from your disk and upload it to a 3rd party without your consent?
> You update all your emacs packages automatically without any code review. Then you start getting emails from your companies security team asking why you uploaded sensitive projects to a 3rd party.
If you do not trust the author or maintainers of a random program and refuse to review any code updates before installing it, then you are a moron.
I think if there is a concern that people would upload malicious packages, then there would be a level of trust put into the repositories that accept and offer them to review submissions before accepting them. This is still imperfect, but it shifts some responsibility off of you.
> Wouldn't it make more sense to restirct color themes to color and font related tasks? Why should a color theme be allowed to scrape sensitive code from your disk and upload it to a 3rd party without your consent?
Why SHOULDN'T a color theme be allowed to scrape code from your disk? Maybe the color theme is sophisticated enough to want to do that, or talk to some network. Something like a seasonal color theme that responds to the local weather might have a lot of hack value; and that is precisely the point you are missing. Emacs is not about restricting what you can and can't do, because the designers of Emacs understand that restricting what the user is allowed to do ultimately hinders freedom and creativity. It is one of the very few platforms left that's still like that, and I believe it should stay that way. If people want to use an editor that's very safe and tells them what to do rather than vice versa, then they should probably consider VS Code, or something like it which DOES upload your data to a third party without your consent, because it is smarter and knows better than you what you should be doing with your computer.
Trust provides no protection.
> refuse to review any code updates before installing it, then you are a moron.
I personally do review every line of Emacs code I run. But I'd wager only a small handful of Emacs users do that.
> Why SHOULDN'T a color theme be allowed to scrape code from your disk?
Security.
> precisely the point you are missing.
Not missing it. nabla9's suggested security measures for extensions. You then asked why security is a concern. You seemed to imply there wasn't any reason for limiting extensions if you trust the author. That's simply not true, as you can easily be sabotaged by the most trusted color theme author.
That may be implied but the precedent is not important. The bigger consequent point I am trying to make is that there is no good reason for limiting extensions at all, and my reasoning for that will follow.
> you can easily be sabotaged by the most trusted color theme author.
Okay. Let's say that we solved the hypothetical issue of colour theme authors sabotaging their themes by requiring color themes to use a format that can't evaluate arbitrary code, only dictate UI options.
Now what about all of the other packages that aren't color themes, that do more useful things and require greater breadth of functionality? I am not trying to separate things into functional and non-functional, as it is futile to do so--there are an infinite number of separations between the degrees of utility packages have, and once you have "solved" the issue of their insecurity by restricting one class of them, there are always more. And every time you do this you only degrade the freedom and extensibility of the entire system; you do not gain anything by it, you only lose.
This phenomena can be explained because it's really an application of Gödel's Incompleteness Theorem. For any program running on any computer, it will always be possible to induce conditions that the program was never designed to handle. Thus it is my belief that the entire field of computer security is really a joke, and anyone who sacrifices freedom for safety ultimately ends up with neither.
In practical terms a bit of security is useful, however Emacs is not the kind of program that benefits from it. It is not useful to waste time reasoning about which methods of security should be applied to a text editor. If you were using Emacs to run an air traffic control system then this type of thinking might make sense, but not as a reasonable or common case.
Get rid of any keybinding or UI convention that is there because that is the way they did it the AI Lab in 1967. Make the UI as familiar to the average computer user as possible (but keep the general design of a large rectangle of text) by using mainstream conventions (which come mainly from the Mac and Windows) for how to respond to this or that keypress or to clicking or dragging with this or that mouse button.
Inside Emacs is a cross-platform toolkit (where the platforms are MacOS, other Unix derivatives, Windows and the terminal) I would split Emacs into 2 projects: a toolkit and an app that uses the toolkit. That way, if someone wants to create an "standalone" org-mode app, Magit app or Gemini browser designed to appeal to people who do not want to spend any time learning to use Emacs the app or "Emacs the generalized interface to information", they have a straightforward way to do so. (These "standalone" apps that are as easy to learn as any other GUI app will I hope help popularize the Emacs ecosystem.)
One thing I definitely would not change is I would not make Emacs dependent on or closely integrated with a browser engine.
Do you have an example of this? I can't tell any difference for the fonts that I use (with emacs-pgtk). I believe Emacs uses Harfbuzz (same as Chrom{e|ium}).
I did setup Obsidian for a friend to write in Urdu, and that worked almost perfectly modulo some minor stuff.
Does your Emacs usually use a proportional-pitch typeface? If so and you're on Linux, I'll install the font you are using.
I've tried using proportional typefaces in Emacs (on Mac), but there was something off, so I went back to monospaced. I could try again now that I have a Linux machine.
The text in my Emacs looks almost exactly like the text in my Gnome Terminal. (A slight difference in size is the only thing I notice. To be painfully precise, (window-system) evals to 'pgtk on my Emacs.)
The text in Gnome Terminal is not terrible, for sure, but text on the web is a nicer in my experience.
Emacs is perfectly capable of rendering other fonts, too, though.
It's not as good text on the web IMHO. Typography is very complicated, and I think the people who did the typographical details of Chrome and Firefox were very skilled, is my guess.
Tips for using a variable pitch font as the default:
0. Choose default fixed and variable pitch fonts with identical baseline-to-baseline heights for a given size; this makes everything described below work better (e.g., this is true for all fonts in the IBM Plex family across all platforms I regularly run GUI Emacs on [Linux, Mac, Windows]).
1. Define a fixed-pitch-mode by copy-pasting the built-in variable-pitch-mode and making the obvious changes (both are trivial applications of buffer-face-mode).
2. Add fixed-pitch-mode to hooks for modes that don't play nicely with variable-pitch fonts (calc, dired, hexl, magit, terminal and shell modes, etc.), or where you just prefer fixed-pitch modes (hint: define your fixed-pitch-mode in a package so you can use use-package's ":hook ((foo-mode bar-mode … baz-mode) . function)" syntax to manage this).
3. Some modes that pop up windows (frames in Emacs parlance) within editing buffers require extensions (e.g., company-posframe-mode for company-mode) to work properly in variable pitch buffers.
4. Last, but certainly not least: assign a convenient key binding to toggle fixed-pitch-mode. I can't emphasize this enough! In fact, I've found that variable pitch is fantastic for coding in most languages if and only if fixed pitch can be quickly toggled on and off with a keystroke, iff this setting is per file rather than global (and iff both fonts have identical line heights, but this is a feature of font families rather than editors).
For this reason alone, I'd argue that Emacs supports variable pitch fonts better than most text editors.
[1] https://en.m.wikipedia.org/wiki/Caps_Lock#Placement
There are other options as well, like remapping the Enter key to act as Ctrl when chorded or using sticky modifiers. I think using an ergonomic keyboard with two large Ctrl keys on both sides of the keyboard is probably the best solution. I've discussed some of these alternatives in more detail <https://susam.github.io/devil/#why>.
By the way, there are some vendors that still make Unix layout keyboards with the Ctrl key positioned where Caps Lock key usually is: <https://deskthority.net/wiki/Category:Keyboards_with_Unix_la...>.
It works really well, and makes emacs much more comfortable to type in.
Downside is this keeps me locked to X11 and fighting the occasional app that reads the key codes directly.
Tangentially, I really loathe how Wayland has no alternative to this. I'm expected to configure keyboard layouts in every DE or WM I use, which is a much worse UX.
[1]: https://vincent.bernat.ch/en/extending-xkb#attaching-symbols...
They also at some point joined the PC world in moving the nubs on their keyboard from "d" and "k", where you were more likely to notice if your fingers are not in their proper place on the home row. Now if your right hand is offset slightly to the right, you won't feel anything, which is less immediately noticeable than if the nub were under the wrong finger.
Caps lock was rightfully relegated to bottom left.
That's indeed true! But the premise of this question explores the scenario: What if we did rewrite Emacs from scratch?
Tongue-no-longer-in-cheek:
I reckon the C core of Emacs is some of the most battle-hardened code out there. Verification, a-la SEL4, is probably irrelevant but still nice. Guile is modern and performant but Elisp is still its own little joy. Literate programming is always nice until it gets in the way. Straight is good enough for me now. Macros are always cool and a leaderboard would be fun, but patch algebra is really nice, see jujutsu nowadays. And beard length is gendered and so only partially admissable. Infinity categories are way out there and always good for a reference.
you insensitive clod
https://www.gocomics.com/calvinandhobbes/1986/02/14
Since I agreed with all of these, I’ll add some more non-ironic, idealistic wishes:
Plugins must be written in sandboxed WebAssembly so you can know what a plugin is capable of without reading the source code. The runtime must be portable so it can run in wasm32-wasi.
for the non-tongue-in-cheek, also relevant: https://www.emacswiki.org/emacs/GuileEmacs#h5o-2
I'm looking at pijul..
https://pijul.org/
Though, not to put too fine a point on it, I know it was in jest, but the core implementation language is the least of my concerns. As long as it is extremely portable, compiles fast, and runs on virtually anything, then whatever the core is, doesn’t matter much to me.
Their version of Lisp is clearly not suited for any large-scale development. (This trickles down hard into user experience, i.e., lack of parallelism or multithreading.)
Is this so obvious as to go without examples? I'm no Emacs power user, nor even really an Emacs user, but it certainly conflicts with my understanding of core Emacs.
Ship is fine, but leaks as hell.
I sometimes think using lisp for a language is a little like trying to implement comments within json data.
Emacs just cannot be Emacs without Lisp. Emacs is a Lisp machine; it is tightly integrated with Lisp and needs Lisp to operate. Lisp is at its core principal model.
There are a number of different types of applications that are significantly more difficult to achieve with a non-homoiconic language; check out Hyperfiddle/Electric, there are some videos with demos. Why do you think there were so many attempts to re-create something like Org-mode, yet none of them were hugely successful?
For starters - the Lisp REPL has some significant differences; it just doesn't work the same way as a REPL in, e.g., Python. In Lisp, you can send any piece of code without any prelude or ceremony directly to the REPL. That REPL instance can even be on some remote computer, like a spacecraft millions of miles away (I'm not making up this shit, NASA did it at some point)
Anyway, Emacs is Emacs because of Lisp, not because someone on a whim decided to use Lisp instead of, I dunno, Pascal. Trying to build Emacs on top of some non-Lispy language is futile. It won't be Emacs. Sure, it might be to a certain degree even better, but it won't be even "like Emacs".
I don't like those languages, and I have just as much right to say that as the people who don't like Lisp.
- What? Okay, so fruits, berries?
- No, no, no fruits either.
- Hmm... what about croutons, nuts, maybe sunflower seeds?
- No, just use meat. I like meat. Just make it with a bunch of meat pieces, alright?
- Well, that is not a salad...
> Not using lisp
Don't you folks realize the imbecility of such statements? Emacs is a Lisp machine that allows writing and loading custom extensions based on Lisp! This level of extensibility and programmability is so deeply ingrained into Emacs, specifically because it revolves around Lisp. Emacs wouldn't be possible without Lisp.
UI: Electron, of course.
Json to represent the edit buffer in RAM. Each utf8 code point base64 encoded, in a json array, it itself, as a blob, base64 encoded. Now, before you complain that that is gonna blow up the data too much, don’t forget that 1. “Ram is cheap” and 2. “gzipped base64 is about the same size as binary”. So, of course, we’ll gzip the data in RAM.
Plugins should be JavaScript, as should be self-evident. And you’ll need a few installations of python (both 2 and 3) and node.js (each in its own docker container, obviously) to glue it all together and provide reproduceability.
With some care and work, it’ll run even on a modest machine taking up merely 60GB of disk, 32GB of RAM, a 4090ti GPU, and 8 CPU cores.
Every key press should be passed through an LLM, to add some intelligence to the editor. The user will, of course, supply a ChatGPT api key when they register for their mandatory myNewEmacs.ai account that they’ll need to subscribe to the editor for only the cost of a few lattes a month.
It is 2024, after all. One must use modern tools and technologies.
Personally I find following email conversations much harder than just a single conversation thread like in a GitHub issue, for example.
. o O ( hey, I get some of this, and I can just start tweaking it here... )
In Emacs, you can seamlessly integrate a function from a third-party package, say, a command that fetches a url, parses it, performs processing, and displays the results in a browser. Remarkably, you can modify it to send the results to an LLM or another function instead, without altering any other aspects. This level of granular control is complete bananas and only possible in Emacs. For VSCode, you'd likely need to create a new extension, while in Vim, you'd have to rewrite the entire function. Emacs, on the other hand, allows you to precisely specify and override only the desired part of the function. And once again, you don't even have to save a damn file to try it out.
So, yeah, I don't have to compare it with nothing. Nothing else comes even close.
I've made some Emacs extensions, the public ones of which are at: https://www.neilvandyke.org/emacs/
My point was that I see a lot of people now who aren't getting the advantage that I had, of seeing "here's some Emacs Lisp code that does X", right up in their face, from the start, and constantly.
So they have more friction, to even knowing what Emacs Lisp looks like, and knowing how close they are to extending Emacs themselves.
But agreed that Emacs is more user-extensible than all the other options presently out there, purely from how easy text-oriented extensions are.
That's how it sounds to me. Dismissing Lisp solely based on its syntax (that you're unfamiliar with), is equally irrational as rejecting projects that incorporate mathematical notation.
If I could have Emacs with Acme-style window management, that'd be perfect
see https://www.masteringemacs.org/article/demystifying-emacs-wi... for more information.
he goes by the moniker 'prot' and has tons of very very good emacs information (both on his website, and youtube). always worthwhile to check them out !
as someone would say, if you like that kind of thing, this the is kind of thing you will like :o)
Vim feels like working on a moodboard while Emacs is more a study desk.
https://youtu.be/1-UIzYPn38s - Emacs: control where buffers are displayed (the 'display-buffer-alist')
Overall, I'm personally happy with Emacs window management, it's highly customizable and extensible, it gives you powerful keyboard-centric control, it supports complex layouts, it is deeply integrated within Emacs' vast ecosystem. There are packages like ace-window, winum, winner-mode, golden-ratio, shackle, popwin, eyebrowse, perspective, window-purpose, etc. I don't know what you're complaining about, I guess because I have not seen something even better than that.
A few years ago I very much shortened my .emacs file using the Straight package manager and I have been happier.
I think of VSCode as “Emacs, but JavaScript instead of Elisp.” That’s one thing I would not choose, in spite of the good things VSCode brings to the table.
What I meant is that the runtime is arbitrarily extensible at runtime.
But I don't assume that people actually do what you describe.
I think this misconception comes from the fact that (1) people often compare emacs and vim, and (2) vim is usually used in the terminal. But emacs and vim are really categorically different things so I think the “emacs vs. vim” meme kinda doesn’t make sense.
Maybe it's just personal preference, since I think it's easier for me to think in python over lisp (which I've known for longer, but I still fumble through)
I do think python would make emacs more accessible to a wider audience.
It would not be Emacs anymore. Emacs is specifically tied to Lisp. Emacs is not a text editor that uses Lisp as the configuration language. Emacs is a Lisp machine that has a text editor built into it.
An "Emacs-like" editor built on Python might be interesting, but it wouldn't be a "better Emacs" or even "like Emacs", it would be a completely different thing.
You may dislike Lisp, you may even hate Lisp, but the fact remains unchanged - there is an emerging class of applications that is significantly more difficult to build around non-homoiconic languages. Emacs is one of them. Stop fetishizing your favorite programming language as the quintessence of Emacs. The best one can do is to build a compiler/transpiler to spit out Lisp code, and people have tried that. Yet somehow, in over forty years nobody has succeeded in dethroning Elisp from ruling Emacs.
GNU Emacs is tied to Elisp. But Emacs is a much wider family of editors written in a multitude of languages.
> Yet somehow, in over forty years nobody has succeeded in dethroning Elisp from ruling Emacs
That might have several reason. Maybe few people are interested to reimplement GNU Emacs in a different language. Like nobody has succeeded in dethroning C from the Linux kernel, using Lisp.
Sure, there's Guile Emacs, there's MicroEmacs - both not Elisp-based, still built on top of Lisp dialects; there's XEmacs, Remacs - both still use Elisp, there's also mg which afaik completely not lisp-based, but I don't know how much of it still 'emacs-like'. In general though, GNU Emacs is what people usually mean when they speak about Emacs, unless they're explicitly talking about others.
Here is an old Emacs timeline:
https://www.jwz.org/doc/emacs-timeline.html
The actual historic Emacs wasn't written in Lisp and was not extensible in Lisp. It was written on top of TECO and assembly. It was extensible.
The second and third Emacs were both written in Lisp (Zetalisp and Maclisp) and they were completely written in Lisp.
At some point Gosling wrote an Emacs in C and Mocklisp. Stallman took that one and rewrote it into GNU Emacs.
We have lots of Emacs variants written in languages like TECO, C, Fortran, ...
Craig A. Finseth wrote "The Craft of Text Editing: Emacs For The Modern World"
http://www.finseth.com/craft/
Chapter Ten of above book describes what Emacs-type means: http://www.finseth.com/craft/#c10
Extensibility is a general feature and not tied to Lisp or GNU Emacs.
The book contained a list of Emacs implementations. An newer list is here: http://www.finseth.com/emacs.html
You can see that there is a multitude of editors in the Emacs category. The list also mentions the implementation and the extension language.
> GNU Emacs is what people usually mean when they speak about Emacs
That's a bit sad. It's like saying "Linux" and think that its the same as "Debian Linux". Similar there are a lot of different Emacs-like editors. Claiming that there is only a single way to implement Emacs goes against the evidence that there are a lot of Emacs-like editors, which are not implemented in C + Emacs Lisp, including the original first Emacs.
I would think that by far the most important Emacs is GNU Emacs, but I don't think its implementation language choice (C + Lisp) is necessary to implement an extensible Emacs-like editor. Also be aware even though GNU Emacs is a popular Emacs editor, there are some people who are using different Emacs-like editors instead. I typically use a Hemlock variant written in Common Lisp and Zmacs, written in ZetaLisp. Both core designs date back many decades, actually even before GNU Emacs existed.
So, I still can't see how that doesn't prove my point even further. These Emacs variants are based on Lisps, like you just said. I don't see anything "Emacs-like" today that's hugely based on a non-homoiconic language. Please, if you know any editor that allows me to modify the behavior of any given function/procedure/command with the same level of granularity as the advising mechanism of GNU Emacs, I would love to know about it.
> Please, if you know any editor that allows me to modify the behavior of any given function/procedure/command with the same level of granularity as the advising mechanism of GNU Emacs, I would love to know about it.
Zmacs did that before GNU Emacs existed. It also allowed ALL parts of the editor to be changed, not just the ones written in Emacs Lisp for GNU Emacs. Remember, the core of GNU Emacs - both the core Lisp implementation and some core editor and UI functionality - is written in C.
Btw., on a real Lisp Machine the editor (Zmacs) was not the main user interface. For example on a Symbolics (but also in Interlisp-D), the listener and a file browsers were their own applications. Zmacs in Genera has a Dired mode, but no listener. Also Genera can run multiple Zmacs windows in the same Lisp, running concurrently -> the Lisp supports multiple threads and the applications use that feature.. Something which GNU Emacs can't easily do. It's mostly blocking and single threaded. Something which can't be easily fixed in Emacs Lisp.
Run Lisp code in GNU Emacs in the REPL (m-x ielm) and it blocks the UI. That can't trivially fixed and is a major implementation fail of GNU Emacs.
Other Emacs-like editors can run multiple things, without blocking the user interface.
Like interactively, without restarts and all? Wow.
> That can't trivially fixed and is a major implementation fail of GNU Emacs.
Yes, that is a real big, sad flop.
---
That's what using X instead of Lisp to make "a better Emacs" sounds like, okay? Emacs is a Lisp-machine, it's built on top of Lisp, it needs Lisp to be Emacs. Otherwise it wouldn't be Emacs. Like at all. Don't be stupid, stop saying stupid shit like "python instead of lisp"...
Can you imagine people enjoying the user experience of Emacs while simultaneously preferring languages that are not Lisp?
It's not "for me", it is what it is. Emacs first and foremost is a Lisp machine, with a text-editor built into it, not the other way around, it's not a text-editor that uses Lisp as its configuration language.
"user experience of Emacs" is to be able to send any expression and sub-expression without any preceding ceremony directly to the REPL. Everything what Emacs does stems from that. No, Python doesn't have the same REPL. Every single stage of it in Python is different. Lisp's Read, Eval, Print, Loop - they all have slightest differences. Those differences are possible because of Lisp's homoiconic nature. Because of that you get Lisp macros, because of that you get advising functions, because of that you can do source blocks in Org-mode that can interact with and modify their own execution environment. Lisp's homoiconicity allows code to be treated as data and vice versa, enabling powerful metaprogramming capabilities. This means you can:
1. Manipulate code at runtime
2. Create domain-specific languages easily
3. Extend the language itself
In Org-mode, this translates to source blocks that can:
1. Dynamically generate and execute code
2. Modify their own content or other blocks' content
3. Interact with the Emacs environment seamlessly
This level of flexibility and power isn't achievable in Python's REPL due to its more rigid separation between code and data. While Python is highly versatile, it lacks the deep introspection and self-modifying capabilities that Lisp's homoiconic nature provides, making Lisp uniquely suited for certain advanced metaprogramming tasks and interactive development paradigms.
So the bottom line is: you can imagine really hard, but it would remain just an imagination, if you want to build something like Emacs - a REPL that has a built-in text editor, you need a Lisp, because non-homoiconic languages DO NOT HAVE exactly same REPLs. Now, do you want me to get seriously pedantic and explain how every step in ReadEvalPrintLoop differs in Lisp and Python?
I don't think it makes sense. One can build programmable editors in many interactive languages. The language for an editor doesn't need to be Lisp. It could be Python, JavaScript, Ruby, PERL, Forth, ... Typically a form of EVAL or compile/load is enough to do so.
Of course, one can - VSCode is a "programmable editor", no? Emacs is a bit different though, wouldn't you agree? It's rather a Lisp REPL that has a text-editor built on top of it.
The first Emacs wasn't using Lisp at all. Wasn't it literally the Emacs?
> It's rather a Lisp REPL that has a text-editor built on top of it.
Just write an Emacs without a Lisp REPL. It can have the same Dired, just written in Python. There is nothing in Dired, which requires Lisp.
Interlisp-D/Medley: https://interlisp.org
MIT CADR: https://tumbleweed.nu/lm-3/
These run an actual Lisp operating system.
Markers are used to mark a different point in the file and one can pop their location to a previous mark.
In response to keypresses, it doesn't bother me too much, as I'm used to the Windows-style behaviour of PgUp/PgDn/etc. moving the caret, much as the Mac behaviour of not doing that is sometimes useful. But for mouse wheel scrolling, which I do a lot - precisely because on Windows this typically does not move the caret! - having point follow along has never felt right.
Iam pretty sure you can customzize that if you want.
> scroll-preserve-screen-position is a variable defined in ‘C source code’.
> Its value is ‘keep’ > Original value was nil
> Controls if scroll commands move point to keep its screen position unchanged.
> A value of nil means point does not keep its screen position except > at the scroll margin or window boundary respectively.
> A value of t means point keeps its screen position if the scroll > command moved it vertically out of the window, e.g. when scrolling > by full screens. If point is within ‘next-screen-context-lines’ lines > from the edges of the window, point will typically not keep its screen > position when doing commands like ‘scroll-up-command’/‘scroll-down-command’ > and the like.
In emacs the cursor would be somewhere around line 600 instead.
I have a buffer manager that can switch the displayed buffer quickly, when I switch to a different buffer and back again, it retains it's "secondary" cursor position that is separate from the other view.
Instead of making the first class installable extensions plugins create a primitive called modes that encapsulate groups of plugins with extra configurations so that instead of having to pick every plugins for our setup we just pick the most popular javascript or ruby etc. mode and then add a couple of our own plugins on top.
Add some system that suggests hotkeys based on usage. If I hit l 20 times instead of just hitting f’ to get to the end of the line show a popup. Gamify the key maps and suggest key maps and features even from my plugins.
Instead of having a package manager for your editor just use homebrew and integrate it deeply into the editor.
- instant startup
- blazingly fast scrolling
- minimal keypress-to-display latency
I have written a lot of elisp (and had to deal with with buffer variables, dynamic scope, etc.), but aligning with modern scheme or lisp (if it can be kept compact and efficient) probably makes sense at this point. (Current emacs should provide backward compatibility as needed.)
Since so many people use emacs as an IDE, I think having an official emacs co-project/subproject focusing on a standard, extensible IDE framework (perhaps for other apps as well) would make sense.
It still seems like a pain to display graphics in emacs in various terminal apps. This should be easy, fast, and standardized.
As others have noted, supply chain attacks against open source are rampant, so vetting and sandboxing packages seems to be more important now.
What kind of HW are you running emacs on where this isn't the case?
b) Use https://github.com/blahgeek/emacs-lsp-booster
c) Tweak GC vars, see: https://emacs-lsp.github.io/lsp-mode/page/performance/
d) Use plists for deserialization (described in the previous link)
e) Learn how to use built-in profiler and don't hesitate to launch it, sometimes simply disabling some minor-mode in specific setting is all it takes
f) Current state of Tree-sitter in Emacs is a mixed bag - for some modes you get huge improvements, for others it's the opposite. YMMV.
https://pavelfatin.com/typing-with-pleasure/
If you have better numbers and comparisons for emacs keypress-to-pixel latency, etc. I'd be interested.
Note classic vi started up faster than vim.
Device makes little to no difference: Raspberry Pi 5, MacBook Pro M1, ThinkPad P1, etc. - emacs is clunky on all of them. I like emacs and it's my daily driver. But it isn't fast.
see also:
"Computer latency: 1997-2017" https://danluu.com/input-lag/
"Measuring keyboard-to-photon latency with a light sensor" https://thume.ca/2020/05/20/making-a-latency-tester/
Yeah it’s faster at starting up but it’s worse in pretty much everything else.
Oh and they end up typing Ctrl-this Ctrl-that anyway.
Might as well use gnu emacs.
If you don't run the output through those 2 functions, then non-printing characters remain in the output that severely undermine legibility.
C programmers tend to develop the ability to glean information from the voluminous output of build processes as it goes whizzing by on a terminal, so they find compilation mode frustratingly slow. Or at least that is my guess as to what happens.
Not that you can't work that way (and using `emacsclient` is the way to do it), but you're losing out by trying to shoe-horn usage patterns familiar from other toolchains onto Emacs. Emacs is not a text editor, it's a text manipulation platform that includes an editor - a number of editors in fact, including a vim clone.
As an aside, having it running in the background was actually the way the original EMACS that ran on ITS was intended to be used: When you C-x C-c out of it, it does not kill the program, it simply puts it in the background, and the next time you invoke EMACS it brings it back up. This is similar in effect to hitting C-z, then using 'fg' to bring it up again, but this only really works in a terminal. The Emacs server achieves the intended effect better, especially on a graphical display.
emacsclient is useful on its own. For example, I use it to edit just about any text, in any input box in any app, delegating the task to Emacs, or when I want to open some URL in Emacs, while browsing a web page in my browser, or to send some selected text to Emacs.
My config is Doom-based. I use about 300 different third-party packages, and I don't even know how many built-in ones. It takes about 1.3s to start. Wishing for it to start even faster is like wanting my microwave to warm my tortilla in 5 seconds instead of 30. I don't restart Emacs every day, nor do I eat tortillas daily. Use a modern package-manager, and defer the loading of packages, it will start very fast - just like 'emacs -q' does.
> minimal keypress-to-display latency
A lot of times, setting keyboard rate is all it takes to make it nice,
On Linux: xset r rate 170 80
On Mac:
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
Free Pascal does gigabyte strings you don't even have to allocate. Then I'd read the Emacs manual, and start writing code and tweaking TECO to make it all impedance match better.
But I'm old and weird, so maybe not the best way to get there.
[1] https://github.com/mikewarot/teco