Closed karrot42 closed 5 years ago
1. How do I make this change permanent and consistent even after I restart yabai so I don't have to run the command every time
Just put the rule in your yabairc—it's just an executable shell script after all.
2. Although the Emacs window tiles, it when I navigate around the open windows (alt - h, alt - l) the Emacs window won't get selected, I must use the mouse to highlight it.
Assuming you installed via brew, do you have anything possibly relevant in your log files when doing this? stderr gets redirected to /usr/local/var/log/yabai/yabai.err.log
(and similarly replace err with out for stdout). You can monitor this file using tail -f /usr/local/var/log/yabai/yabai.err.log
.
An alternative would be to run yabai --verbose
instead of the brew service to get a more detailed output, which should print why your windows cannot be selected.
Emacs has always been an issue, sadly.
Emacs has always been an issue, sadly.
Try using emacs-mac from the tap emacsmacport.
It has much more better GUI support than the original, and a few additional features you might appreciate.
All this is due to GNU Emacs's main role being an AXTextField instead of AXWindow mentioned https://github.com/koekeishiya/chunkwm/issues/105#issuecomment-312619814. :-(
Sent with GitHawk
Does Emacs not provide a good CLI alternative to its GUI version?
Assuming you installed via brew, do you have anything possibly relevant in your log files when doing this? stderr gets redirected to
/usr/local/var/log/yabai/yabai.err.log
(and similarly replace err with out for stdout). You can monitor this file usingtail -f /usr/local/var/log/yabai/yabai.err.log
.An alternative would be to run
yabai --verbose
instead of the brew service to get a more detailed output, which should print why your windows cannot be selected.
There was no log file in /usr/local/var/log/yabai/
and the --verbose didn't show anything unusual that I could notice
Try using emacs-mac from the tap emacsmacport.
It has much more better GUI support than the original, and a few additional features you might appreciate.
this will probably be my solution especially because there have always been some glitchiness with my emacs install with window resizing and what not, I'll give a try tomorrow.
Does Emacs not provide a good CLI alternative to its GUI version?
It has a CLI alternative but I think it lacks things like following links to open files and URLs in orgmode files, which I use pretty heavily. I could be wrong about that though because I've only used CLI on a headless server in a pinch.
@karrot42 I'm using emacs-mac and still have the same problem. The simple fix is to add
(menu-bar-mode t)
to configuration file. Hope it help!
Closing this then.
I added this information to the tips and tricks section of the wiki: https://github.com/koekeishiya/yabai/wiki/Tips-and-tricks#tiling-emacs
I have not tested whether this works as I don't use Emacs myself, but maybe this will help some real programmers (xkcd).
I'm using emacs-mac with menu-bar-mode on. Yabai mostly works, but if I try to do cmd+tab
to switch to emacs from another space, it moves emacs into the current space instead of switching. I haven't seen any other app do this.
On macOS I use an emacs config based on doom emacs with emacs-plus installed with these options:
brew install emacs-plus --with-no-titlebar --with-modern-icon --without-spacemacs-icon
and this has (menu-bar-mode t)
set
I use this rule to contain emacs windows: yabai -m rule --add app=Emacs manage=on space=2
With this setup emacs tiles just fine using yabai and seems well behaved.
@webframp your comment helped me tile emacs but I still can't get it to focus by using commands. I get could not locate a southward managed window.
although I set
yabai -m rule --add app=Emacs manage=on
Hi, I have been a user of chunkwm and Emacs tiled just as all other programs. Today I installed yabai because a macOS update bricked my chunkwm installation. And everything works as before except Emacs.
Now i have installed a version of emacs called emacs-plus, which has a --with-no-titlebar option that removes the window decoration. The option (menu-bar-mode t)
is stil set in emacs which means that what worked for everybody else have not worked for me.
I have also added a tiling rule for Emacs in .yabairc with no effect.
I digged a little bit and it seems like Emacs will tile when it is launched. It even reacts on resizing regardless which application is in focus. I can swap and move commands but only when Emacs is in focus, not when another application is in focus. The same applies for moving focus. I can use commands to move focus away from Emacs, but not to Emacs.
Below is my Emacs installation
brew tap d12frosted/emacs-plus
brew install emacs-plus --with-no-titlebar
@brorbw Quoting the wiki... (emphasis mine)
Emacs is not a well-behaved citizen of macOS. Try using → emacs-mac from the Homebrew tap → emacsmacport.
If Emacs is still not recognized by yabai, try enabling menu-bar-mode.
If you're using emacs-plus, you should set up a custom rule for it (which actually creates lots of problems relating to tooltips).
@brorbw can you provide any more info on your emacs config? I use emacs-plus as I mentioned and have no tiling issues with it. It may be worth trying emacs-mac just to eliminate the cause of the issue
I realise that my poor english skills might have come across as unfamiliarity with chunkwm. For that i apologise.
@pcr910303 I appreciate your answer but all of the above mentioned methods does not work for me. I like having the --with-no-titlebar
option and i have been using it for age with chunkwm and i have had no problem.
If Emacs is still not recognized by yabai, try enabling menu-bar-mode. The
(menu-bar-mode t)
options is set and makes no difference.
I will add that the official Homebrew install of emacs and emacs-plus does not work either.
If you're using emacs-plus, you should set up a custom rule for it (which actually creates lots of problems relating to tooltips). I had a custom rule for emacs before and i remember having a workaround for tooltips
@webframp My emacs config is almost the dev branch of spacemacs with some minor changes.
@pcr910303 I appreciate your answer but all of the above mentioned methods does not work for me. I like having the
--with-no-titlebar
option and i have been using it for age with chunkwm and i have had no problem. I had a custom rule for emacs before and i remember having a workaround for tooltips
Well, then I don't understand the question, why would you not add a custom rule for Emacs in your yabai init file?
I will add that the official Homebrew install of emacs and emacs-plus does not work either.
Yes, as said, the official emacs and emacs-plus don't work without custom rules.
Try something like this (this doesn't consider tooltips): have checked working on macOS 10.15 Catalina with Emacs built on master.
yabai -m rule --add label=emacs app=Emacs manage=on
Since emacs-plus
is mentioned here several times, let me share a special option that should fix the window role:
$ brew install emacs-plus --with-window-role-fix
It's in 'experimental' state. And if it works reliably, I will make it on by default. Using it for several days (with yabai) and can confirm that doesn't require any special rules.
Does it also work with the --no-title-bar
option?
Yes, it works with --with-no-titlebar
(please make sure that you use the right option 😸 ).
Yeah, I just wrote what was on the top of my head. Of course it's --woth-no-titlebar
.
Happy new year 🎉
@pcr910303
Well, then I don't understand the question, why would you not add a custom rule for Emacs in your yabai init file?
For completeness I will answer your question. I tried adding a custom rule for emacs-plus but it simply wouldn't work hence why I kept asking.
That option was merged and is not required anymore. Have fun :)
That option was merged and is not required anymore. Have fun :)
Was it recently merged? Yesterday I still had to add it for brew install.
@picaschaf it was merged just minutes before I posted about it here. Here is relevant commit: https://github.com/d12frosted/homebrew-emacs-plus/commit/0017af1e7710ff833dfb2c061fe56660207ad0b7
I know this is closed, but I still have this issue. I installed the Emacs plus from @d12frosted above, and have the rule, yabai -m rule --add label=emacs app=Emacs manage=on
. However, I yabai -m window --focus [direction]
skips over Emacs as if it wasn't there. Thankfully, it is tiling, however.
I do not have lable=emacs
in my rule and it works fine. Could it be the flavour of emacs? I have installed emacs-plus
That is the same Emacs I am using.
I installed the Emacs plus from @d12frosted above
@TomFaulkner I also use emacs-plus
and I don't have any special rules for Emacs. And still it works well with --focus
commands. AFAIR, it works regardless of Emacs version, but just for the sake of completeness, I am using Emacs 28. This is how I got my version:
$ brew install emacs-plus --without-spacemacs-icon --with-jansson --HEAD
I was on 26.3, then tried 28 with the --HEAD
option, but it couldn't read the Spacemacs (up-to-date develop branch) init.el
file for some reason. 27 works and Yabai treats it like other windows now. Thanks for the help.
I installed emacs-plus --with-no-titlebar
, 27, 28, 29 versions, but it still didn't want to tile.
What I found is that when I remove some package's initialization from the .emacs
it tiles, but not every time.
And what worked every time is when I restart the yabai service after starting Emacs. This way it always tiles.
I've also started using emacs recently, and even with proper accessibility attributes on the window tiling sometimes fails. From a brief investigation this is what happens:
kAXErrorCannotComplete
This is mainly caused by the fact the Emacs actually takes a while to properly startup and properly responding to ax requests. The fix in my case is changing the value here https://github.com/koekeishiya/yabai/blob/4848ec028b60c29f3edb869f07e9e78834f3733a/src/window_manager.c#L1623
@koekeishiya I think it would be worth to make that value a little higher or at least configurable, I've seen the same failure described above for other apps like Safari, especially when the system is under load.
@choco nice catch. Most likely what's happening with me. It explains also why emacs -Q
(skip config, starts in a flash) always get tiled.
@choco Just a regression in the changes that were made on the-future branch. Should be back to working as before on the master branch now.
A lot of the suggestions here will cause problems. For anyone confused, you should not use rules. All you need is to use emacs-plus or apply its fix-window-role patch.
Here is a more detailed summary of what currently works to get Emacs tiled correctly without messing up e.g. completion popups:
open -a Emacs --args --daemon
first or the windows created with emacsclient won't be managed/tiledmanage=on
rules related to Emacs; Emacs.app will already be managed correctly by default, and if you add a manage rule, it will tile child frames (e.g. completion popups); maybe you can use title exclusions to get things working correctly in all cases, but this is unnecessarily complicated (it's not as simple as ignoring empty titles as suggested in #587)yabai -m config window_topmost on
; leave it as the default (off) (or completion popups can appear behind Emacs - #1657)@noctuid can I ask, to which emacs version in nixpkgs are you applying the patches to?
I've tried applying the same patches from emacs-plus to get this to work with emacs29 emacs29-pgtk (fails to build) and emacs29-gtk3 but they dont tile correctly, or only tile when the titlebar is enabled, while the version from emacs-plus works without just fine :/
@saucoide I'm using emacs@29
installed with
brew install emacs-plus@29 --with-no-titlebar --with-native-comp
Removing all rules for emacs. That works great. Sometimes when I reboot and emacs opens before yabai loads it wont tile. In that case I have to toggle tiling for the emacs window and then it works.
@saucoide I'm using emacs-git from emacs-overlay. See here.
Why are you trying to use pgtk or gtk on mac? I would not try to use pgtk unless on Wayland or WSL with Wayland.
@noctuid thanks! I wasnt planing on using pgtk, but since the standard one was not working I wanted to try if different ones would behave differently, but thanks will try with that one :)
@brorbw thanks, yes the brew version also works for me, but i've switched everything to nix and emacs is the last straggler that's why i asked noctiud since he mentioned he uses nix as well
update: I'm giving up on getting emacs/yabai to work via nix, will just use the emacs-plus versions which works fine for me, nix + patches i can only get it to tile if i launch it with open -a Emacs
+ showing the title bar, the moment i modify the 'default-frame-alist
to make it undecorated, it doesn't tile anymore, plus M-x is switched between the option & command keys vs the homebrew version with the same emacs config. Anyway thanks everyone for the help at least i learned something
Yeah, I found undecorated-round
to be too buggy with yabai (for other reasons I think, but I can't remember) and ended up removing the setting from my early-init. You don't have any issues with it in emacs-plus?
The other issue is probably solvable by just explicitly setting mac-command-modifier
and mac-option-modifier
.
yes, with emacs-plus i dont have any issues, everything works mostly, sometimes if i run emacsclient -c -a ''
from keybinding it won't tile, but it's rare and most times it does tile correctly, so i don't worry about it. Could be that it's a race between removing the decoration and naming the frame or something, but for now i'm ok with leaving emacs on homebrew
I take back what I said about undecorated-round. I've been using it for months without issue. Not sure what your setup is, but I don't have any issues with skhd.
I recently switched from "regular" brew emacs to https://github.com/railwaycat/homebrew-emacsmacport.
Using spacemacs, tiling would not work until I changed the following line in .spacemacs
:
;; dotspacemacs-maximized-at-startup t
dotspacemacs-maximized-at-startup nil
To check whether spacemacs is the problem, you can break your .spacemacs with a syntax error (or maybe rename it? didn't try).
Broken .spacemacs will open in recovery mode which looks like:
Try tiling this window. For me it worked, which pointed to spacemacs as the issue.
From a straight install Emacs won't tile with the rest of the windows, so I figured out that if I run
'yabai -m rule --add app=Emacs manage=on' after starting emacs it will tile with the other windows but I have 2 problems