Homebrew-emacs-plus: Borderless feature

Created on 14 Jan 2017  路  31Comments  路  Source: d12frosted/homebrew-emacs-plus

I've applied the patch in the borderlass branch:

$ brew install --HEAD ./emacs-plus.rb                                                                                                                                           聽顐猜狀偁聽master
==> Cloning https://github.com/emacs-mirror/emacs.git
Updating /Users/krisz/Library/Caches/Homebrew/emacs-plus--git
==> Checking out branch master
==> Downloading https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-10/binh950gCIBLY.bin
Already downloaded: /Users/krisz/Library/Caches/Homebrew/emacs-plus--patch-184301d28dabab5e2115cfd3c4875b89b408c31845ef04f909a6e0710523f082.bin
==> Patching
==> Applying binh950gCIBLY.bin
patching file lisp/cus-start.el
Hunk #1 succeeded at 448 (offset 2 lines).
patching file src/nsterm.m
Hunk #1 succeeded at 6748 (offset -27 lines).
Hunk #2 succeeded at 6787 (offset -27 lines).
Hunk #3 succeeded at 6809 (offset -27 lines).
Hunk #4 succeeded at 8736 with fuzz 1 (offset -27 lines).
==> ./autogen.sh
==> ./configure --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs-plus/HEAD-877c525/share/info/emacs --prefix=/usr/local/Cellar/emacs-plus/HEAD-877c525 --with-xml2 --without-d
==> make
==> make install
...

but there is no ns-use-titled-windows variable in Emacs.

Could You give me some hints to achieve borderless frame?

I've found another patch which conflicts with emacs' source http://stackoverflow.com/questions/24021624/in-gnu-emacs-osx-how-to-hide-title-bar .

question

Most helpful comment

@braham-snyder: (setq frame-resize-pixelwise t) solves this issue.

All 31 comments

I have created that branch to share the work on this feature, but I couldn't make it working, that's why it's still not in master branch. The patch I have applied is taken from this thread.

Wow, thanks for the link. I'll try it. But in case you wish to bring this patch faster, I highly advice you to test it on your own and send me a PR. This would be very nice and helpful as I am not going to look into it for several weeks.

I've pull requested a branch using the patch I modified (I wrote that StackOverflow post). Want to test it @kszucs?

Note that it doesn't currently work on HEAD (if I recall correctly, one hunk failed, and one was fuzzed--I didn't look further into it).

e: Also, I've changed the variable name to ns-use-title-bar in accordance with requests to change the original patch (by Jay McCarthy) in that gnu.org thread.

Great! I'm testing now.

(setq ns-use-title-bar nil) right? It doesn't seem to work with --devel

$ brew install --devel --with-borderless-variable Formula/emacs-plus.rb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

==> Downloading http://alpha.gnu.org/gnu/emacs/pretest/emacs-25.1.90.tar.xz
######################################################################## 100.0%
==> Downloading https://gitlab.com/brds/GNU-Emacs-OS-X-no-title-bar/raw/master/GNU-Emacs-25.1-OS-X-no-title-bar.patch
######################################################################## 100.0%
==> Patching
==> Applying GNU-Emacs-25.1-OS-X-no-title-bar.patch
patching file lisp/cus-start.el
patching file src/nsterm.m
Hunk #1 succeeded at 6831 (offset 56 lines).
Hunk #2 succeeded at 6870 (offset 56 lines).
Hunk #3 succeeded at 6892 (offset 56 lines).
Hunk #4 succeeded at 8761 with fuzz 1 (offset -2 lines).
==> ./configure --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Ce
==> make
==> make install
######################################################################## 100.0%
==> Caveats
To have launchd start emacs-plus now and restart at login:
  brew services start emacs-plus
Or, if you don't want/need a background service you can just run:
  emacs

WARNING: brew services will fail when run under tmux.

.app bundles were installed.
Run `brew linkapps emacs-plus` to symlink these to /Applications.
==> Summary
馃嵑  /usr/local/Cellar/emacs-plus/25.1.90: 4,051 files, 120.5M, built in 2 minutes 20 seconds

I'm trying with bottle.

Same results with the bottle version. I can set the variable, but no effects. I've placed the setq nil in my .spacemacs and tried with M-x set-variable to nil too.

Sorry, I wouldn't expect it to be compatible with --devel either; I'll throw an error there too.

I'm on Sierra 10.12.2

I'm on El Capitan, and can't test on Sierra--I suppose it's possible it won't work on Sierra (but I have no idea).

Same results with the bottle version. I can set the variable, but no effects. I've placed the setq nil in my .spacemacs and tried with M-x set-variable to nil too.

Even after setting ns-use-title-bar to nil, creating a second frame creates a frame retaining the title bar? If (setq ns-use-title-bar nil) is in your user-config, it won't set the variable early enough to affect the first frame--you'd have to either put that into user-init or save it using custom. (EDIT: The custom setting isn't consistently working for me anymore. You may need to use setq in user-init.)

Doesn't it require 26.1?

I thought (perhaps mistakenly?) that that version string is only for the user--for, e.g., the variable's documentation:

This variable was introduced, or its default value was changed, in
version 26.1 of Emacs.

John McCarthy set it to 26.1 in the second revision of his patch after being told that the feature would not be introduced in version 25, so I just left it as-is since it worked for me (even with 25.1). Arguably it should be 25.1 here.

Same results with the bottle version.

It shouldn't be a bottle version (binary package) if I'm understanding homebrew correctly: brew uninstall Formula/emacs-plus.rb then brew install --with-borderless-variable Formula/emacs-plus.rb ought to build 25.1 (not devel nor HEAD) from source.

Hmmm... for it to work on the first frame, it looks like ns-use-title-bar needs to be set in user-init now, maybe? Originally, I had it default in the source to nil (i.e., do not use the title bar), but after changing the default to t for this pull request, my custom setting was being a little iffy.

Placing (setq ns-use-title-bar nil) into user-init, however, is still working for me.

Second frame works, first frame does not. I've placed under user-init.

In order to properly reinstall brew package you have to uninstall it and then install it again.

$ brew uninstall emacs-plus
$ brew install emacs-plus [options]

Using brew reinstall might not work if you switch between HEAD, devel or release versions. If you follow the logs after doing

$ brew install emacs-plus --HEAD
$ brew reinstall emacs-plus

You'll notice that brew installs HEAD version anyways during reinstall.

P. S. I might be wrong.

@kszucs

I think it should be a top-level expression in your .spacemacs file.

I set the value of ns-use-title-bar to nil at the very beginning of init.el and it doesn't work with the first frame. But the next created frame doesn't have title bar so that nice. I wonder why the first frame has it.

Looks like it was only working for me on the first frame since I exclusively start the daemon and then connect using client frames (i.e., I essentially only use emacsclient -n -c -a "")--if I just run emacs the first frame retains its title bar for me as well.

Though it's not ideal, I could just change the default value of ns-use-title-bar to nil. I don't plan on attempting a fix any more extensive than that myself (I'm not actually familiar with the code--I really only had to move a few lines around to update the patch--so I have no idea how long a robust fix would take).

Using brew reinstall might not work if you switch between HEAD, devel or release versions.

Tricky--and thanks, I've edited that bit.

Thanks for the patch. It's in master, so you can use it 馃樃 Would be really nice to make it working with head and devel version of Emacs.

Yeah, looks like the first emacs (not emacsclient) frame per session will always use ns-use-title-bar's default value, so I've just flipped the default to omit the title bar.

In more detail: I've just pushed an update to https://github.com/d12frosted/homebrew-emacs-plus/pull/14 that:

  • defaults ns-use-title-bar to nil, forcing every first, non-client frame per session to omit the title bar regardless of the value of ns-use-title-bar (instead of forcing the opposite);
  • notes the bug motivating this behavior in ns-use-title-bar's intra-emacs documentation1;
  • and throws an error upon the attempted combination of --with-no-title-bars (updated option name to reflect its new default effect) with either --HEAD or --devel.

Would be really nice to make it working with head and devel version of Emacs.

Actually, I was just assuming it didn't work on --devel from this thread, but it indeed does at the moment. Right now, it still didn't work on --HEAD, though it's possible the fix is trivial since only one hunk failed (and another was fuzzed by 1). That being said, I don't have the time to maintain compatibility with --HEAD, nor with --devel. We could change the error upon use with --HEAD or --devel to just a warning that they're unsupported for now. Or we could leave it as-is with the idea that adventurous users can always edit the formula themselves.

So as not to oversell --with-no-title-bars, I've not mentioned the variable itself (ns-use-title-bar) in brew's CLI documentation for the flag.

1 ns-use-title-bar's documentation:

Non-nil means to include the title bar on frames.  Nil means to
omit the title bar on OSX >= 10.7.  This variable is ignored on OSX <
10.7. Note that the first frame per emacs session (unless it is an
emacsclient) will use the default value of this variable (nil--do not
include a title bar), ignoring (!) the user-set value of this
variable. This is almost certainly due to a bug in the patch adding
this variable. Default is nil.

Hi!

Trying to install borderless with brew install emacs-plus --with-no-title-bars yields the following error during make:

==> make
Last 15 lines from /Users/GaborK/Library/Logs/Homebrew/emacs-plus/02.make:
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/fringe.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2  fringe.c
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/image.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2  image.c
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/nsterm.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   nsterm.m
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/nsfns.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   nsfns.m
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/nsmenu.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   nsmenu.m
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/nsselect.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   nsselect.m
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/nsimage.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   nsimage.m
clang -c  -Demacs  -I. -I. -I../lib -I../lib   -I/usr/X11/include   -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.28/include/libpng16 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.12.1_2/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/pixman/0.34.0/include/pixman-1 -I/usr/local/Cellar/pcre/8.39/include -I/usr/local/Cellar/glib/2.50.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.8/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.36.2/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.16_1/include/librsvg-2.0   -I/usr/include/libxml2           -MMD -MF deps/macfont.d -MP -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/p11-kit/0.23.5/include/p11-kit-1 -I/usr/local/Cellar/gnutls/3.5.10/include   -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes  -g3 -O2   macfont.m
nsterm.m:6840:36: error: use of undeclared identifier 'NSWindowStyleMaskBorderless'
                                   NSWindowStyleMaskBorderless) |
                                   ^
1 error generated.
make[1]: *** [nsterm.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [src] Error 2

Any idea what might be the issue here? I ran brew upgrade before a retry but that didn't help anything. I am on OSX El Capitan 10.11.6 (15G1217).

No sorry, I have no clue.

Did you figure out what was the problem?

not exactly... but i upgraded to Sierra and it works now. :)

in sierra 10.12.4 (16E195) it works well

Could someone post a screenshot of what this should look like? I think it doesn't work for me on Sierra, but maybe there's something I misunderstand.

@TheBaronHimself I've got a screenshot in my repo for the patch: https://github.com/braham-snyder/GNU-Emacs-OS-X-no-title-bar

Huh, okay. I just did another reinstall after trying it earlier today and it works now. How odd. Never mind my earlier comment.

This may be an unrelated question, but how does one remove the border on the right side and bottom of the Spacemacs window? I can't seem to get it to fit properly. I don't have that issue with other applications.
screen shot 2017-05-02 at 21 34 36

With kwm, the borderless patch is definitely giving me a smaller window given the same window-management "container", but my Emacs frames are still centered correctly within their containers, despite their edges not quite aligning flush with other application windows--that annoyed me a lot initially, but I'd mostly forgotten about it till now. I happen to use a desktop background color very similar to the color of my Spacemacs windows (though I do understand wanting contrast there instead), which likely makes it less noticeable.

Yeah, it's not a huge issue. I was just curious :). Thanks.

@braham-snyder: (setq frame-resize-pixelwise t) solves this issue.

The sha sum of the patch got misaligned. Also doesn't work with the current default 25.2

@braham-snyder is it an easy update to fix the SHA mismatch?

$ brew install emacs-plus --with-no-title-bars
...
Error: SHA256 mismatch
Expected: 51b9bbe4c731e7f5b391fdae98cf5c946b77e45b8dc25317cdd00e4180c72241
Actual: d098240657791aa1da9ed93f96a2168d11660db816e0253a63b8a5fac2f7d399
Archive: /Users/phil/Library/Caches/Homebrew/emacs-plus--patch-51b9bbe4c731e7f5b391fdae98cf5c946b77e45b8dc25317cdd00e4180c72241.patch

@philc @kszucs thanks for the heads-up--if you want a quick-fix before this is merged, you can just enter brew edit emacs-plus to automatically open the relevant file: https://github.com/d12frosted/homebrew-emacs-plus/pull/38

Awesome @braham-snyder, thank you for the quick fix!

@braham-snyder I have the same problem with the borderless feature. However I'm using HEAD and adding (undecorated . t) to the frame properties instead (which is the suggested way I think) I created an issue on chunkwm (similar to kvm) https://github.com/koekeishiya/chunkwm/issues/265

I tried the pixel wise ration that @TheBaronHimself suggested and that solves the transparent titlebar spacing I had before, but not the borderless one.

Does anyone of you know why this happens? (There are more screenshots in the issue I linked in this comment)

Emacs 26.1 is out. Closing this issue 馃樃

Let me know if you have any questions/problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonathanj picture jonathanj  路  3Comments

d12frosted picture d12frosted  路  8Comments

nwolfe picture nwolfe  路  6Comments

AbstProcDo picture AbstProcDo  路  3Comments

d12frosted picture d12frosted  路  6Comments