8 ms·
Emacs standing alone on a Linux Kernel
- bigdict 4y agoI don't get it. It's Emacs installed on Linux. So what?
- pama 4y agoOther than emacs, the only available command on that Linux system is mount. Not even a shell.
- bigdict 4y agoThen how are the commands in the code listings executed?
- samus 4y agoEmacs' `dired` mode might or might not be able to produce a directory listing by itself. However, the author admits that > Of course, quite a number of syscalls are missing from emacs (not available as elisp primitives), so as it is, it would be hard enough to do EVERYTHING with emacs, but this is a starting point.
- ertian 4y agoeshell (emacs' shell) has it's own versions of common shell commands, written in elisp.
- photonbeam 4y agoPeople joke about emacs being an operating system, here emacs is the whole userland
- ihatepython 4y agoWouldn't that be kind of bloated?
- HopenHeyHi 4y agoThis is actually smaller: https://busybox.net https://busybox.net https://re-ws.pl/2020/11/busybox-based-linux-distro-from-scratch/ https://re-ws.pl/2020/11/busybox-based-linux-distro-from-scr...
- anthk 4y agoUhm. On the 2.4 era, you could boot a Linux floppy to play Nethack on it: NeHaBoDi. https://nehabodi.sourceforge.net/ https://nehabodi.sourceforge.net/ I wonder if I could do the same with Slashem.
- JadedEngineer 4y agoIIRC a single-thread, slow userland that is. Emacs is the only CLI program I've ever run that would take a second or two to render when quickly switching tmux panes. I'll never get the "use emacs for everything" mantra.
- dingosity 4y agobecause it does what i want my computer to do. sure, VI would be faster, but i would have to use vi.
- q7xvh97o2pDhNrh 4y agovim is also pretty slow these days. Even after I did the usual toil of analyzing startup times and trimming my vimrc, its speed/responsiveness correlates inversely with the size of the text file that's open. And we're not talking about some artifically-constructed benchmark — just an extra-long ordinary text file (or log file, or code file) sitting around will be enough to make vim start to feel slow. Maybe we're all just getting old, and the dream of "one text editor for everything" is becoming one of those quaint old notions of yesteryear.
- tenebrisalietum 4y agoThe Linux kernel, when it boots, will perform all its setup, then launch a program. That program has traditionally been `/sbin/init` which launches all background things that need to be running, including your `getty`'s for console login, your `sshd` for SSH login, and your `gdm`'s or what not for GUI login. Lately it's `systemd` which does the same in a less simple but more flexible/featureful manner. Here, there is literally no other process running but Emacs - it's your "login shell." This is the first step in replacing `systemd` with `emacs`, and it will take less space and be easier to use. /s
- pjmlp 4y agoI guess in such configuration 8 MB should be enough.
- nasretdinov 4y agoIt would be constantly swapping though
- teddyh 4y agoBefore GRUB, (i.e. with LILO), you could easily do this at any time by just booting with the added kernel parameter “init=/usr/bin/emacs”.
- ilyt 4y agoI mean, that works and always worked, bootloader really have nothing to do with it (as commandline can be baked into kernel image even if bootloader wouldn't support setting it)
- teddyh 4y agoTrue; what I was thinking of was not GRUB or LILO, but the fact that setting the init process from a kernel command line is less useful for hacks like these if the initial root file system is only an initramfs images from /boot, and does not contain Emacs.
- planede 4y agoYou can configure additional kernel parameters just fine with GRUB.
- teddyh 4y agoYep, I was thinking of initramfs on /boot vs. direct root fs mounting, not GRUB vs. LILO.
- pierpa 4y agoNext: Emacs on bare metal.
- dingosity 4y agoOr a CPU that executes e-lisp as it's machine code.
- zie 4y agoWe have had lisp machines, but I don't know of any that run e-lisp specifically.
- lispm 4y agoThey did not run Lisp as machine code. They either ran a machine code, which Lisp was compiled to, and/or they ran a Lisp interpreter, which ran Lisp source code. The machine often was kind of a stack machine, with microcode implementing the instruction set.
- zie 4y agoCorrect. But for all practical purposes they were lisp machines, you turned them on and got a lisp prompt, not a basic prompt which was the more common language to boot into back then.
- lispm 4y agoThat's right. What them made Lisp Machines was a mix of things: * the command interface is based on the Lisp REPL (read eval print loop) * the operating system itself is written in Lisp * the instruction set of the CPU is optimized for Lisp (for example via microcode) * the CPU itself might have hardware support for Lisp (for example for efficient GC) * the hardware itself (console, keyboard, system bus, extension cards, memory, ...) is used directly from Lisp and might be optimized for it (like special keyboards, special memory cards, special fronted computers, ...) What's OTOH rarely is the case, that they run Lisp directly in Hardware -> which would mean that the CPU itself is a Lisp interpreter.
- _yb2s 4y agoI can't believe nobody posted this quote yet: "Emacs is a great operating system, lacking only a decent text editor"
- jb1991 4y agoIt probably was not posted because it’s untrue. No point in posting inaccuracies. Emacs is a great text editor.
- deleted 4y ago[deleted]
- smitty1e 4y agoJokes are the unit tests of our understanding. Sure, the gag "fails", but it makes the point of the general usability of the infamous Lisp-machine-in-editor-drag.
- _yb2s 4y ago"decent" or "great" are personal emotional responses, they cannot be true or false
- m463 4y ago
- FullyFunctional 4y agoIn 1989 when I was part-time IT staff at Århus University, CS. Dept. we had to turn down a professor who requested doing exactly this with his Sun workstation (it might have been possible, but we didn't have the resources to support it). My only requirement for my first personal PC (T1800, 386/sx, 4 MiB, monochrome) was that it could run True Emacs (on Linux) - I could certainly have used this, but `exec emacs` achieves nearly the same.
- Y_Y 4y agoFortunately I don't work at universities much any more, but I found IT to be even less accommodating than at a megacorps. My department luckily realised this early on and classed all computers as "experiment equipment" and had our own techs to any necessary admin.
- hestefisk 4y agoDAIMI! Did you code in TRINE?
- tripleo1 4y ago?
- FullyFunctional 4y agoThis is getting pretty off-topic, but for the record: I think I was taught that 1st year, or perhaps the predecessor. It's was MIS' first year teaching. IIRC, Trine's array started at 1 and there was much debate over the merits of that vs. starting at zero like C but other than that it was a reasonable language for the time.
- anthk 4y agoWell, back in the day you could run Emacs and a Scheme interpreter (MIT Scheme) as a textinfo format under an i386 just fine. No X, of course.
- NoGravitas 4y ago
- Y_Y 4y agoWhile this is a bit silly, I'd love to emacs as a DE option alongside KDE, Gnome etc.
- bigfishrunning 4y agoYou can! https://github.com/ch11ng/exwm https://github.com/ch11ng/exwm
- hestefisk 4y agoEight megabytes and constantly swapping
- Ruq 4y agoI'd just like to interject for a moment. What you're referring to as Linux, is in fact, Emacs/Linux, or as I've recently taken to calling it, Emacs plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning Emacs system made useful by Emacs. Many computer users run a modified version of the Emacs system every day, without realizing it. Through a peculiar turn of events, the version of Emacs which is widely used today is often called Linux, and many of its users are not aware that it is basically the Emacs system, developed by the Emacs Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the Emacs operating system: the whole system is basically Emacs with Linux added, or Emacs/Linux. All the so-called Linux distributions are really distributions of Emacs/Linux!
- red_phone 4y agoAbsolutely genius.
- anthk 4y agoYou joke, but an Emacs with framebuffer support and with everything statically build would be Stallman's dream: a next-gen LISP Machine.
- bheadmaster 4y agoEven better - compile Emacs as a kernel module, and run it in ring 0. ELisp would give it memory safety, so memory protection would not even be necessary. System calls have never been so cheap!
- nequo 4y agoThen we could finally live the dream and run Emacs in kernel mode sandboxed inside QEMU.
- wkdneidbwf 4y agothis is both cool and exactly why i don’t want to use emacs.
- tripleo1 4y agoAlso, nobody wanted to run the old Firefox-based distro where the userspace (from X up) was in XUL.
- trashface 4y agoBeen a long time since I used emacs (had to stop, it was hurting my pinky) but I did use M-x shell a lot, I always thought it ran bash but from this description I understand emacs has its own shell?!
- excircul 4y agoM-x shell does run bash (or whatever is your user’s shell) M-x eshell is a shell implemented completely in Emacs Lisp and integrates with Emacs really nicely
- dinom 4y agoDid you try swapping or replacing capslock w/ ctrl? Something like this... setxkbmap -option ctrl:nocaps xmodmap -e "keycode 107 = Control_R" I would occasionally experience some pinky pain until I did this. Losing capslock is mostly inconsequential (you can always use upcase-region).
- kagevf 4y agoThis is a useful guide to the different shells in emacs: https://www.masteringemacs.org/article/running-shells-in-emacs-overview https://www.masteringemacs.org/article/running-shells-in-ema... (the whole site has lots of information about emacs)
- zokier 4y agoDo you actually need mounted rootfs to run emacs though?
- lisper 4y ago> Another, more realistic, alternative would be to use a Common-Lisp implementation with a FFI and portable Hemlock. Now there is an intriguing idea...
- tmtvl 4y agoFortunately, FFI is fairly well supported in CL: https://cffi.common-lisp.dev/manual/html_node/Implementation-Support.html https://cffi.common-lisp.dev/manual/html_node/Implementation...
- lisper 4y agoYes, using CL+Hemlock as the init process is very doable. That's what makes it an intriguing prospect!
- 1letterunixname 4y agoRMS essentially uses emacs as his "OS", so this seems a natural conclusion.
- ggm 4y agoWhat would be impressive would be exposing a mechanism to make sysctl() and ioctl() work, and control device driver dynamic load. Or, introspect the FS state from the binary. "just install the command you need in /bin" is cheating.
- phendrenad2 4y agoActually, you can embed emacs inside of the kernel binary itself. https://wiki.gentoo.org/wiki/Custom_Initramfs https://wiki.gentoo.org/wiki/Custom_Initramfs Then just drop the kernel image onto your EFI partition, and you have a single-binary Linux/emacs system!
- ggm 4y agoThink lua in BSD kernels probably gets what people want
- hulitu 4y ago> Typically, an initramfs is not needed, but may be necessary for: Mounting an encrypted, logical, or otherwise special root partition Providing a minimalistic rescue shell (if something goes wrong) Customize the boot process (e.g., print a welcome message) Load modules necessary to boot (e.g., third party storage drivers) Anything the kernel can't do that's usually handled in user space So a lot of things which are not emacs.
- phendrenad2 4y agoBut can be used for emacs
- jdblair 4y agoNow do Linux standing alone on top of Emacs.
- lynx23 4y agoI had Emacs running as PID 1 inside of an initramfs roughly around 2010. Had a part of sysvinit reimplemented in Emacs Lisp, for things like ALSA and networking. Kernel + initramfs was roughly 200MB IIRC.
- phendrenad2 4y agoYeesh, reading the top comments, HN really has become the Slashdot I remember. Good times ahead. Anyway, one thing this brings to mind is how much of Linux is encapsulated within the kernel itself. This is why distros feel so... similar.
- hulitu 4y ago> Compile mount statically This is cheating. Why not use also bash when you claim you only use emacs ?
- abudabi123 4y agoEmacs on seL4kernel with Plan9userspace and remote desktop to disposable Mac or Linux shortlived desktopui should be very secure for the researcher.
- hprotagonist 4y agounless you have a hankering for benson&hedges cigarettes.
- froh 4y ago/me (from outside the loop): "huh?"
- nescioquid 4y agoSounds like a reference to The Cuckoo's Egg (fun read).