From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nick Helm Newsgroups: gmane.emacs.help Subject: Re: Mac: Don't quit Emacs when window is closed Date: Wed, 20 Jan 2016 11:04:30 +1300 Message-ID: References: <5870E7A7-DF82-484A-95BB-985DF8F419AF@luisgerhorst.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1453241118 6852 80.91.229.3 (19 Jan 2016 22:05:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Jan 2016 22:05:18 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Luis Gerhorst Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 19 23:05:11 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aLeOj-0006ch-9D for geh-help-gnu-emacs@m.gmane.org; Tue, 19 Jan 2016 23:05:09 +0100 Original-Received: from localhost ([::1]:39376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeOi-0001G8-7S for geh-help-gnu-emacs@m.gmane.org; Tue, 19 Jan 2016 17:05:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeOT-0001G2-Kn for help-gnu-emacs@gnu.org; Tue, 19 Jan 2016 17:04:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLeOO-0004Rg-Ek for help-gnu-emacs@gnu.org; Tue, 19 Jan 2016 17:04:53 -0500 Original-Received: from mail-pu1apc01on0123.outbound.protection.outlook.com ([104.47.126.123]:20633 helo=APC01-PU1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeON-0004RI-Lv for help-gnu-emacs@gnu.org; Tue, 19 Jan 2016 17:04:48 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=nick@tenpoint.co.nz; Original-Received: from nitrogen.local (125.239.120.90) by SY3PR01MB0282.ausprd01.prod.outlook.com (2a01:111:e400:5c05::26) with Microsoft SMTP Server (TLS) id 15.1.390.9; Tue, 19 Jan 2016 22:04:37 +0000 User-agent: mu4e 0.9.15; emacs 24.5.1 In-Reply-To: <5870E7A7-DF82-484A-95BB-985DF8F419AF@luisgerhorst.de> X-Originating-IP: [125.239.120.90] X-ClientProxiedBy: SY3PR01CA0023.ausprd01.prod.outlook.com (2a01:111:e400:5c00::33) To SY3PR01MB0282.ausprd01.prod.outlook.com (2a01:111:e400:5c05::26) X-Microsoft-Exchange-Diagnostics: 1; SY3PR01MB0282; 2:1pDnysgDhmhl1P3IDfnpERTKWsAwNY5br+IBbVhXLzu2732J6gWog43dzuwnxGmw/AMO5dINV70JgF3yUy9for6DHkl+qMAi3zEpwpCJLD3i9tBFF5ISZebYSxLVlliiSPmOpwyKwgeWGdqxyIh1+A==; 3:5GaFC48GaqgiksViNv3d93dTutVg6QgyRuO29D9rs8azeZK6TvAgm4Dhkn1zIoMDWJ9JM+pG5mwuQvW6psXI4GWoOJkeM8OxMtqESco+eVYHiBPgb0D96dQVI4S8A3+L; 25:yC/Sxgw+e7w64JPEDaMip2t6MnMUTCi4fqja3BT+ZjebUP1ABu0vqIZst3ciN0VLm9r8iOpBV0kkQvnqQLDH4yHMpHOd2OgHfHL2zL65mL8KU6vZZn5Ay39JIP/EmQuSK3bPMm57ohi+h3Sqy2Ml8mxXDsK8DXDDBCMpXr8Z6Wvcf8bXeN8wE0C+eeqCVqVY++cKWnn0Pn+GwXafFDh+mme65oOM++RmilRy7z1gbph/wTFSbbw6K/+kcIzoC99+; 4:ed1jnuEBKIPwOLeaR5/gu4Ji0bsFCbPhOtpgVAWNnJF1+ExLZYlblI6rTavo4qKwXbXXer4HGyohcOwXyn4on78XhsykHo1ZRqqOGqt4Uew1UE5zy1+GFbs2hNOtYlYX21PqRRpWtTiIr6nKSZEPxNE8TiQLJ+oJPfHvaVg1pgTG5cII8flIDnXV3Ad8lq7TVpO4IobDUZvzqpz5IuMkH1mWutAK5ZBBDiJdTl4cbS/gfjlldJ9VNAaIgEAFc9Qa5yL47SVSwezF7WrQLAKkwIoBlQ771taZcrnww X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SY3PR01MB0282; X-MS-Office365-Filtering-Correlation-Id: 263fb129-c460-4846-6834-08d3211c85f1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(123027)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046); SRVR:SY3PR01MB0282; BCL:0; PCL:0; RULEID:; SRVR:SY3PR01MB0282; X-Forefront-PRVS: 0826B2F01B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(19580395003)(74482002)(4001350100001)(92566002)(97736004)(1096002)(81156007)(33646002)(36756003)(40100003)(189998001)(86362001)(2906002)(122386002)(586003)(5003940100001)(83506001)(5001960100002)(48376002)(110136002)(66066001)(3846002)(106356001)(105586002)(5004730100002)(47776003)(50986999)(54356999)(101416001)(50466002)(87976001)(6116002)(4326007)(5008740100001)(2950100001)(76176999)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:SY3PR01MB0282; H:nitrogen.local; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: tenpoint.co.nz does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SY3PR01MB0282; 23:WWdvtHmGrjgL3tS5tHUMB/UWyF8T4jBkGX/m9MzBQ?= =?us-ascii?Q?GjBPGXPHxDATZTR/0wSUH+C1TcEa4mIlrJqVsKH8gIz9Nmqeta2GbnREoKM7?= =?us-ascii?Q?0IcBYihY1FZy2rd2vbhl96R7TZh4t4o5HvQiNlnI9dXcpIidO5i+mlfGANx+?= =?us-ascii?Q?+xn2LMU/ecSSbHlWeHEuVDYWle5tFhBjQ9jWxzsxNjA8WfksPFakJSwGhMHY?= =?us-ascii?Q?wkNclycb8otrMaIXiqPCOU16xEdOtz7HPGFmrXuL2Kv8O5sTBFzo2s3D08j+?= =?us-ascii?Q?1hAyoj/cg5rHb5JSj4xpxa57XvvXONIPyx1IHyX4aE3o/a/67GXuNCW7v4tQ?= =?us-ascii?Q?LnA1ZEMSYoLTGN4aGAEhoEVIjBISx+ek/XLbWdYjBq74Pu/lj7JTHh0MUdwH?= =?us-ascii?Q?DLBd4MfZDOUuw8YmwZNypr9gLInAJgeJ6YzhljfE7xELYtINC+IPzHtB32FR?= =?us-ascii?Q?tf3WNHx+kR8/3jpkI8dM4Tg/MJQcE1JnmhhLeHQbuTag07bqy2Sy8LGWxetF?= =?us-ascii?Q?60SvTk0qXEgs4ryz/ujj+Byj0VAUuluWpjqNriFDKT+4EslvITmmU/N7Oy2m?= =?us-ascii?Q?2Xqc9ZA4MvL8uzXzPJlcl7yu4vQhSZ6IFWs2Uz4Rrfx/8RVRIfe8ezgAVaOT?= =?us-ascii?Q?i6C X-Microsoft-Exchange-Diagnostics: 1; SY3PR01MB0282; 5:rOlBkvrW6L8yrr8nQ0c9owpNSbbXK9dapMFftbxd9veNeY9GMg0S4op/gEIlHvtAouy0AYG+m86dO6m2I/zu5YucotlOI6PxpCBgcTDZ2ZY3owzHo8FaWaRBTParM40JRKcbpVIveZnKbF1Mo8gINw==; 24:MukgmfZqRMffI+qhttCSkjfZVnlBKtPc9SfLInk7fGN9ghPmqHn25x1C15/yUuaKXZ/me38s91rNyXa3Q1Vu7Ye34KXSpk/Cy2svExE/ECA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: tenpoint.co.nz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2016 22:04:37.7644 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY3PR01MB0282 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.126.123 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108799 Archived-At: > Thanks! I tried it but it gives me some error in GNU Emacs. For the > beginning I instead added this code wich make C-z no longer painful on > OS X: > > (when (eq system-type 'darwin) > (global-set-key [remap suspend-frame] 'ns-do-hide-emacs)) > > Without it the Emacs window minimizes slowly into the dock on my iMac > 27" Retina. On OSX emacs, `suspend-frame' is the equivalent of clicking the yellow minimise button on the window decoration. This is normally on C-z. You could try using s-h (super-h) instead, which is pre-mapped to `ns-do-hide-emacs' and should give you a quick hide key if that's what you need. Sorry about the error on GNU/Emacs. Try replacing the first function with this instead: (defun nh-mac-hide-last-frame (orig-fun &rest args) "Check if last visible frame is being closed and hide it instead." (if (and (featurep 'ns) (display-graphic-p nil) (= 1 (length (frame-list)))) (progn (when (eq (frame-parameter (selected-frame) 'fullscreen) 'fullboth) (set-frame-parameter (selected-frame) 'fullscreen nil) (sit-for 1.2)) (ns-hide-emacs t) (sit-for 1.5) (modify-frame-parameters (selected-frame) default-frame-alist) (delete-other-windows) (switch-to-buffer "*scratch*")) (apply orig-fun args))) This just replaces the mac-* functions with ns-* equivalents. Having access to `ns-hide-emacs' and `ns-do-hide-emacs' is much nicer than messing about with applescript imho. One more thing, if you'd like the frame reset to work (so the unhidden frame has the same position and size properties as a new frame), make sure you have default-frame-alist defined in your init.el. Even better is to set the frame parameters in ~/Library/Preferences/org.gnu.emacs.plist to avoid that annoying flicker as the frame resizes during startup. Nick