Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Railwaycat emacs-mac support #10

Closed
avendael opened this issue Nov 7, 2016 · 19 comments
Closed

Railwaycat emacs-mac support #10

avendael opened this issue Nov 7, 2016 · 19 comments

Comments

@avendael
Copy link

avendael commented Nov 7, 2016

In my experience, railwaycat emacs-mac is the best emacs to use in a mac. It has smooth scrolling and touchpad gesture support among other things. It would be awesome if there's an option that would install the railwaycat version instead of the cocoa version.

@d12frosted
Copy link
Owner

Good idea. I think it should be separate formulae named emacs-mac[-port]-plus, because I don't really want to merge two different formulas. What do you think?

@ghost
Copy link

ghost commented Dec 14, 2016

@d12frosted I have switched to emacs-mac. Much more responsive. Less crashes. Nicer GUI.

It's literally latest GNU Emacs + patches on top. So it is always as-up-to-date as the official repo.

It has SVG built-in via WebKit.

All you need to do is enable all these features (yes all of them, some packages require texinfo and xm2):

  brew tap railwaycat/emacsmacport
  brew install emacs-mac --with-gnutls --with-imagemagick --with-modules --with-texinfo --with-xml2 --with-spacemacs-icon
  brew linkapps emacs-mac

I also suggest updating the osx layer for Spacemacs to disable smooth scrolling in this Emacs fork by default (with an option to opt-in), because it's more like a tech-demo/hack. It probably emulates keyboard scrolling, draws a texture and tries to smoothly insert it. Sure, it "smoothly" scrolls a pixel at a time, but in reality is choppy as hell.

  ;; GUI Settings for YAMAMOTO Mitsuharu's Mac port of GNU Emacs.
  ;; https://github.com/railwaycat/homebrew-emacsmacport
  (when (and (spacemacs/system-is-mac) (display-graphic-p))
    ;; Disable pixel-by-pixel scrolling, since it's extremely choppy.
    (setq mac-mouse-wheel-smooth-scroll nil))

Instead of using pixel-scrolling, I set up my own smooth scrolling like this (this is the thing most people will want when they mean "smooth" scrolling; because the defaults jump fast as hell, so I understand why they would assume pixel-by-pixel scrolling is an improvement):

  ;; Keyboard smooth scrolling: Prevent the awkward "snap to re-center" when
  ;; the text cursor moves off-screen. Instead, only scroll the minimum amount
  ;; necessary to show the new line. (A number of 101+ disables re-centering.)
  (setq scroll-conservatively 101)

  ;; Optimize mouse wheel scrolling for smooth-scrolling trackpad use.
  ;; Trackpads send a lot more scroll events than regular mouse wheels,
  ;; so the scroll amount and acceleration must be tuned to smooth it out.
  (setq
   ;; If the frame contains multiple windows, scroll the one under the cursor
   ;; instead of the one that currently has keyboard focus.
   mouse-wheel-follow-mouse 't
   ;; Completely disable mouse wheel acceleration to avoid speeding away.
   mouse-wheel-progressive-speed nil
   ;; The most important setting of all! Make each scroll-event move 2 lines at
   ;; a time (instead of 5 at default). Simply hold down shift to move twice as
   ;; fast, or hold down control to move 3x as fast. Perfect for trackpads.
   mouse-wheel-scroll-amount '(2 ((shift) . 4) ((control) . 6)))

@ghost
Copy link

ghost commented Dec 14, 2016

Oh and that fork also AWESOMELY bug-fixes sRGB rendering of XMP bitmaps, which means that Powerline no longer looks like trash.

My config now looks like this:

  ;; Switch powerline separators to text, since the bitmaps look bad in sRGB.
  ;; It's possible to disable sRGB, but that makes Emacs colors too bright.
  ;; (setq powerline-default-separator 'utf-8)

;-)

@ghost
Copy link

ghost commented Dec 14, 2016

There is no reason to ever use the vanilla emacs/emacs-plus. They are garbage compared to railwaycat. He's had a reputation for years as the best port, and it's true.

The vanilla one is made by emacsformacosx.com. It's terrible.

Don't do yourself a disservice, install Yamamoto's Emacs fork now.

@d12frosted
Copy link
Owner

@SteveJobzniak I am glad for you. Thanks for sharing your thoughts about GNU Emacs vs emacs-mac-port.

They are garbage compared to railwaycat. He's had a reputation for years as the best port, and it's true.

Many people (including me) switched to GNU Emacs from emacs-mac-port just because the latter was so very laggy and low-peformance that it was just unusable. I should check how it runs nowadays.

Oh and that fork also AWESOMELY bug-fixes sRGB rendering of XMP bitmaps

That's great. And the fix was there for a long time. For me powerline separator is even not an issue compared to performance.

But as I said - I'll give it a try to see how it runs after switch to Emacs 25.

@ghost
Copy link

ghost commented Dec 14, 2016

@d12frosted The performance of emacs/emacs-plus has lots of random crashes (100% CPU) and brief freezes (for a few seconds) and those are totally gone with emacs-mac. Others have said the same. Railwaycat's changelogs make it seem like he has implemented better polling to avoid freezes.

And just disable the silly pixel-by-pixel scrolling (which IS slow as hell and choppy). After that is disabled, I notice only improvements compared to vanilla. I am never going back.

In 2015, the offical vanilla maintainer said that he wants to merge railwaycat's work, but nothing came of that so far.

@d12frosted
Copy link
Owner

Others have said the same.

I don't know anyone except for you saying this. But welp, we are word-comparing different versions of software. And just in case you didn't see it - syl20bnr/spacemacs#4955.

But as I said - I'll give it a try to see how it runs after switch to Emacs 25.

Only after I check it myself I can say anything about latest emacs-mac-port.

@ghost
Copy link

ghost commented Dec 14, 2016

http://emacs.stackexchange.com/a/3952/14218

I have tried all of the above options (even the tap recommended by Reiner in a comment above) by none have worked well for me (trackpad scrolling problems, hangings, etc.). I am quite happy, however, with Yamamoto Mitsuharu's fork, as mantained by railway's github page. It is up-to-date with respect to the official GNU version.

Just one of many comments I found like that. Reddit was also full of comments like that when I did research.

And yeah try it out. Either way, I am running it now and will never go back. So far I haven't had a single freeze or crash anymore.

@ghost
Copy link

ghost commented Dec 14, 2016

Well, I just had a 5 hour session without any hangs, slowdowns or crashes. That's in comparison to the emacs/emacs-plus vanilla version which micro-froze constantly and crashed/perma-froze at 100% CPU about once per hour. On the exact same dotspacemacs file and same develop branch of Spacemacs.

@d12frosted
Copy link
Owner

Well. I am using it for 5 minutes and already run into some lags / slowdowns. I know that it's not the best way to navigate, but sometimes I hold C-n or C-p to go down / up over the lines. And almost every time I do it emacs-mac-port starts to freeze and cursor disappears for a second or so. 😞

But lets see how it goes with other tasks 😸

@ghost
Copy link

ghost commented Dec 14, 2016

@d12frosted I opened my init.el (~900 lines) and held down C-n and then C-p for about 2 minutes, not even a single missing cursor or freeze. It just kept going non-stop. Could it be a hardware issue on your machine? A bug that only affects yours?

The vanilla Emacs didn't run anywhere near as well as this one does for me. I will keep my eye on it though.

@ghost
Copy link

ghost commented Dec 15, 2016

@d12frosted
Maybe try this:

  ;; GUI Settings for YAMAMOTO Mitsuharu's Mac port of GNU Emacs.
  ;; https://github.com/railwaycat/homebrew-emacsmacport
  (when (and (spacemacs/system-is-mac) (display-graphic-p))
    ;; Disable pixel-by-pixel scrolling, since it's extremely choppy.
    (setq mac-mouse-wheel-smooth-scroll nil))

See if that improves your C-n and C-p situation.

I run with it off because I hate how choppy and syrupy and stuttery it makes mousewheel scrolling (I suspect that hack is using an off-screen buffer which is rendering more lines of the document than just what's on-screen, and then constantly refreshing that buffer every time you scroll a pixel.

Perhaps having it on is choppy for keyboard too. It may be affecting the entire rendering of the text-pane, "just in case" the user wants to scroll with the mouse suddenly.

@d12frosted
Copy link
Owner

It's the same with mac-mouse-wheel-smooth-scroll set to nil and set to t.

@ghost
Copy link

ghost commented Dec 15, 2016

@d12frosted Hmm okay. That's weird.

I've now spent all day coding in emacs-mac. Not a single crash or slowdown yet. Even the small "stutters" I used to get when using the space-menu are gone.

With emacs (the vanilla one via your emacs-plus formula) which I've used for the prior 9 days, I had about one total hang every 1-2 hours with the menus sometimes making Emacs use 100% CPU and not being rescuable with Ctrl-g. All of that was fixed when I changed to Yamamoto's enhanced Mac fork.

Before that, I just assumed that Emacs was a buggy, crashy editor due to all the Spacemacs packages. But now it's stable as hell after I switched Emacs port.

That really shows how different experiences can be. I have no idea why this one works worse for you but much better for me. Very weird.

I am using the latest emacs-mac plus this exact dotfile:
https://github.com/SteveJobzniak/spacemaxed/blob/master/spacemaxed/docs/01_INSTALL.org#spacemaxed

You are maintaining the official brew recipe for Spacemacs and may want to research this further for the sake of users, since I noticed people in the chat asking how to stop Spacemacs from freezing. Maybe they are Mac users with the official Emacs too.

If you are ever curious to see if my config fixes it, then you can hide your own .spacemacs.d folder, and follow those clone and port install instructions above (ignore my external utilities of course) to see if your machine's results have something to do with your config file.

I wouldn't think our physical hardware has any effect on this, so I bet it's the config or the source code size you are looking at.

@ninrod
Copy link

ninrod commented Dec 15, 2016

@SteveJobzniak I build emacs from source (git HEAD) and I never experience a hang. it's my main editor for everything except java.

@fuxialexander
Copy link

@d12frosted @SteveJobzniak I've tried both emacs vanilla and emacs-mac. The problem of emacs-mac for me is: when you use the native fullscreen on mac and you want to switch using touchpad between different fullscreen apps, say, emacs-mac and safari, there is a significant lag. Vanilla Emacs do not have that problem.

@bassu
Copy link

bassu commented Jan 12, 2017

@SteveJobzniak You're right. The default smooth scrolling in @railwaycat's emacs-mac port is really choppy. I am not sure why others find it pleasing. Your tweaks returned back the sanity without having me go through gazillion lines of scroll documentation. 👍

@ghost
Copy link

ghost commented Jan 12, 2017

@ninrod I have now used railwaycat's Emacs for a month and have zero hangs. I haven't tried regular Emacs HEAD, maybe that would also have solved the hangs I was having.

@fuxialexander Yes railwaycat uses native fullscreen which has an entry/exit animation and disables all input (Apple does) while it animates. But I never use fullscreen.

@bassu Yeah it blows my mind why anyone likes the choppy default pixel-scrolling mess in railwaycat, but it's probably because they used regular Emacs scroll before that which scrolls way too fast. Hence why I simply tweaked that regular scrolling to jump less lines at a time, and now it feels great. Glad my tweaks helped you! :-)

@d12frosted
Copy link
Owner

Ok, I have played with emacs-mac-port for a while and still think that it doesn't fit my needs. Mostly because it solves issues that I personally don't care about while adding some strange input lags and freezes, adding some strange issues with server (it's not reliable anymore) and forces me to change how I launch emacs (not a simple emacs in the terminal anymore). This is not objective, I know. Rest assured that it doesn't affect my view on the subject, it just affects my tool set 😸

What I am going to do is to update Spacemacs installation guide for macOS users with a note about emacs-mac-port. Some people might find it more pleasant. I would be really happy if people experiencing issues with GNU Emacs could solve them either by someone fixing bugs in GNU Emacs or just switching to Emacs Mac Port.

Thanks everyone for a good discussion on this topic. I really appreciate your effort. And thanks for the hints about scrolling (for some reasons I like line-by-line scrolling even if I use touchpad 😸 ).

To be honest I am not sure if there is a point in having emacs-mac-port-plus formulae as the features provided by emacs-plus are either available in emacs-mac-port (e. g. Spacemacs icon) or don't make much sense with mac port version (e. g. -x11 option). Since emacs-mac-port formulae authors are more open to new features I'd rather contribute directory to them new features (like 'borderless support').

Just as a history notice, emacs-plus was created simply because I wanted to provide Spacemacs users ability to install GNU Emacs with Spacemacs icon (despite the fact that I don't use it 😸 ). Homebrew maintainers are agains such additions to emacs formulae so I had to create my own tap. The name emacs-plus was chosen intentionally (it has several purposes) and as it turned out, it's a good name. Recently hombrew maintainers made emacs formula 'obsolete' as they now promote cask version (installed via brew cask install emacs) over regular (installed via brew install emacs). Then they throw away X support. That's not a great list of 'features', but anyways 😸

So as you can see, emacs-plus is about GNU Emacs. In case it get's something useful for mac port, I'll try to contribute to that project as well.

That being said, I am closing this issue. Thanks again everyone for the input and feel free to continue your discussion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants