Buttery Smooth Emacs
facebook.com
facebook.com
The crux of it is that macOS became more strict about what you were doing in GUI- vs non-GUI-threads, and now asserts if you fetch GUI events (I think?) in not the main thread, because of the risk of memory corruption. Ostensibly.
This bug only manifests if you compile Emacs on 10.12 (so if you install the "emacs-app" in MacPorts, for example), because then it'll link against the asserting framework. If you use Emacs from another source that compiles it on 10.11 (such as from https://emacsformacosx.com/), then it links against an older framework that doesn't have the assert, and it'll work "fine".
Considering the fractal accumulation of "clever hacks" that make Emacs work on modern GUI systems, I'm curious to see how this issue will be resolved, because I doubt it's something so simple where Emacs has proper separation of GUI vs non-GUI threads, as QED by the article ;)
The OSX support in the mainline Emacs repo (which emacsformacosx.com and aquamacs use) is a third class citizen, since very few people work on it and Stallman is always quick to remind the rest that Linux (sorry GNU/Linux) remains the priority rather than those pesky non-free OSes. The end result is that the official OSX Emacs is perpetually buggy (check emacs-devel, it breaks all the time) and lacks a lot of useful features that are available through new OSX APIs. To make matters worse, Stallman has demanded that _useful features be removed_ from the OSX branch, because _Linux doesn't have equivalent APIs_. It was disappointing to see them following through with these removals.
On the other hand, the Yamamoto Mitsuharu port is rock-solid, functionality is not removed cause Stallman said so, is actively worked on (Yamamoto was the old Carbon Emacs maintainer and knows what he's doing) and uses the latest OSX APIs. It has had flicker-free double-buffering for years, smooth (pixel-based) scrolling with inertia, integrated AppleScript bridge, integrated Apple event support, HiDPI, ligatures, graphics/SVG/animations through ImageKit, proper C-g handling, dictionary service support, proper fullscreen, and I could go on and on and on [1] ..
TL;DR
If you're using Emacs on OSX, you should be running Yamamoto's port.
[1] https://bitbucket.org/mituharu/emacs-mac/raw/892fa7b2501a403...
Original:
Interesting! However, how closely does it follow upstream for... every other feature?
I'm using GNU Emacs because I've basically standardized my use of it across platforms. Gone are the days of XEmacs vs Emacs and all the small differences between them, and GNU Emacs' development pace has nicely picked up over the past 2-3 years since Stallman stepped down as maintainer.
As long as Stallman holds sway over Emacs and can demand that one cripple his own work for _political reasons_ , I don't see this situation changing. I'm just glad that Yamamoto did not fall for the "lowest common denominator" approach and has enough pride in his own work to do things as he sees fit.
Even so, it would help if Homebrew reassigned the "emacs" package name to the Emacs fork by Yamamoto Mitsuharu.
(The way it is now, when you install with `brew install emacs`, you get FSF emacs; to get Mitsuharu Emacs, you have to know to say `brew install emacs-mac` instead.)
It's just too bad that you seldom get things to go your way.
The traditional x port flickers a bit, (dan just fixed it via xdbe, great!) but proper Ctrl-x, Command-x and just works as everywhere else. RMS politics are stupid, yes, but overall the official port is still the best.
And by "problematic keybindings" you probably mean how most graphical Emacs packages on OS X use the Command modifier key to set the meta bit.
But Mitsuhara Emacs (or emacs-mac as you refer to it) lets you assign any "Emacs modifier bit" (control, meta, alt, hyper or super) to any of OS X's modifier keys (namely, control, option, command or fn) except for the shift key.
So for example if you're on a Macbook, but you are used to the key on the bottom left's being a control key, you would add (setq mac-function-modifier 'control) to your .emacs.
To use the option key as your meta key, (setq mac-option-modifier 'meta).
>The traditional x port flickers a bit
None of the other ports you mention have ever flickered in my experience. And running Emacs under X has the disadvantage that Emacs ends up looking quite different typographically than native OS X apps do.
With the latest XQuartz and emacs 25 only "Use System Font" looks good, before we had much more good fonts. Wonder what caused this regression.
* The Craft of Text Editing: https://www.finseth.com/craft/
* Writing a Text Editor From Scratch: https://www.twitch.tv/gary_bernhardt/v/90796516
* A Modern Text Editor Built in Rust: https://www.youtube.com/watch?v=SKtQgFBRUvQ
https://docs.google.com/document/d/1_S7gv6UGLAKuo9g1tNoNbU2O...
(I won't go into jus how hard it was to find this version of the docs and extract the file on a non-Windows computer. Luckily I just did that a few months ago for unrelated reasons!)
Sounds like a good topic for a small blog post.
BTW, can you upload the original doc file somewhere? Google Docs appears to be mangling the formatting in a few places (page 28, for example).
[1] Window-Win: http://donhopkins.com/home/archive/lisp/rms.winops.txt
[2] Window-Win protocol: http://donhopkins.com/home/archive/lisp/rms.wincmd.txt
[3] A Performance Comparison of the Window Systems of Two LISP Machines: http://www.cs.cornell.edu/~rdz/Papers/ZJ-CSC86.pdf
http://bitsavers.informatik.uni-stuttgart.de/pdf/mit/cadr/LI...
> CADR Lisp Machine window system. (Not to be confused with Genera!!!
Early Genera was based on the Lisp Machine window system. Later Symbolics introduced a new window system (Dynamic Windows), but the old one (TV, ...) was still provided.
I hadn't heard of Vernon Vinge before, but the concept resonates. There's so much lore and knowledge to be found in old software packages. When I was learning how to program, I randomly found this pseudo-BASIC compiler called ASIC, which was amazing for what it could do. It provided low-level functionality that normal QBASIC wouldn't give you. I remember spending a whole summer playing with that and a free tutorial on 3D programming called "3DICA" written by some Finish students. Good times.
BTW, http://www.textfiles.com is a great place to start looking for oldies but goodie :)
[1] http://dl.acm.org/citation.cfm?id=806463
[2] http://donhopkins.com/home/archive/emacs/skull-and-crossbone...
always been partial to "A Tale Of Five Editors" ~ http://www.catb.org/esr/writings/taoup/html/ch13s02.html
I want to continue developing it, but have no idea what to do regarding design... I'm considering using Sublime's themes.
Another interesting tutorial: http://www.catch22.net/tuts/neatpad
Intergenerational software development will someday be its own sub-discipline, with professors and specialized techniques and everything.
Did you know Vinge is himself a computer scientist? IIRC, there's a point in A Deepness In The Sky where its implied that the protagonists' interstellar ramscoop ships run a descendant of Unix.
And you know, Git would be the perfect source control system for an interstellar species who various settled systems are separated from each other by light years.
Edit: Found it out myself. Install docker-tramp.el [1], `C-x C-f` to `/user@myserver|docker:mycontainer:/`
Out of the box, Konsole+Emacs do this with super.
display (image :type svg :file "splash.svg")
https://www.gnu.org/software/emacs/manual/html_node/elisp/Di...Frankly, Emacs is a fractal of hacks, but it's incredibly powerful, consistent enough from a user perspective, and usually works, so we tend to ignore it.
I wonder if something analogous this hack would be required in the new GTK front-end.
Also, are the Xt and motif versions still maintained? Surely the user base of those must be pretty close to 0 these days?
"Pulling [GTK] out into its own frontend" means taking GTK support out of where it is now, Emacs' general-purpose X11 code (where GTK is one of many supported X11 toolkits) and putting it in a new top-level window-system that's a peer of NS (for OS X) and Windows support. The new GTK window system wouldn't be allowed to use X11 functions directly. Under this architecture, Emacs would be much closer to a well-behaved GTK program and could take advantage of cool GTK tricks like Broadway support.
But SHTDI. Volunteering?
[1] https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg00...
However, I am responsive on #gtk+ answering questions to people working on this.
I have two X1 Carbon 4th Gen machines, one running Goobuntu (basically Ubuntu 14.04 with a new kernel) and one running Ubuntu 16.10. They both flicker, but differently.
Edit: Hm, no there is no synchronization between the WM and emacs in any way. So this can't be it.
(I hope this change doesn't make it run crappily in XQuartz! X-Windows programs that do double buffering draw to an offscreen buffer often perform really poorly, poorly enough that I'd definitely rather have the flicker, not least because I don't mind the flicker too much anyway.
(I assume a lot of them have a client-side pixmap that's written to manually, and then has to be sent over the network link. )
If it is slow for you, you can turn off the new stuff:
(modify-frame-parameters nil '((inhibit-double-buffering . t)))The flicker happens only with graphical Emacs (and then only on Linux IIUC).
But I must admit, this butter-smooth version of emacs sounds intriguing .. off to give it a try.
For about 6 months.
Here's the .configure you'll need: ./configure LDFLAGS=-L/usr/local/opt/libxml2/lib CPPFLAGS=-I/usr/local/opt/libxml2/include PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig
There are more things in Heaven and Earth, Horatio, than are dreamed of in your iPhilosophy. ;-)
Some of the features are already fuzzy on my mind, but I think one reason I used to use it instead of the original Emacs was the improved GUI experience.
Last time I have used it was around 10 years ago.
Though I think XEmacs is mostly dead nowadays..
Around 10 years ago is when I moved back into Windows on my main computer, so eventually I settled on using whatever Emacs version is installed, if any, when accessing GNU/Linux environments.
Another aspect was I think only XEmacs had nice menus and toolbar, until eventually Emacs added them.
"But I wants it!" is not a reason to backport fixes or issue new releases. You can always run from master for now.
Every time someone releases a new IDE or text editor or word processor I take a look and then return to Emacs. I don't mean that it is perfect, just, for me, better than the rest.
Seems to work pretty much the same as in Visual Studio to me. Mind you I hardly ever use it, I prefer to mark the region instead.
If you can add what you want to Emacs without making the new features compulsory and without removing the existing ones then by all means go for it. But I suspect that the lack of some features is simply down to no one with enough enthusiasm and expertise to build them actually wanting them. Most of Emacs' features were built by people who wanted to use them so a lot of stuff ends up being worked on just until it is good enough for the creator's own purposes.
BTW, I just double-checked, and I can indeed make it flicker when resizing the window as you mention in emacs-devel. I guess I've just never noticed since I never resize anything (maximized windows or nothing).
Granted, that's a VIM example, but I can't imagine Emacs being much better in terms of code.
That function isn't particularly bad. It's a little messy, but it's reasonable for legacy portable code.
>> This function is over 400 lines and contains over 40 #ifdefs.
This is a low-level function that is supposed to handle different platforms, so this is the function where platform-specific #ifdefs should be collected. It's mostly a giant case/switch style #ifdef wrapper around a list of platforms and features.
>> Vim tries to be compatible with every OS, including dead ones such as BeOS, VMS, and Amiga.
That isn't a bad thing. Unless there is an actual[1] problem with the legacy platform support, then it should be left in for the people that do use the "dead" OS.
> Features that drastically change behavior are enabled/disabled with preprocessor flags.
Yes, that's the point of those flags. This is to enable/disable major features like XCLIPBOARD support which isn't going to compile on non-X11 platforms, or for debug and other unusual features that shouldn't be included in standard builds.
> Cross-platform libraries like libuv didn’t exist when Vim was created.
Sure. Which is why this function exists. Also, libuv is nice, but it isn't a replacement for all of the features (like XCLIPBOARD) this function provides. Even if most of the function was replaced with a libuv port, some of the #ifdefs would still be necessary.
[1] "It's old" doesn't count.
Is the reason related to this blog post? Every time I tried to profile emacs it led me to the redisplay function, and from there i was lost..
Is there any hope that emacs will ever render code as quickly as modern 'native' apps (e.g sublime)??
(Please don't suggest spacemacs)
What drew me to it at the time was emacs --daemon and emacsclient, which lets you have the same view of the same files open in different terminals or GUI windows ("frames") and saves you from the "file already open" warnings you would get from vim when e.g. editing a file and browsing ctags in different terminals.
Things I found annoying after the switch:
* lack of tabs (situation may have changed since I switched; there's an evil-tabs package but I haven't used it. By now I just got used to emacs' way of doing buffers and frames)
* I feel like I'm fighting the built-in bindings a lot in cases like e.g. dired-mode (directory browser) and Ibuffer-mode (buffer listing)
Notes which you may find useful if you decide to try it out:
* While emacs will work in a terminal, I've found it more comfortable to use the GUI, because it saves me having to think about why e.g. trying to look up help triggers a backspace (C-h).
* my evil config, for an example of some settings and how to tame bindings: http://pastebin.com/TxxuSU8u. Not just mine, a lot of people post their init.el online, and they're often a good reference.
My specific reason was I wanted to be able to run commands asynchronously in a separate buffer, rather than switching back and forth between the editor and a terminal. The other reason is I think vimscript is terrible, and I didn't want to learn it to customize the editor. Elisp is much nicer, and the documentation is fantastic.
I've heard VIM has since gained async buffers, but not lisp.
As for knock on benefits, there is really a fantastic ecosystem of applications built for emacs that I can't imagine are possible for most other editors. This is because emacs is a lisp runtime that happens to include an editor. So it has a built in terminal, email client, irc client, Tramp mode, Org mode, etc.
Sorry, this turned into a bit of a thought splurge, but serves as a good overview of why I'm sticking with Emacs for now (after using Vim exclusively/obsessively for years).
Number one benefit of Emacs is Lisp. Hacking on plugins is a lot more pleasant because of it. I don't think I'm alone in my dislike for Vimscript and love of Lisp.
There are many other factors that make it more pleasant than Vim. I like that `M-X` just shows a fuzzy-matched list of elisp functions, I like that I can do (eg):
M-X, find-function, ENTER, [function-name]
and jump to the on-disk definition of that function.The packaging system (with MELPA) is far more satisfying and modern than my old pathogen + git repo setup for vim. I think this is getting better in vimland too, though.
As far as specifics go:
The best thing for me is autocompletion, I used YouCompleteMe in Vim which (don't know if this is still the case) used to block UI rendering all the time. I remember it being particularly irritating for JS development using Tern, which works great with the relevant Emacs plugins.
CIDER[1] is amazing for Clojure development (this is actually why I switched).
Magit[2] is much more pleasant than Fugitive IMO, though they accomplish much the same thing. For what it's worth I was never really sold on Fugitive (I just use the console...), but I tried briefly. I find myself using Magit more and more (in particular for inline diffing, "Oh what changed here since commit X" sort of stuff).
The old joke that Emacs is 'basically an OS unto itself'. I actually appreciate this. There seems to be more of a culture of developing "apps" for Emacs, things like helm-spotify[3], which are actually pretty fun/useful. I know there are mail clients too, for instance. Being able to open a console in the project dir with `SPC-'` is something I enjoy vs using TMUX.
I think, in general, I prefer Emacs' more ambitious approach when it comes to windows/buffers within the app itself. This is a difference in philosophy.
Projectile[4] is another plugin I very much enjoy using. Don't know if this is personal preference/maybe I never put in the required effort in vim-land, but I never came across anything as satisfying, simple, functional to use.
I have heard nothing but great things about Org mode[5], though I have yet to jump in there. Again I feel like I need to invest a little time into it before it becomes useful. I have appreciated (certainly in the GTK version) that Emacs supports a slightly more rich display than Vim did (Images, bullet points etc). This is just eye candy, though. Also comes with the caveat I never tried GVim, maybe it is also capable of these things somehow.
The single most frustrating thing is my current inability to tame the auto-indent algorithm, as well as TAB's behavior. I don't know if this is Spacemacs specific.
1. https://github.com/clojure-emacs/cider-nrepl
2. https://github.com/magit/magit
3. https://github.com/krisajenkins/helm-spotify
defaults write NSGlobalDomain KeyRepeat -int 1 defaults write NSGlobalDomain InitialKeyRepeat -int 10
It will setup blazing fast keyboard repeat rate.
I also use this in my .vimrc for even smoother ride:
set scrolloff=999 set scrolljump=-100
I think the new iTerm2(3?) is quite a bit faster, but you probably use that already. Try Terminal.app and see if you notice a difference.
If you run `vim -u NONE` and then open a file, is it still slow when you hold j?
Ain't that how X11 was originally envisioned? You'd create a bunch of windows made of many smaller windows. At least, that's the impression I got when I started playing around in X11 (mostly for StumpWM hacking).
One of my goals was to unify shell-mode (and related "comint" modes) with a proper terminal emulator, but had a hard time getting traction for this. So people added horrible hacks like color support to shell-mode, instead of improving term-mode. I mentioned this unification goal recently (see bug#22785 "comint/shell modes should be merged with term mode"), but people still don't get it.
These days I'm back to working on terminal emulators, but using Web technologies (DOM, JavaScript, CSS). It's pretty cool, IMNSHO. Please check out DomTerm (http://domterm.org).
The built-in terminal emulator is atrocious, both code-quality and feature-wise.
It would be a big failure for Emacs.
Can anyone explain?
Reuse over SSH is a compelling reason. Do you still have low resource requirements if using things like linting, hinting, and full graphical debugging?
Exactly. Now, imagine being able to use that same IDE for everything JetBrains supports, and to read man pages, and to read info pages, and to read & compose email, and to list the processes running on your computer, and to manage files in directories, and to emulate a terminal, and to browse the web, and to play NetHack, and to use IRC, and to manage git repos, and to do every other thing you want. And all the keybindings remain consistent throughout all of those modes. And you can easily schlep data back & forth between them. And it's extensible in a relatively sane language (sane compared to Java, JavaScript, C, C++ and Python, anyway).
That's why we use emacs. That's why it's very difficult to understand why anyone else doesn't use emacs.
> Do you still have low resource requirements if using things like linting, hinting, and full graphical debugging?
Emacs can be pretty amazingly fast even with all of that running. There are advantages to having first been written back when computers were small.
FTR I've been using Emacs for over two years and didn't bother yet to learn "real" navigation commands. I use arrow keys + Shift/C and/or mouse/trackpoint.
For most bigger projects I use the appropriate IDE (normally JetBrains or QtCreator) unless I'm on a laptop.
-C-f
-C-b
-C-n
-C-p
-C-v
-M-v
-C-s
-C-r
-And finally, whatever key you bound ace-jump-mode to. Seriously, if you are on Emacs, you really need acejump. It's just that good.
Another thing is that Emacs movement is also very fast relative to some IDEs which sometimes pop up other windows which you have to interact with like in JetBrains Switcher.
That being said if you write IDEs just look at how fast, easy to configure, and complete buffer movement is in Emacs. We want these features!
I tried ace-jump and have it configured for months, I never use it. neither do I use swiper, because it is too slow to start.
Also, don't forget C-M-{left, right, up, down} commands :)
Edit: Oh you meant "why would you use evil mode". Disregard.
In the last week, I've edited javascript, html, python2, python3, sql, json, yaml, graphviz, markdown, and docker files. Looking back a little longer, throw in C, C++, bash, z-shell, R, lisp, LaTex, and perl5.
Having an appropriate and reasonably consistent editing experience works for me. For Java, the eclipse experience has grown on me, so I prefer editing Java outside of emacs for anything but quick edits. I pretty much just do quick edits in C or C++, but if I were to be doing it daily I would probably prefer a dedicated IDE like Visual Studio. I'd probably prefer Viz Studio for python, but that would require working in a windows VM and that's just not going to happen.
The utility of some basic functions like column editing, zap-to-char, hippie-completion, macros, yasnippet, etc. that I've grown used to over the years coupled with syntax highlighting and predictable indentation for pretty much anything I'm editing makes it hard to seriously consider another editor. I'm sure vi/vim users feel the same way about features that seem small but get used very frequently.
Regardless, it all boils down to productivity. I'm productive in emacs, so I like it. I wouldn't force somebody to use it - or even recommend it for someone who didn't have the time to build the muscle memory before needing to be productive.
Well, neither do we emacs-users: every language we write in has an amazingly great IDE, because emacs is our IDE for every language. And, other than go-mode's wanton breakage of M-., there aren't generally gratuitous inconsistencies when switching between languages.
I don't really think of emacs as being a solution in resource-constrained environments (although it works well there too): it's excellent on its own, not just a way to eke out constrained resources a bit further.
Macros are invaluable. Search and replace regexp is invaluable. Compare buffer, unique, sort and rectangular insert is invaluable.
There is no purpose-built python IDE that is tailored to my use case. The closest is ipython, and I already run that parallel with emacs when doing more complex python coding.
That said, the things that keep me in emacs:. Magit, eshell, tramp, many toy enhancements I have written, I like the themes, erc, and org mode.
Eh, out of the box you're right, but I'd advise most folks to just install prelude (or if they're coming from vi-land, spacemacs), which has already done all the configuration for one.
For example, there are IDEs that have excellent code generation for Java (not defending the practice of boilerplate getters/setters, just pointing out a feature that people use). There are IDEs with hinting, linting, and debugging built-in and requiring no configuration.
My question was: at what point is the ultra-flexibility of Emacs no longer worth it?
In North Korea, I am not sure they have many alternative if they want to chat about freedom of speech.
Though, I appreciate that you compare Facebook to North Korea.
I haven't ever experienced any flickering on emacs myself, but thanks to the author for the patch anyways. One thing I'm looking forward to is the concurrency patch.
Styles of reading also vary. You do not always have to struggle through "boring" parts to be able to understand the parts that you think are more important or interesting. (I, for one, thoroughly enjoyed the entire piece, having found all parts equally interesting and fun to read.)
In the mean time comments like yours dissuade other people from putting themselves out there. I'll get 100 positive responses on something I write or say at a conference, but the 1 hater always sticks out more. If that means fewer people write publicly it makes us all worse off.
This kind of pissing contest does nobody any good, while we're on the topic of adding value to HN
The author doesn't appreciate the motivation and constraints that led to this. Obviously Emacs has been hugely successful despite these perceived "flaws". For me, it's a feature that it still supports old terminals and yes, I do use it. I haven't seen the patch, but it wouldn't surprise me if it breaks old functionality that some of us depends on.
It manages to be fairly lighthearted and fun, while still teaching me something about Emacs. All in all, I really liked it.