From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: Emacs 26 MacOS bugs Date: Sun, 11 Feb 2018 11:47:31 +0000 Message-ID: <20180211114731.GA45075@breton.holly.idiocy.org> References: <20180210224516.GA33099@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Kj7319i9nmIyA2yE" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1518349619 25946 195.159.176.226 (11 Feb 2018 11:46:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Feb 2018 11:46:59 +0000 (UTC) User-Agent: Mutt/1.9.3 (2018-01-21) Cc: emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 11 12:46:54 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekq5o-00068M-E5 for ged-emacs-devel@m.gmane.org; Sun, 11 Feb 2018 12:46:48 +0100 Original-Received: from localhost ([::1]:55148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekq7p-00011E-WD for ged-emacs-devel@m.gmane.org; Sun, 11 Feb 2018 06:48:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekq6e-00010t-Tq for emacs-devel@gnu.org; Sun, 11 Feb 2018 06:47:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekq6d-0007qv-MU for emacs-devel@gnu.org; Sun, 11 Feb 2018 06:47:41 -0500 Original-Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:55297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekq6a-0007mi-Nt; Sun, 11 Feb 2018 06:47:37 -0500 Original-Received: by mail-wm0-x229.google.com with SMTP id 143so4875244wma.5; Sun, 11 Feb 2018 03:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=F8hr7/6fKbdflESSeA44Fiba9Pj1X5pGnkFEP0KbvWE=; b=isDxaCJW/RqhL+O6OAjASCgbSVWIb98nmD8HjWdfk7TpvJ8o4s202SVhV8j/BuA9I3 TtzkSqn9605HsfzQIEVT0/bjf9h3JIu02494tj8g51EGBa/05x8wmXA+UHh74MxsxRGC 1dED3OhBwJGXjDlmppUMl/6e3xH+2aQ1qCL+lEG1zMY6C0hsFUVv9Gd0RqB3sDQbIhmL 4r4IoEAJ+jXtnBQvLwMeZIZ10g7TFfFQteTDC5sGa/smpL1tzdF2tcjk179O1KCd8/XN AZj/L8oJbAyKsDU1qGQY8QUGdlqLhh1wsT6ysXSdotbX/w+iGnE12/MblWWl3oZBu4Al dLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=F8hr7/6fKbdflESSeA44Fiba9Pj1X5pGnkFEP0KbvWE=; b=QfootSf36oiHNMDUsYyCRz59HI4BH+z2VRCSNAyUroCjL0JSQ4sXsi0ErzADy8bv4i q5rJ9AszU7/wpx5qdaJImJRmdXJS5WHoYwGf0iAGw/edak3NPmGl26+l4wF1GiNWP6Hc wuaGKYifIRpwiZOkoQ6TGopJZ1wobDTVHRp2g/nrbUD/4xrNYmmBQCiIfxZUj+eKJd5h DajnOpoKqe/wulm3A42Z7bUPqGlbGrNqaxi7i60U6niijaN0vlk8EryUdWotqsAG98P+ +xOZaHwrCMUgBh0/XKAP9i5NbgowtMJ5DLjA45xe3agjzphexHR8t0SISk8MIp/pdUAf /zeQ== X-Gm-Message-State: APf1xPAcwAMTIgEnl1F3VvYVv4oZ2gDwm6djBUkCID9fAgtp1DWJXnuv 8Md5mps1HWC5JlT72kb3G9DS5fkh X-Google-Smtp-Source: AH8x226dhgglJJpwJRvcjJVi707R1iEPDMroQ9Sfz9yRntFS7SGU3lQ0/7aycCI/NTDlwnLifOu55w== X-Received: by 10.28.16.2 with SMTP id 2mr1171018wmq.120.1518349654869; Sun, 11 Feb 2018 03:47:34 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-74c9-75ab-6497-55f7.holly.idiocy.org. [2001:8b0:3f8:8129:74c9:75ab:6497:55f7]) by smtp.gmail.com with ESMTPSA id w14sm2458120wmf.32.2018.02.11.03.47.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2018 03:47:34 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180210224516.GA33099@breton.holly.idiocy.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222659 Archived-At: --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Feb 10, 2018 at 10:45:16PM +0000, Alan Third wrote: > On Tue, Feb 06, 2018 at 09:49:16AM -0500, Richard Stallman wrote: > > C.10 : > > - - (p 520) neither -T=title nor --title=title appear to work on macOS > > (Sierra), although --name=title does. > > I believe this is caused by the way macOS handles filenames in the > titlebar. Fix attached. It seems to work for me, but I only learned today that the macOS ‘proxy icon’ is anything other than just an icon, so if it breaks anything subtle I probably wouldn’t notice. -- Alan Third --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Remove-NS-special-handling-of-frame-title-format.patch" >From c89bfa7e6fc634a6da01ca37abb9e726bea83c3b Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 11 Feb 2018 11:34:49 +0000 Subject: [PATCH] Remove NS special handling of 'frame-title-format' * lisp/term/ns-win.el (frame-title-format, icon-title-format): Change default format to just the filename. * src/nsfns.m (ns-use-proxy-icon): New variable. (ns_set_name_as_filename): Remove function. (x_implicitly_set_name): Get rid of special handling of frame-title-format. * src/nsterm.h (ns_set_represented_filename): Use new definition. * src/nsterm.m (ns_set_represented_filename): Move some of the logic from ns_set_name_as_filename into this function. --- etc/NEWS | 5 +++ lisp/term/ns-win.el | 4 +-- src/nsfns.m | 91 +++++------------------------------------------------ src/nsterm.h | 2 +- src/nsterm.m | 30 +++++++++++++++++- 5 files changed, 45 insertions(+), 87 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 8fed15af5b..005f177a27 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -289,6 +289,11 @@ Previously it was supported only in the Cygwin-w32 build. ** Emacs now handles key combinations involving the macOS "command" and "option" modifier keys more correctly. +** The special handling of `frame-title-format' on NS where setting it +to `t' would enable the macOS proxy icon has been replaced with a +separate variable, `ns-use-proxy-icon'. `frame-title-format' will now +work as on other platforms. + ---------------------------------------------------------------------- This file is part of GNU Emacs. diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index eab95e02d8..ea9991ba36 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -807,8 +807,8 @@ ns-suspend-error ;; Set some options to be as Nextstep-like as possible. -(setq frame-title-format t - icon-title-format t) +(setq frame-title-format "%b" + icon-title-format "%b") (defvar ns-initialized nil diff --git a/src/nsfns.m b/src/nsfns.m index 0f60bb8107..bbb6644ce0 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -61,7 +61,6 @@ Updated by Christian Limpach (chris@nice.ch) static ptrdiff_t image_cache_refcount; static struct ns_display_info *ns_display_info_for_name (Lisp_Object); -static void ns_set_name_as_filename (struct frame *); /* ========================================================================== @@ -483,17 +482,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side { NSTRACE ("x_implicitly_set_name"); - Lisp_Object frame_title = buffer_local_value - (Qframe_title_format, XWINDOW (f->selected_window)->contents); - Lisp_Object icon_title = buffer_local_value - (Qicon_title_format, XWINDOW (f->selected_window)->contents); + if (! NILP (ns_use_proxy_icon)) + ns_set_represented_filename (f); - /* Deal with NS specific format t. */ - if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (icon_title, Qt)) - || EQ (frame_title, Qt))) - ns_set_name_as_filename (f); - else - ns_set_name (f, arg, 0); + ns_set_name (f, arg, 0); } @@ -520,78 +512,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side ns_set_name_internal (f, name); } - -static void -ns_set_name_as_filename (struct frame *f) -{ - NSView *view; - Lisp_Object name, filename; - Lisp_Object buf = XWINDOW (f->selected_window)->contents; - const char *title; - NSAutoreleasePool *pool; - Lisp_Object encoded_name, encoded_filename; - NSString *str; - NSTRACE ("ns_set_name_as_filename"); - - if (f->explicit_name || ! NILP (f->title)) - return; - - block_input (); - pool = [[NSAutoreleasePool alloc] init]; - filename = BVAR (XBUFFER (buf), filename); - name = BVAR (XBUFFER (buf), name); - - if (NILP (name)) - { - if (! NILP (filename)) - name = Ffile_name_nondirectory (filename); - else - name = build_string ([ns_app_name UTF8String]); - } - - encoded_name = ENCODE_UTF_8 (name); - - view = FRAME_NS_VIEW (f); - - title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] - : [[[view window] title] UTF8String]; - - if (title && (! strcmp (title, SSDATA (encoded_name)))) - { - [pool release]; - unblock_input (); - return; - } - - str = [NSString stringWithUTF8String: SSDATA (encoded_name)]; - if (str == nil) str = @"Bad coding"; - - if (FRAME_ICONIFIED_P (f)) - [[view window] setMiniwindowTitle: str]; - else - { - NSString *fstr; - - if (! NILP (filename)) - { - encoded_filename = ENCODE_UTF_8 (filename); - - fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; - if (fstr == nil) fstr = @""; - } - else - fstr = @""; - - ns_set_represented_filename (fstr, f); - [[view window] setTitle: str]; - fset_name (f, name); - } - - [pool release]; - unblock_input (); -} - - void ns_set_doc_edited (void) { @@ -3311,6 +3231,11 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename doc: /* Toolkit version for NS Windowing. */); Vns_version_string = ns_appkit_version_str (); + DEFVAR_BOOL ("ns-use-proxy-icon", ns_use_proxy_icon, + doc: /* When non-nil display a proxy icon in the titlebar. +Default is t. */); + ns_use_proxy_icon = Qt; + defsubr (&Sns_read_file_name); defsubr (&Sns_get_resource); defsubr (&Sns_set_resource); diff --git a/src/nsterm.h b/src/nsterm.h index cc4c6d5e91..8b985930ec 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1237,7 +1237,7 @@ extern void ns_finish_events (void); #ifdef __OBJC__ /* Needed in nsfns.m. */ extern void -ns_set_represented_filename (NSString *fstr, struct frame *f); +ns_set_represented_filename (struct frame *f); #endif diff --git a/src/nsterm.m b/src/nsterm.m index f017d8d152..c694544b07 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -469,10 +469,38 @@ - (NSColor *)colorUsingDefaultColorSpace ========================================================================== */ void -ns_set_represented_filename (NSString *fstr, struct frame *f) +ns_set_represented_filename (struct frame *f) { + NSView *view; + Lisp_Object filename, encoded_filename; + Lisp_Object buf = XWINDOW (f->selected_window)->contents; + NSAutoreleasePool *pool; + NSString *fstr; + + NSTRACE ("ns_set_represented_filename"); + + if (f->explicit_name || ! NILP (f->title)) + return; + + block_input (); + pool = [[NSAutoreleasePool alloc] init]; + filename = BVAR (XBUFFER (buf), filename); + + if (! NILP (filename)) + { + encoded_filename = ENCODE_UTF_8 (filename); + + fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; + if (fstr == nil) fstr = @""; + } + else + fstr = @""; + represented_filename = [fstr retain]; represented_frame = f; + + [pool release]; + unblock_input (); } void -- 2.16.1 --Kj7319i9nmIyA2yE--