* bug#27645: MacOS: run GUI Emacs without 'make install' @ 2017-07-10 19:06 Charles A. Roelli 2017-07-10 19:12 ` Charles A. Roelli 0 siblings, 1 reply; 9+ messages in thread From: Charles A. Roelli @ 2017-07-10 19:06 UTC (permalink / raw) To: 27645 Currently, when building Emacs for MacOS, you have to run 'make install' before you can run the GUI version, which needs to be running inside an Apple "bundle" (which includes a configuration file, "Info.plist"). If you try to run 'src/emacs -q' directly after 'make', you get an Emacs frame with no menu or dock icon, and the frame does not take any keyboard input. This is fixed by changing the "activation policy" of Emacs at runtime. The following snippet from /System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSRunningApplication.h: has more details: /* The following activation policies control whether and how an application may be activated. They are determined by the Info.plist. */ enum { /* The application is an ordinary app that appears in the Dock and may have a user interface. This is the default for bundled apps, unless overridden in the Info.plist. */ NSApplicationActivationPolicyRegular, /* The application does not appear in the Dock and does not have a menu bar, but it may be activated programmatically or by clicking on one of its windows. This corresponds to LSUIElement=1 in the Info.plist. */ NSApplicationActivationPolicyAccessory, /* The application does not appear in the Dock and may not create windows or be activated. This corresponds to LSBackgroundOnly=1 in the Info.plist. This is also the default for unbundled executables that do not have Info.plists. */ NSApplicationActivationPolicyProhibited }; typedef NSInteger NSApplicationActivationPolicy; So when we call 'src/emacs -q' directly, Emacs should change activation policy to NSApplicationActivationPolicyRegular. The patch in the next message implements this. Normally the Info.plist file inside the application's bundle takes care of setting this policy, but when we run Emacs outside of the bundle, that won't happen. This change also makes it easier to run Emacs inside GDB in MacOS, since there's no need to run 'make install' and give GDB the bundled executable's name -- it's now done as on GNU/Linux. Some things still to consider: - Is this necessary/feasible on GNUstep? - Does this work on the X11 port in macOS? (I don't have a build ATM.) ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-10 19:06 bug#27645: MacOS: run GUI Emacs without 'make install' Charles A. Roelli @ 2017-07-10 19:12 ` Charles A. Roelli 2017-07-12 18:52 ` Alan Third 0 siblings, 1 reply; 9+ messages in thread From: Charles A. Roelli @ 2017-07-10 19:12 UTC (permalink / raw) To: 27645 [-- Attachment #1: Type: text/plain, Size: 130 bytes --] The patch is attached. Also, maybe there is a better way to find the file name of the icon to use (without hardcoding the name). [-- Attachment #2: 0001-Enable-GUI-Emacs-without-make-install-on-macOS-Bug-2.patch --] [-- Type: text/x-patch, Size: 2449 bytes --] From 3cc9491d301be0030b9a4c85bb2cfa0507f7e243 Mon Sep 17 00:00:00 2001 From: Charles A. Roelli <charles@aurox.ch> Date: Mon, 10 Jul 2017 21:08:14 +0200 Subject: [PATCH] Enable GUI Emacs without 'make install' on macOS (Bug #27645) * nextstep/INSTALL: Correct it, and mention that Emacs can be run from 'src/emacs'. * src/nsterm.m (applicationDidFinishLaunching:): When Emacs is launched outside of a macOS application bundle, change its activation policy from the default 'prohibited' to 'regular'. ; * etc/NEWS: Mention the change on macOS. --- etc/NEWS | 3 +++ nextstep/INSTALL | 11 ++++++----- src/nsterm.m | 11 +++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a00760c..e1e6e15 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1516,6 +1516,9 @@ debugger has been attached to it. ** 'set-mouse-position' and 'set-mouse-absolute-pixel-position' work on macOS. +** Emacs can now be run as a GUI application from the command line on +macOS. + \f ---------------------------------------------------------------------- This file is part of GNU Emacs. diff --git a/nextstep/INSTALL b/nextstep/INSTALL index 799cd4d..9579987 100644 --- a/nextstep/INSTALL +++ b/nextstep/INSTALL @@ -17,14 +17,15 @@ Compilation In the top-level directory, use: - ./configure --with-ns + make -(On macOS, --with-ns is enabled by default.) +This will compile all the files. -This will compile all the files, but emacs will not be able to be run except -in -nw (terminal) mode. +In order to run Emacs, you must run: -In order to run Emacs.app, you must run: + src/emacs + +In order to install Emacs, you must run: make install diff --git a/src/nsterm.m b/src/nsterm.m index bf83550..c965e25 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5479,6 +5479,17 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification object:nil]; #endif + if ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited) { + /* Set the app's activation policy to regular when we run outside + of a bundle. This is already done for us by Info.plist when we + run inside a bundle. */ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp setApplicationIconImage: + [EmacsImage + allocInitFromFile: + build_string("icons/hicolor/128x128/apps/emacs.png")]]; + } + ns_send_appdefined (-2); } -- 1.7.4.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-10 19:12 ` Charles A. Roelli @ 2017-07-12 18:52 ` Alan Third 2017-07-12 22:24 ` Jean-Christophe Helary 2017-07-15 14:58 ` Charles A. Roelli 0 siblings, 2 replies; 9+ messages in thread From: Alan Third @ 2017-07-12 18:52 UTC (permalink / raw) To: Charles A. Roelli; +Cc: 27645 On Mon, Jul 10, 2017 at 09:12:14PM +0200, Charles A. Roelli wrote: > The patch is attached. I haven’t had a chance to test this, but it looks good, thanks for working on it. > In the top-level directory, use: > > - ./configure --with-ns > + make > > -(On macOS, --with-ns is enabled by default.) > +This will compile all the files. I understand that running make also runs configure, but I think it’s worth leaving configure and the stuff about --with-ns in there. If you try to build the NS port on anything other than macOS then you really need to know about --with-ns. > -This will compile all the files, but emacs will not be able to be run except > -in -nw (terminal) mode. > +In order to run Emacs, you must run: > > -In order to run Emacs.app, you must run: > + src/emacs > + > +In order to install Emacs, you must run: > > make install I read this as it’s going to install Emacs somewhere on my PC, it should probably be something like: ‘To build Emacs.app ...’. -- Alan Third ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-12 18:52 ` Alan Third @ 2017-07-12 22:24 ` Jean-Christophe Helary 2017-07-15 14:58 ` Charles A. Roelli 1 sibling, 0 replies; 9+ messages in thread From: Jean-Christophe Helary @ 2017-07-12 22:24 UTC (permalink / raw) To: Alan Third; +Cc: 27645, Charles A. Roelli > On Jul 13, 2017, at 3:52, Alan Third <alan@idiocy.org> wrote: > >> +In order to install Emacs, you must run: >> >> make install > > I read this as it’s going to install Emacs somewhere on my PC, it > should probably be something like: ‘To build Emacs.app ...’. Indeed, since it only puts Emacs.app in the default location which is not standard for a macOS installation. Jean-Christophe ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-12 18:52 ` Alan Third 2017-07-12 22:24 ` Jean-Christophe Helary @ 2017-07-15 14:58 ` Charles A. Roelli 2017-07-20 18:58 ` Charles A. Roelli 1 sibling, 1 reply; 9+ messages in thread From: Charles A. Roelli @ 2017-07-15 14:58 UTC (permalink / raw) To: Alan Third; +Cc: 27645, jean.christophe.helary [-- Attachment #1: Type: text/plain, Size: 1360 bytes --] On 12/07/2017 20:52, Alan Third wrote: > On Mon, Jul 10, 2017 at 09:12:14PM +0200, Charles A. Roelli wrote: >> The patch is attached. > I haven’t had a chance to test this, but it looks good, thanks for > working on it. > >> In the top-level directory, use: >> >> - ./configure --with-ns >> + make >> >> -(On macOS, --with-ns is enabled by default.) >> +This will compile all the files. > I understand that running make also runs configure, but I think it’s > worth leaving configure and the stuff about --with-ns in there. If you > try to build the NS port on anything other than macOS then you really > need to know about --with-ns. Thanks, I've put it back. > >> -This will compile all the files, but emacs will not be able to be run except >> -in -nw (terminal) mode. >> +In order to run Emacs, you must run: >> >> -In order to run Emacs.app, you must run: >> + src/emacs >> + >> +In order to install Emacs, you must run: >> >> make install > I read this as it’s going to install Emacs somewhere on my PC, it > should probably be something like: ‘To build Emacs.app ...’. > It may install it (with --disable-ns-self-contained). I've clarified this (hopefully). I've also placed the nsterm.m change inside #ifdef NS_IMPL_COCOA, since the activationPolicy doesn't seem to exist on GNUstep. See the updated patch again. [-- Attachment #2: 0001-Enable-GUI-Emacs-without-make-install-on-macOS-Bug-2.patch --] [-- Type: text/x-patch, Size: 3872 bytes --] From 37abf2a8e9a30377a2e064f111d546ec083c3363 Mon Sep 17 00:00:00 2001 From: Charles A. Roelli <charles@aurox.ch> Date: Mon, 10 Jul 2017 21:08:14 +0200 Subject: [PATCH v2] Enable GUI Emacs without 'make install' on macOS (Bug #27645) * nextstep/INSTALL: Correct it, and mention that Emacs can be run from 'src/emacs'. * src/nsterm.m (applicationDidFinishLaunching:): When Emacs is launched outside of a macOS application bundle, change its activation policy from the default 'prohibited' to 'regular'. ; * etc/NEWS: Mention the change on macOS. --- etc/NEWS | 3 +++ nextstep/INSTALL | 16 ++++++++++++---- src/nsterm.m | 13 +++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index edb7111..36cb80b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1544,16 +1544,19 @@ execution and return control to the debugger. If no debugger is attached to the receiving process, the call is typically ignored. This is in contrast to the default action on POSIX Systems, where it causes the receiving process to terminate with a core dump if no debugger has been attached to it. ** 'set-mouse-position' and 'set-mouse-absolute-pixel-position' work on macOS. +** Emacs can now be run as a GUI application from the command line on +macOS. + \f ---------------------------------------------------------------------- This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/nextstep/INSTALL b/nextstep/INSTALL index 799cd4d..b7e84e0 100644 --- a/nextstep/INSTALL +++ b/nextstep/INSTALL @@ -16,25 +16,33 @@ Compilation ----------- In the top-level directory, use: ./configure --with-ns (On macOS, --with-ns is enabled by default.) -This will compile all the files, but emacs will not be able to be run except -in -nw (terminal) mode. +Then run: -In order to run Emacs.app, you must run: + make + +This will compile all the files. + +In order to run Emacs, you must run: + + src/emacs + +In order to install Emacs, you must run: make install This will assemble the app in nextstep/Emacs.app (i.e., the --prefix -argument has no effect in this case). +argument has no effect in this case). You can then move the Emacs.app +bundle to a location of your choice. If you pass the --disable-ns-self-contained option to configure, the lisp files will be installed under whatever 'prefix' is set to (defaults to /usr/local). The bundle will be smaller, but depend on these resources (may require 'sudo' for "make install"). Installation diff --git a/src/nsterm.m b/src/nsterm.m index bf83550..7834bac 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5474,16 +5474,29 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification #ifdef NS_IMPL_COCOA [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(antialiasThresholdDidChange:) name:NSAntialiasThresholdChangedNotification object:nil]; #endif +#ifdef NS_IMPL_COCOA + if ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited) { + /* Set the app's activation policy to regular when we run outside + of a bundle. This is already done for us by Info.plist when we + run inside a bundle. */ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp setApplicationIconImage: + [EmacsImage + allocInitFromFile: + build_string("icons/hicolor/128x128/apps/emacs.png")]]; + } +#endif + ns_send_appdefined (-2); } - (void)antialiasThresholdDidChange:(NSNotification *)notification { #ifdef NS_IMPL_COCOA macfont_update_antialias_threshold (); #endif -- 1.7.4.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-15 14:58 ` Charles A. Roelli @ 2017-07-20 18:58 ` Charles A. Roelli 2017-07-20 20:34 ` Alan Third 0 siblings, 1 reply; 9+ messages in thread From: Charles A. Roelli @ 2017-07-20 18:58 UTC (permalink / raw) To: Alan Third; +Cc: 27645, jean.christophe.helary I'll push this in a few days if there's no further changes to make. On 15/07/2017 16:58, Charles A. Roelli wrote: > On 12/07/2017 20:52, Alan Third wrote: > >> On Mon, Jul 10, 2017 at 09:12:14PM +0200, Charles A. Roelli wrote: >>> The patch is attached. >> I haven’t had a chance to test this, but it looks good, thanks for >> working on it. >> >>> In the top-level directory, use: >>> - ./configure --with-ns >>> + make >>> -(On macOS, --with-ns is enabled by default.) >>> +This will compile all the files. >> I understand that running make also runs configure, but I think it’s >> worth leaving configure and the stuff about --with-ns in there. If you >> try to build the NS port on anything other than macOS then you really >> need to know about --with-ns. > > Thanks, I've put it back. > >> >>> -This will compile all the files, but emacs will not be able to be >>> run except >>> -in -nw (terminal) mode. >>> +In order to run Emacs, you must run: >>> -In order to run Emacs.app, you must run: >>> + src/emacs >>> + >>> +In order to install Emacs, you must run: >>> make install >> I read this as it’s going to install Emacs somewhere on my PC, it >> should probably be something like: ‘To build Emacs.app ...’. >> > > It may install it (with --disable-ns-self-contained). I've clarified > this (hopefully). > > I've also placed the nsterm.m change inside #ifdef NS_IMPL_COCOA, > since the > activationPolicy doesn't seem to exist on GNUstep. > > See the updated patch again. ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-20 18:58 ` Charles A. Roelli @ 2017-07-20 20:34 ` Alan Third 2017-07-23 15:02 ` Charles A. Roelli 0 siblings, 1 reply; 9+ messages in thread From: Alan Third @ 2017-07-20 20:34 UTC (permalink / raw) To: Charles A. Roelli; +Cc: 27645, jean.christophe.helary On Thu, Jul 20, 2017 at 08:58:06PM +0200, Charles A. Roelli wrote: > I'll push this in a few days if there's no further changes to make. Looks good to me. Thanks. -- Alan Third ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-20 20:34 ` Alan Third @ 2017-07-23 15:02 ` Charles A. Roelli 2017-07-24 18:24 ` Charles A. Roelli 0 siblings, 1 reply; 9+ messages in thread From: Charles A. Roelli @ 2017-07-23 15:02 UTC (permalink / raw) To: Alan Third; +Cc: jean.christophe.helary, 27645-done Great! Pushed as: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2c87aab57946b95d67b664259f30e64468d08544 On 20/07/2017 22:34, Alan Third wrote: > On Thu, Jul 20, 2017 at 08:58:06PM +0200, Charles A. Roelli wrote: >> I'll push this in a few days if there's no further changes to make. > Looks good to me. Thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#27645: MacOS: run GUI Emacs without 'make install' 2017-07-23 15:02 ` Charles A. Roelli @ 2017-07-24 18:24 ` Charles A. Roelli 0 siblings, 0 replies; 9+ messages in thread From: Charles A. Roelli @ 2017-07-24 18:24 UTC (permalink / raw) To: Alan Third; +Cc: 27645, jean.christophe.helary I've just realized that after 'make' on OS X you get this message: You must run "make install" in order to test the built application. The installed application will go to nextstep/Emacs.app and can be run or moved from there. The application will be fully self-contained. I suggest to replace it with this: Run "make" to build Emacs, then run "src/emacs" to test it. To build a self-contained application bundle, run "make install". The installed application will go to nextstep/Emacs.app and can be run or moved from there. Any thoughts? On 23/07/2017 17:02, Charles A. Roelli wrote: > Great! Pushed as: > > http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2c87aab57946b95d67b664259f30e64468d08544 > > > > On 20/07/2017 22:34, Alan Third wrote: >> On Thu, Jul 20, 2017 at 08:58:06PM +0200, Charles A. Roelli wrote: >>> I'll push this in a few days if there's no further changes to make. >> Looks good to me. Thanks. > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-07-24 18:24 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-10 19:06 bug#27645: MacOS: run GUI Emacs without 'make install' Charles A. Roelli 2017-07-10 19:12 ` Charles A. Roelli 2017-07-12 18:52 ` Alan Third 2017-07-12 22:24 ` Jean-Christophe Helary 2017-07-15 14:58 ` Charles A. Roelli 2017-07-20 18:58 ` Charles A. Roelli 2017-07-20 20:34 ` Alan Third 2017-07-23 15:02 ` Charles A. Roelli 2017-07-24 18:24 ` Charles A. Roelli
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.