[HN Gopher] Emacs should become a Wayland compositor
       ___________________________________________________________________
        
       Emacs should become a Wayland compositor
        
       Author : pabs3
       Score  : 261 points
       Date   : 2022-12-04 01:27 UTC (21 hours ago)
        
 (HTM) web link (emacsconf.org)
 (TXT) w3m dump (emacsconf.org)
        
       | nanna wrote:
       | This is above my head, what does it mean?
        
         | unsafecast wrote:
         | Emacs is generally used as a normal program that connects to a
         | Wayland compositor (Wayland speak for window manager). The idea
         | is to instead make Emacs behave as a compositor, essentially
         | connecting directly to Wayland and bypassing other window
         | managers.
        
           | hanafudafan wrote:
           | Correction, normally it connects to x.org.
        
             | unsafecast wrote:
             | In the current context, "normal" would be Wayland. Of
             | course, most people use X (and it was the only choice until
             | 29).
        
           | stingraycharles wrote:
           | What would be the advantage? Performance, or just because
           | it's neat?
        
       | tadfisher wrote:
       | Emacs should separate the command loop from redisplay first. At
       | least with X, another process is managing the display, so I can
       | deal with Emacs crashing or preventing redisplay. If it were the
       | Wayland compositor, I would have to avoid the many Emacs features
       | that perform work in the command loop.
        
         | donio wrote:
         | The presentation discusses this a bit around the 3 minute mark.
         | It sounds like the compositor is a separate process.
        
       | hanafudafan wrote:
       | Absolutely not.
        
       | rnd0 wrote:
       | Well...I mean yeah, sure. Why not?
       | 
       | Hey, let's throw systemd in there while we're at it.
       | 
       | Anything to procrastinate on adding a good editor to it, right?
        
         | nequo wrote:
         | It already has a good editor. It's called evil mode:
         | 
         | https://github.com/emacs-evil/evil
        
           | gnull wrote:
           | Is Kakoune mode anywhere in sight?
        
             | yw3410 wrote:
             | There's meow-mode and others.
        
               | LanternLight83 wrote:
               | Checking this out, thanks!
        
         | tmtvl wrote:
         | The default editor in Emacs is entirely fine, at the very least
         | it isn't a modal editor which is a really outdated paradigm
         | which also doesn't make any sense when most of what you do with
         | a text editor is typing in text.
         | 
         | I used Vim for 5 years, tried various different editors (Atom,
         | Geany, Kate,...), and now for the past 4 years I've been using
         | Emacs. And I'm liking it a lot more than Vim (though that may
         | have something to do with my switching from typing QWERTY to
         | Dvorak).
        
           | marcosdumay wrote:
           | > at the very least it isn't a modal editor which is a really
           | outdated paradigm which also doesn't make any sense when most
           | of what you do with a text editor is typing in text
           | 
           | Hum... As an emacs user, I'm quite comfortable to disagree
           | here.
           | 
           | When in an editor, you want to both type text and run code.
           | Vi only messes up on the emphasis for both cases (due to the
           | legacy of descending from ed), but even emacs has a "run
           | code" mode.
        
           | opan wrote:
           | I've been perfectly happy with vim binds using both dvorak
           | and workman layouts. Sticking with it from the start when
           | you're slowly relearning to type at all makes it feel normal
           | in a week or two at most. The only meaningful change is hjkl
           | since it's positional in qwerty. The other stuff was all over
           | and based on mnemonics like d for delete. If you can get used
           | to C-n, C-p, C-f, and C-b for emacs movement, hjkl shifting
           | around is not at all harder. There's also the fact that in
           | many cases you probably move around with something like e or
           | w or the search rather than smaller hjkl movements.
           | 
           | Modal editing has ergonomic benefits similar to Sticky Keys,
           | I don't see anything dated about it.
           | 
           | I'm not sure I agree writing is done the most either. Moving
           | around is probably pretty high up there. It does depend on
           | the file of course, but for config files or [video] playlist
           | files you probably do more small edits and movements than
           | writing of pure text. Writing email would be the other
           | extreme.
        
         | sping wrote:
         | Are there any good Emacs jokes that _aren 't_ based on
         | ignorance of Emacs?
        
           | ninjha01 wrote:
           | I could come up with one, but I'm too busy rewriting my
           | config to use a better package manager _again_.
        
             | bloopernova wrote:
             | You need to install yak-shave-mode to make that more
             | efficient.
        
             | andreareina wrote:
             | Oh no have we moved away from straight and use-package
             | already?
        
               | imaltont wrote:
               | Emacs 29 can download packages straight from their source
               | too, so time to move back I guess.
        
           | donio wrote:
           | Eight Megabytes and Constantly Swapping is pretty funny now
           | that everything else needs several GB of memory.
           | 
           | (But to be fair even a minimal Emacs is about 20MB RSS these
           | days).
        
             | mftb wrote:
             | Hmm, I can't get an RSS that small even with -nw (to use
             | the client TUI), but leaving that aside, on my box just
             | running GNU Emacs normally I get 88MB RSS, so maybe we just
             | need to update the acronym. ;)
        
               | donio wrote:
               | I had to rebuild it with everything turned off in
               | ./configure to get that number.
        
               | mftb wrote:
               | Interesting, I was thinking it was probably a fork.
               | Anyway good to know, ty.
        
             | Gordonjcp wrote:
             | I think it's nuts that the Linux machine I run DaVinci
             | Resolve on today has considerably more RAM than the Windows
             | NT machine I used to use Premiere for editing on 22 years
             | ago had hard disk space.
             | 
             | Back then mine was the "scary" machine in the workshop with
             | its AMD Duron 700 and a whopping 512MB of RAM... and Emacs
             | was just about usable on it!
        
           | distantsounds wrote:
           | the only ignorance is from you, not realizing how much better
           | literally any other text editor is
        
             | nequo wrote:
             | > literally any other text editor
             | 
             | Have you tried literally every other text editor?
             | 
             | I switched from Vim. In Emacs, I can inline previews of
             | LaTeX formulas in the same buffer as the one that I am
             | editing. This is possible because Emacs has a GUI. Vim
             | cannot do this because it runs in the terminal, and it also
             | doesn't seem possible to do this in gVim.
             | 
             | Meanwhile Emacs implements Vim's modal editing through evil
             | mode. So for this use case, Emacs seems to be strictly
             | better than Vim.
        
             | pvaldes wrote:
             | Yup, those days of Joe and roses...
        
           | andreareina wrote:
           | I'm partial to escape-meta-alt-control-shift
        
           | rnd0 wrote:
           | Yes. https://xkcd.com/378/
        
             | rnd0 wrote:
             | Though technically it's a alpha nerd joke with an emacs
             | punchline.
        
               | donio wrote:
               | And it gets the keybinding wrong so it falls into the
               | ignorance category. But at least we got M-x butterfly
               | thanks to it.
        
               | benj111 wrote:
               | Can you get a keybinding wrong for a command that doesn't
               | exist?
        
               | Jorengarenar wrote:
               | What made you think it does not exist?
        
               | benj111 wrote:
               | Fair enough. What is the keybinding then?
        
               | imaltont wrote:
               | M-x butterfly C-M-c(or RET), made in reference to the
               | xkcd. Been in there since version 23.
        
               | owl57 wrote:
               | It seems more nuanced. What does it mean that the command
               | doesn't exist? Every serious Emacs user has their own
               | personal bindings, some of those for their own custom
               | commands. But "M-butterfly" suggests more rare hackery,
               | though seemingly trivial for the hypothetical butterfly
               | hacker: they have a "butterfly" key in their keyboard
               | layout.
        
             | dicytea wrote:
             | The fact that the punchline isn't a valid (or at least not
             | a conventional) Emacs keybind still bugs me.
        
               | moloch-hai wrote:
               | M-nerdsniping.
               | 
               | He knew what he was doing.
        
           | funsevenshirt wrote:
           | > Are there any good Emacs jokes
           | 
           | No, there aren't.
        
         | jmclnx wrote:
         | Well I an sure it would be better that all the other existing
         | Wayland Window Managers or Desktops :)
        
           | donio wrote:
           | If done right then yes, it will be. EXWM is the best X11 WM
           | after all. Being able to treat X11 windows as Emacs buffers
           | with the same buffer management mechanisms and keybindings is
           | amazing.
        
             | snickerer wrote:
             | EXWM sounds very cool. Thanks for the hint -- I never heard
             | about it.
             | 
             | I use swayWM and Emacs (with frames instead of windows) and
             | configured sway to have Emacs-style key bindings. So I
             | mimicked EXWM behavior without knowing about EXWM.
        
               | donio wrote:
               | It's definitely worth a try. I used StumpWM for 10 years
               | before switching to EXWM about 5 years ago. One great
               | thing about merging the concepts of Emacs buffers and X11
               | windows is that there is only one set of keybindings you
               | need to worry about (the Emacs ones).
        
       | IceDane wrote:
       | Emacs running a WM is a disaster. It's also slow as hell. It's
       | hilariously slow.
       | 
       | Suggesting using it as a compositor is sort of like suggesting
       | sawing your own leg off. Makes no sense and is obviously a stupid
       | idea.
       | 
       | FYI i daily drive emacs for everything and have probably written
       | a million lines of code in it through the years, but I'm not
       | gonna pretend it isn't janky as all hell.
        
       | silon42 wrote:
       | Wayland compositors all the way down.
        
       | dtx1 wrote:
       | Emacs already is a great operating system i just wish it had a
       | good Editor
        
       | rayiner wrote:
       | A neat byproduct of this would be a more elegant solution to
       | embedding external programs as currently done through the emacs-
       | xwidgets framework.
        
       | amadeuspagel wrote:
       | When will chrome become a wayland compositor?
        
         | pritambaral wrote:
         | I think it already is, on ChromeOS:
         | https://chromium.googlesource.com/chromium/src/+/HEAD/compon...
        
       | thecosmicfrog wrote:
       | Emacs as PID 1 is the only logical conclusion.
        
         | matheusmoreira wrote:
         | Let's go further. Emacs on bare metal.
        
           | stirfish wrote:
           | Emacs etched on a custom ASIC.
        
         | ticviking wrote:
         | In many ways I trust Emacs more than systemd.
         | 
         | Not enough to use it as PID1 on real hardware, but enough to be
         | tempted to try it in a VM
        
         | e3bc54b2 wrote:
         | Here you go: https://github.com/a-schaefers/systemE
        
         | krylon wrote:
         | Once you go there, why not put Emacs on bare metal? It'll run
         | that much faster.
         | 
         | You can put in a hypervisor (M-x start-virtual-machine) to run
         | a bloated Linux distro so you can Firefox or Chrome (M-x start-
         | virtual-machine-with-browser), but I'm sure somebody can
         | streamline that even further.
        
         | mtlmtlmtlmtl wrote:
         | Someone already did this back in the day and the only extra
         | utility needed was mount.
        
           | entropie wrote:
           | One still needs an editor, right?
        
             | ticviking wrote:
             | Evil is a fine editor.
        
               | fiddlerwoaroof wrote:
               | Best implementation of the vim standard
        
               | Kamq wrote:
               | It's surprising how good it is.
               | 
               | They even get the = register. Evaluates elisp instead of
               | vim script, but what are you gonna do?
        
               | yjftsjthsd-h wrote:
               | > Evaluates elisp instead of vim script, but what are you
               | gonna do?
               | 
               | Celebrate? I like vim, but I don't think I've ever heard
               | someone praise vimscript; even neovim added lua.
        
               | Kamq wrote:
               | The big annoyance on the elisp front is it makes math
               | slightly more annoying (~80% of my usage of the
               | register).
               | 
               | Trying to evaluate x + y and have vim insert the result
               | is now (+ x y), which is more key-presses. It's a
               | trivial, but slightly annoying in my common case.
               | 
               | Also throwing a bunch of things into an array and
               | indexing into the result, then incrementing a number is
               | more complicated as well (I usually run this in a macro
               | to process a list of things), which is another ~15% of my
               | usage.
               | 
               | There are a lot of things to complain about in vimscript,
               | but infix operators and c-style array indexing has never
               | been at the top of that list.
               | 
               | That being said, in the general case, elisp offers a
               | really nice way to integrate with the editor. Far
               | superior to classic vim-script. It just makes the =
               | register slightly more annoying.
               | 
               | But, asking someone someone to maintain an entire
               | language interpreter just to make the = register more
               | familiar is kinda too much to expect of someone. At least
               | the = register is there, I've never found another vim
               | emulator that even has it.
        
         | humanistbot wrote:
         | If we're doing that, then why not go all the way to PID 0?
        
           | LoganDark wrote:
           | I don't think there is a PID 0. The very first userspace
           | process is PID 1.
           | 
           | Or do you mean the kernel itself?
        
             | deafpolygon wrote:
             | Send a PR to the linux kernel team
        
             | erik_seaberg wrote:
             | kill(2) interprets pid 0 as "everything in my process
             | group."
        
         | abudabi123 wrote:
         | Can the layer between Emacs and hypervisor be as thin as an
         | seL4 microkernel and do pixel perfect framebuffer star field?
        
         | hcarvalhoalves wrote:
         | http://informatimago.free.fr/i/linux/emacs-on-user-mode-linu...
         | 
         | Wouldn't be a bad idea at all to have the equivalent of modern
         | Lisp Machine.
        
           | sph wrote:
           | I've been designing one in my head for the past month, it's
           | become an obsession. I don't know if I'm onto something, or
           | caught a really bad case of the Lisp fever. What's the
           | recommended treating regimen?
        
             | MonkeyClub wrote:
             | A bit afraid of throwing gasoline on fire, but...
             | 
             | > What's the recommended treating regimen?
             | 
             | Implement!
             | 
             | The only way out is through.
        
               | zasdffaa wrote:
               | Contact the people who designed and used Lisp machines
               | and get their very, very expert take. Many are still
               | alive.
        
               | worthless-trash wrote:
               | And please document your findings! Would love to read.
        
               | shaftoe wrote:
               | Seriously. A well documented history of the lisp machines
               | would be at the top of my Christmas list.
        
               | sph wrote:
               | Yeah, that's my plan for the weekend. I'm currently
               | working on a minimal Lisp implementation written in Rust,
               | step 2 is to compile the thing into a free-standing UEFI
               | binary, and give it the ability to execute machine code.
               | 
               | The final goal is something akin to DOS, but the prompt
               | is a Lisp that has access to the entire machine at full
               | privileges and complete control over the hardware. I'm
               | also exploring how to make it possible to rewrite the
               | most core functions from the Lisp environment, so I
               | could, for example, replace a naive "eval" function with
               | native code after boot.
               | 
               | What can you build with the most minimal "operating
               | system" paired the most meta-programmable environment? My
               | dream is to add a simple display, keyboard and have this
               | run on a RISC-V SoC, that simply boots with the prompt:
               | 
               | "> "
               | 
               | (I hate you for making me write this down and adding more
               | fuel to the fire.)
        
               | rjsw wrote:
               | Why not use an existing Lisp implementation that has a
               | good compiler?
               | 
               | Or just run Mezzano [1].
               | 
               | [1] https://github.com/froggey/Mezzano
        
               | sph wrote:
               | Because I want to follow my vision. There is space for
               | more than one thing in the world. Also, Common Lisp is
               | nice but it's anything but minimal. One of the questions
               | I want to answer is what is the minimum amount of
               | constructs you need to have complete control over your
               | hardware, while able to rewrite the entire kernel at run
               | time. I bet it's not that many.
               | 
               | That said, Mezzano is cool and I should play with it
               | more.
        
               | qubex wrote:
               | "Minimum number of constructs you need to have complete
               | control over your hardware" is a bit of a slippery slope
               | when it's known that one-instruction computers are Turing
               | Complete ("subtract and branch if negative" being one I
               | recall). There's plenty of mind-bending stuff on
               | esolangs.org
        
               | sph wrote:
               | Fair enough, but Lisp needs a little more than subleq &
               | co. to do something useful :)
        
               | qubex wrote:
               | Turing-Church Thesis disagrees.
        
             | mark_l_watson wrote:
             | You might want to look at Mezzano which is an operation
             | system written in Common Lisp
             | https://github.com/froggey/Mezzano
             | 
             | I haven't tried it since moving to M1/ARM, but it is cool.
        
             | jamal-kumar wrote:
             | I had a friend (Passed away, RIP) who went to MIT and
             | learned how to program on those things. She was really
             | confused when Microsoft went full-in on OOP in the 90s
             | because it flew in the face of everything she learned while
             | there about how to write programs that don't crash.
             | 
             | May as well go all in on that idea and make a name for
             | yourself.
        
             | moloch-hai wrote:
             | Resist! Resist! Your brain is subject to colonization by
             | self-referential idea complexes, but it is has defenses.
             | 
             | We have learned a great deal over decades about how to make
             | languages that enable building reliable, expressive
             | systems. Lisps can draw upon very little of that learning.
             | Types can do heavy lifting, where put to work.
             | 
             | Instead of rebuilding something that was tried in the '70s,
             | learn what they didn't know then, and apply it to something
             | wholly new.
        
               | sph wrote:
               | Meh. The fact that software engineers as they get older
               | they are return to older and older technologies has to
               | have a reason... or can simply be explained by declining
               | mental faculties :)
               | 
               | Types are cool, but are _way_ overrated. Correctness isn
               | 't the only useful metric to optimise for. They are
               | important if I am running a business and I don't want my
               | crashing software to lose customers, but they are a
               | hindrance if I just want to have fun and break things.
               | Fun and productive businesses have been built on Lisp,
               | BASIC and Python.
               | 
               | Languages aren't continuously getting better. They are on
               | a cycle that repeats every 25 years. We've just entered
               | another strong typing era.
        
         | the-rc wrote:
         | I doubt it was PID 1, but I saw RMS' laptop almost 30 years ago
         | and I think it booted into Emacs...
        
           | toasteros wrote:
           | When I hung out with him ~4 years ago, it booted into what
           | might have been GNOME or XFCE, but he did spend a lot of time
           | using emacs in a TTY.
        
             | BenFeldman1930 wrote:
             | When I hung out with him last year, he was fixing an Emacs
             | bug on a field notes notebook.
        
               | comfypotato wrote:
               | He's close to the average life expectancy for a human
               | male; I'm curious what his plan is regarding the
               | succession of his love for eMacs.
        
       | donio wrote:
       | Exciting and looking forward to the code! C server with an elisp
       | IPC is a good way to go about this, poor man's X11/ICCCM. Sounds
       | like it still has ways to go though. Input handling (mentioned as
       | missing) is a very big part of of what makes EXWM so useful.
        
       | wyuenho wrote:
       | > Emacs is already a great window manager.
       | 
       | Right. That's why everybody uses popwin, amiright?
        
         | backtoyoujim wrote:
         | Oh, that would be impressive, if anyone knew what a compositor
         | was.
        
       | Ekaros wrote:
       | So can I use nano inside Emacs? I mean I need a good editor for
       | text.
        
         | distantsounds wrote:
         | emacs exists at this point only to generate hacker news
         | articles, nobody actually uses it to edit text files
        
           | Elzair wrote:
           | I do!
        
           | pvaldes wrote:
           | Sorry, I was not paying attention. Too busy editing text
           | files in my emacs just right now...
        
           | packetlost wrote:
           | lol I have several coworkers who do the vast majority of
           | their coding in emacs, but go on
        
       | szopa wrote:
       | A long time ago my setup was StumpWM with Emacs with Slime
       | connected to StumpWM's lisp image. The non-trivial part was
       | getting one interface to navigate both buffers and windows using
       | C-x b. It was non-trivial because of the somehow circuitous
       | nature of the arrangement.
       | 
       | At some point I moved to a Mac because I realized that perfecting
       | my window manager setup was just killing my productivity. I hope
       | that one day I'll be able to get back to it - maybe when I
       | retire.
        
         | textread wrote:
         | Do you still happen to have the elisp for getting C-x b to list
         | both X-windows & buffers in stumpwm? Would you please share?
        
           | donio wrote:
           | EXWM is the natural way to do this, treating X11 windows as
           | Emacs buffers is what it's all about. Or are you trying to
           | get just the buffer switching part without going all the way
           | to EXWM?
        
             | textread wrote:
             | szopa[granparent] uses StumpWM, not EXWM. I am trying to
             | get the EXWM's buffer switching behaviour in StumpWM.
             | 
             | By default, StumpWM lists normal buffers on C-x b, and
             | X-windows using some other keybinding like C-t b
        
         | sph wrote:
         | > At some point I moved to a Mac because I realized that
         | perfecting my window manager setup was just killing my
         | productivity
         | 
         | Which is funny because macOS out of the box has some of the
         | worst window management ever seen on any OS.
        
         | ansgri wrote:
         | What you use on Mac for window management? Recently switched
         | from Linux Mint Cinnamon, default window management feels like
         | a downgrade, maybe I'm holding it wrong?
        
           | alpaca128 wrote:
           | I use Rectangle which makes it bearable, but its behaviour is
           | still a bit annoying. And Hyperkey for both Escape & Ctrl on
           | the Caps Lock key.
           | 
           | I'm still looking for an sxiv replacement, though.
        
           | lelanthran wrote:
           | > What you use on Mac for window management? Recently
           | switched from Linux Mint Cinnamon, default window management
           | feels like a downgrade, maybe I'm holding it wrong?
           | 
           | You're not holding it wrong, it's just a very primitive
           | desktop environment. No snapping, poor external monitor
           | support, defaults to magically moving desktops in relation to
           | each other, etc.
           | 
           | If you want good window management right out the box, you
           | won't get it from MacOS.
        
           | szopa wrote:
           | It is a downgrade, but it's a conscious trade-off for me.
           | I've been fine with that for the last 14 years. I switched to
           | the Mac to get a mostly adequate environment that I wouldn't
           | be tempted to hack.
           | 
           | The thing I actually care about is navigating between windows
           | by typing something that gets autocompleted. Spotlight or
           | Alfred get me mostly there. In chrome I use Powerswitch to
           | navigate between windows, and there's Cmd K for Slack. Having
           | one interface for those would be grand, but I'm not holding
           | my breath.
        
       | teddyh wrote:
       | Wayland integration is less interesting to me (right now, at
       | least), than the (implied) intriguing possibility of running
       | Pure-GTK Emacs directly on the framebuffer.
        
         | raverbashing wrote:
         | Fb is not great and gtk-fb neither.
         | 
         | I mean, it would work, but debatable how good it would be. The
         | thing with X is that it lets you do more with the video device.
         | Even better if you go the OpenGL way
        
           | teddyh wrote:
           | Does Emacs need any of those things? And we need an off-ramp
           | from X anyway, apparently.
        
             | raverbashing wrote:
             | If you have multiple buffers you probably want to render
             | them in the background
             | 
             | (though ok, it is a bit of a corner-case optimization)
        
       | esjeon wrote:
       | The time of Emacs/Linux is nigh.
        
         | MonkeyClub wrote:
         | 2023 will be the year of the Emacs desktop! :)
        
         | sph wrote:
         | There will be no separation of state and church (of GNU) in the
         | Linux world. Like it or not, they're inseparable.
        
         | tsimionescu wrote:
         | The only true salvation will be a HURD of Emacs.
        
         | abudabi123 wrote:
         | Emacs is the Back to the Future Lisp.
        
         | deafpolygon wrote:
         | Don't you mean GNU/eMacs?
        
         | justahuman74 wrote:
         | We could call it 'GNU/Linux'
        
           | TazeTSchnitzel wrote:
           | I'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 GNU system made useful by
           | Emacs, comprising a full Lisp system.
        
             | owl57 wrote:
             | I googled for this meme and it turns out it has its own
             | page on gnu.org, "Incorrect Quotation" [1]
             | 
             | And while reading that page I realised that I actually work
             | with GNU, not even GNU/Linux, systems in production every
             | day. Because I'm mostly working on applications deployed in
             | clouds: the kernel is managed, and I'm not sure if AWS even
             | promised that EKS runs on Linux and not something entirely
             | else but very compatible. But GNU userspace is definitely
             | there in my containers.
             | 
             | [1] https://www.gnu.org/gnu/incorrect-quotation.en.html
        
       | p-e-w wrote:
       | Watched the video expecting a joke about how bloated Emacs is.
       | 
       | Surprised to find out the headline is 100% serious.
        
         | IncRnd wrote:
         | One person's bloat is another person's feature. I know people
         | who do absolutely everything inside emacs.
        
           | merb wrote:
           | https://xkcd.com/1172/
        
           | danielheath wrote:
           | eMacs is a great OS. Just needs a decent text editor.
        
             | Narishma wrote:
             | eMacs were Apple computers, not an OS.
        
       ___________________________________________________________________
       (page generated 2022-12-04 23:02 UTC)