Ah, ok, it's Cocoa related. It won't happen for instance with the Lucid build of Emacs for Mac OS X, but you might need an XServer for that. Altough I could be wrong and Lucid libraries can be run under OSX if they are ported...
https://appetrosyan.github.io/posts/emacs-widget
Hopefully, similar improvements can address the issues with large locks and the lack of proper threading.
When I do run Linux I run Wayland, I daily drive macOS, but better than both are what you already allude to: the Emacs widget toolkit which will focus on replacing the GUI frontend with SDL and also (equally potentially) introducing an actor-type framework (akin to BEAM's) for communication to decouple that GUI.
There are advantages to using a native window (display your method doc popups in formatted markdown instead of plain text), but they have never really made up for the jank, so I've never committed to it. I'm glad the author took a look, though.
This was 10 years ago though, before Kitty and the new Windows Terminal.
Can GUI anything keep up?
That's true only if you think pointing devices are useless for editing and navigating code.
ADDED: I withdraw this comment.
I didn't mean to suggest that pointing devices are completely useless in a terminal, but it has always been my experience that what the device can do is severely limited compared to graphical Emacs.
(xterm-mouse-mode 1)
Also, when you've selected some text with the pointing device, does Emacs sense the selection? I.e., does (list (region-beginning) (region-end)) return the start and end of the selection?
Everything is recognized with the meta, because meta just sends an escape sequence followed by the key code for the other characters.
With all that said, there are thousands of reasons it could be working for you "it's just software" so anything can be programmed, but I'm not aware of say a terminal spec that supports more control codes. Usually when this works it's because the user has implemented one of the many workarounds available online (e.g., change the terminal emulator to send a different key code, and change Emacs to use that key code for the command). It's also possible the terminal emulator you're using has custom support built-in specially for Emacs.
I could fix this myself if I wanted to, but I've just found it's better for my sanity to work with terminal emulators as a clear spec (which includes only the limited set of control character codes) rather than work against that. For an example of how much work this can be to maintain, this is fixing all the discrepancies I've found in Alacritty where it doesn't send the correct key code by default https://github.com/robenkleene/Dotfiles/blob/4d06e9855465c00... I mainly did that to make terminal Emacs usable in Alacritty.
With all that said, if you have another terminal emulator handy, I'd be super curious if it works with that one as well.
(I've dug through the ObjC source, specifically "nsterm.m", but haven't quite figured out the core problem.)
[edited slightly for clarity]
[bug]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75275#83 [brew]: https://github.com/d12frosted/homebrew-emacs-plus/compare/ma...
I feel like there’s a vi joke in this submission subject…
I often end up facing lag and performance issues in several different aspects of using emacs. Every time I boot up vim or any of the modern editors (zed/vscode), I get shocked at how smooth they are.
I only have 3 realistic options at this point:
- stop using macos (won't because macbooks are the best hardware I can get)
- stop using emacs
- keep suffering
currently I'm doing #3, but I soon need to make the hard call and swallow the pill.
What will my next editor be? Zed? NeoVim? write my own? Is there any other lisp/emacs like editor?
EDIT: helix looks cool
> What will my next editor be?
Fancy giving a shot to Helix[0]? Not even is it pretty good out of the box, it has a scheme extension language in the work.
It couldn't handle the Git repo of Emacs' size. Every keystroke took 3 seconds to process.
I found it somewhat funny. But otherwise Helix is still a great editor worth recommending.
There is a plugin I can't live without: aggressive-indent, and it is awfully slow for me. I don't use any emacs distributions like doom, everything is hand rolled yet my keystrokes are noticeably slower than any other place.
Sometimes random operations like projectile get slow down, sometimes I'm stuck hitting c-g multiple times, it keeps popping up every now and then.
I need to restart emacs once every week because things tend to get slow by then.
And yes, magit is the slowest of them all. I've spent weeks trying to debug and fix magit but it's so slow for me. I am a magit power user despite all the jank, because it really gives me superpower.
Emacs has made me a much better developer, both because of repl driven development, and by making me grok how much power you can wield when you can mold an editor to your needs.
Switching from emacs to something else will be a long and arduous journey for me, but I can't live with the jank anymore as I get frustrated by it almost every day.
And I restart mine every 2-3 days, so it doesn't have that much time to get slowed down.
There is Lem, an Emacs- like editor written in Common Lisp, which seems quite active.
I switched to Vim, and later to NeoVim. I'd highly recommend it.
It's scriptable, and these days is scriptable in multiple "real" programming languages. It took some getting used to, but I found myself going faster in vim than I ever did in Emacs.
You might find https://vim-adventures.com/ fun for learning some of the basics. In particular, it's worth spending time learning the motion commands "in the small", because you'll spend a lot of time using them. For instance:
t (up to character) and f (up to and including character)
i( (inside parens, works with [ or < or ", or p for paragraph)
a( (same thing but includes the delimiters).
Things like that are extremely worth learning, in part because they're the "nouns" in vim's verb-noun editing model, so you'll use them in many different commands.
though i highly recommend writing your own editor. there aren't really any editors out there that can provide what emacs can provide someone who's been using it for almost a decade.
All that being said, Emacs has always worked pretty well for me on Mac. I use Emacs and PDFgrep to spelunk through multi-GBs of PDFs and it is faster than almost anything else.
But their design just seems broken, if they're re-initializing the graphics context on every runloop iteration?
So what Emacs does is keep control of its own main loop. It has a select() that listens for events, and then calls NSApplication:run in the event handler. Emacs’s implementation of run() processes all pending events and then exits and returns control to the real Emacs main loop. So every keystroke or timer event in Emacs invokes setting up and tearing down the entire NSApplication main loop.
The relevant code is ns_select_1 in nsterm.m, line 5102. https://github.com/emacs-mirror/emacs/blob/master/src/nsterm...
The model of "slurp some events from a queue-like thing, throw some drawing at another queue-like thing, then wait for another event" is precisely what [NSApplication run] already implements. Per Apple
>A Cocoa application is event driven: It fetches an event from the queue, dispatches it to an appropriate object, and, after the event is handled, fetches the next event. With some exceptions (such as modal event loops) an application continues in this pattern until the user quits it.
But what it is doing is first posting a message that will call `[NSApp stop]` then calling `[NSApp run]`. Which is odd, because `[NSApp nextEvent]` exists, but even if that doesn't work it's not the way I'd do it. However I'm sure there are very good reasons to do it this way when you know the emacs source.
> GNU Emacs is an old-school C program emulating a 1980s Symbolics Lisp Machine emulating an old-fashioned Motif-style Xt toolkit emulating a 1970s text terminal emulating a 1960s teletype. Compiling Emacs is a challenge. Adding modern rendering features to the redisplay engine is a miracle.
Emacs owns its main loop because, damnit, it created one before it was cool.
Hats off to any heroes who would manage to drag it, kicking and screaming, into this millennium.
[1] https://gist.github.com/ghosty141/c93f21d6cd476417d4a9814eb7...
But they did! As you say yourself
> For many, this slowness won’t be a surprise. There are plenty of complaints about slowness on MacOS, especially around popular packages.
So this is some parody, describing as efficient something rather inefficient
> Because Emacs is very efficient.
> For instance, dragging a window handle - depending on the machine - could result in thousands if not millions of such events, causing allocation and reallocation of gigabytes of memory;
Worst case, you just swap out the NS p pselect hack and use a w32-like separate thread. Let Emacs be Emacs and let Cocoa be Cocoa.
NS would be just as good as Windows then. Isn't that bood enough? Maybe this thread splitting is the "deep event loop surgery" the author meant? I haven't been following.
@@ -10298,7 +10298,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname) /* mingw.org's MinGW doesn't declare _dstbias. MinGW64 defines it as a macro. / #ifndef _dstbias -__MINGW_IMPORT int _dstbias; +__MINGW_IMPORT long _dstbias; #endif
/ Fix a bug in MS implementation of 'tzset'. This function should be
hollerith•18h ago
deafpolygon•18h ago
exe34•18h ago
Jtsummers•18h ago
ergonaught•17h ago
kstrauser•17h ago
f1shy•3h ago
worik•17h ago
Mēh! Maybe not "inflexible", more "inscrutable", very hard to discern any method to their madness....
uludag•18h ago
I don't think there'd be pushback on bug fixes. I think it's only new features that would only exist on macOS that get pushback.
hollerith•18h ago
jrockway•18h ago
cobbal•18h ago
http://xahlee.info/emacs/misc/emacs_macos_emoji.html
karthink•17h ago
On the other side, there are many MacOS-specific features supported by Emacs, with the recently added dictation support being one of them. If a MacOS feature is missing, it's much more likely to be due to a lack of manpower than a desire to maintain feature parity with Linux.
cobbal•17h ago
Edit: I also remember hearing that for a long time an ffi was forbidden because someone could use it to call proprietary software. Don't have a source on that one though.
hollerith•17h ago
The good news is that this fork was very competently maintained, so I had a good experience in Emacs on OS X.
The 2 or 3 times I tried "vanilla" Emacs (the one published on fsf.org) it had bugs that weren't present in Mitsuharu Emacs. One of those times vanilla Emacs did not work at all: it displayed a window, but the window was very small (i.e., incapable of displaying more than a few characters) and the usual ways of enlarging a windows on OS X had no effect. My (typing blindly) evalling (set-frame-parameter frame 'fullscreen 'maximized) also had no effect.
The homebrew package named "emacs" got you vanilla Emacs. To get Mitsuharu Emacs, you needed to install the homebrew package named "emacs-mac" instead.
Maybe vanilla Emacs got better on OS X during the past 4.5 years. I haven't had access to a Mac during that time.
goranmoomin•17h ago
[0]: https://news.ycombinator.com/item?id=44739359
uludag•17h ago
You don't have to look hard to see that the Emacs maintainers aren't actively hostile to non-free OSes. Android is another good example. The Emacs manual states "it must be necessary to consider Android proprietary software from a practical standpoint." and yet a good amount of work went in to adding support for Android.
lvass•17h ago
Not even that anymore, it seems. https://xenodium.com/emacs-send-to-aka-macos-sharing-merged-...
rpdillon•11h ago
> If you're wondering what was controversial about the patch, GNU guidelines discourage adding features targeting non-free operating systems before it can be made available for GNU/Linux. While the patch could be easily reworked to expose the native capabilities available for each platform, there's plenty of room for interpretation as to whether a rework is considered enough to satisfy the guideline. Most of the discussion was centered around this topic. Once the thread was refocused around shaping the patch, I received super constructive feedback and the patch was indeed reworked to cater for different platforms. We also agreed to rename the feature from "share" to "send". To my surprise, even RMS also chimed in on the patch discussion. Achievement unlocked?!
goranmoomin•17h ago
The patch was adding xwidget webkit support for macOS Cocoa[0], which I iterated for the next few months[1], only to side-rail into a discussion on macOS/GCC and GNUStep support policy[2], and I fizzled out.
That was abt 5 years ago, and I’ve never touched on the Emacs codebase since.
[0]: https://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00...
[1]: https://lists.gnu.org/archive/html/emacs-devel/2019-07/threa...
[2]: https://lists.gnu.org/archive/html/emacs-devel/2019-08/msg00...
PaulDavisThe1st•18h ago