From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#29837: UTF-16 char display problems and the macOS "character palette" Date: Sun, 24 Dec 2017 16:00:53 +0000 Message-ID: <20171224160053.GA71863@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="82I3+IH0IqGh5yIs" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1514131222 20815 195.159.176.226 (24 Dec 2017 16:00:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Dec 2017 16:00:22 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) To: 29837@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 24 17:00:18 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1eT8hB-0004na-7G for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Dec 2017 17:00:13 +0100 Original-Received: from localhost ([::1]:56396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eT8j9-0005PD-RW for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Dec 2017 11:02:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eT8j2-0005Oe-TK for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:02:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eT8iz-0003Xk-A5 for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:02:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eT8iz-0003XB-5V for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:02:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eT8iw-0001UL-EE for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Dec 2017 16:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29837 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15141312695635 (code B ref -1); Sun, 24 Dec 2017 16:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Dec 2017 16:01:09 +0000 Original-Received: from localhost ([127.0.0.1]:50801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eT8i5-0001So-DY for submit@debbugs.gnu.org; Sun, 24 Dec 2017 11:01:09 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eT8i4-0001Sb-7A for submit@debbugs.gnu.org; Sun, 24 Dec 2017 11:01:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eT8hx-0002lB-TC for submit@debbugs.gnu.org; Sun, 24 Dec 2017 11:01:03 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eT8hx-0002l5-OR for submit@debbugs.gnu.org; Sun, 24 Dec 2017 11:01:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eT8hw-00058I-5i for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:01:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eT8hu-0002kE-S2 for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:01:00 -0500 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:42470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eT8hu-0002jm-Fb for bug-gnu-emacs@gnu.org; Sun, 24 Dec 2017 11:00:58 -0500 Original-Received: by mail-wm0-x232.google.com with SMTP id b199so29476935wme.1 for ; Sun, 24 Dec 2017 08:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=wScRBh4ywTqIEI/9kFuvOJ6/iCXGnuSdcA4QHzsv5EA=; b=a6thREtKFC315nwfTyRyHExu4Er8zN0ISg9t0lnN/i3ENH6nbhJ8VNhRuu4SodZqa2 r3Efybk2rLw4ASCiMiW17VRDJRx0Khd4+N1oiC2ixqhYcX1Nl0A4RHLy8LtG3nQYOgYp mDt0ezRg26sg6Qt/CRR3nTj0k3FoApnb6ZHR/4eL/RBBUNfNYZmQqPGPiaEzgldLtUYa wd7U4nnwh5KMrLO88EvO+aBRMDiQAkS4vKxrMNF9I6NlaPvkFnapBsewC6skEpAj7MVT tpWLRYhyw48uMubtPArJlcGm0HGtbJTG298dCLl6Eb/VUM9fuloiABXB8YuVaOZRnk9C cFGw== 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:subject:message-id :mime-version:content-disposition:content-transfer-encoding :user-agent; bh=wScRBh4ywTqIEI/9kFuvOJ6/iCXGnuSdcA4QHzsv5EA=; b=cqN90lnvx7/2niwjsiJzz5QKi8/pgVupPdTOslwiy5xMTgJsDqZXYq8GFnSjEkKcMW fZGNodgkJB7VR099SA8XIn4kD65NVN/dl9K9wEAGva2/BJIQdMbl8NZ0bO5/jyC66h5C Catx/Z1nEwD27ceje677rzcIp5nfuYhtNxSKeggCcytiZEzlSt43IyPS295+mYej240x Mrll2Dhz7YVpiMcWigMpIuDlmW9n4LaN+MTeJMO+4EcYHqC1OV9+7rFwxN5Y85WPxmhU LBYraukuXMYiD45dWyotwfnj46mHty3A/vfusdA0DXwuZYDnNeJUcp4Q51DM27ubjeL3 P9eQ== X-Gm-Message-State: AKGB3mI37I2np8L5xQaHwNDQtQxgCIHK/zzWr67jw+WhBjX7NUqk2Q+y qyTSht7y2M6yGHHIBlAj57ndOR2V X-Google-Smtp-Source: ACJfBosl3a+xwpyWG68yYylRCDHoAHSy4oy7fIh759Zy0O1FLCm6pAP4ow296D8dKl8iJ82jFKrvkw== X-Received: by 10.28.157.7 with SMTP id g7mr15987033wme.89.1514131256807; Sun, 24 Dec 2017 08:00:56 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-2872-d519-1675-2de8.holly.idiocy.org. [2001:8b0:3f8:8129:2872:d519:1675:2de8]) by smtp.gmail.com with ESMTPSA id f4sm33412668wra.75.2017.12.24.08.00.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Dec 2017 08:00:55 -0800 (PST) Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141450 Archived-At: --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, I’ve had a go at enabling the macOS character palette, which is just a virtual keyboard that helps you to enter special characters, emoji’s, etc. It’s easy enough to bring it up (patch attached) but some special characters are put into Emacs incorrectly. I think the problem is that we have multi code‐point UTF‐16 characters, and when they are ‘typed’ into Emacs they are entered as individual 16 bit code‐points and are therefore displayed as a series of blank spaces. An example is '🢫' (RIGHTWARDS FRONT-TILTED SHADOWED WHITE ARROW). If I enter it using C‐x 8 RET, it appears correctly, but if I use the character palette it shows up as two blank spaces. Describe-char reveals these to be HIGH SURROGATE-D83E and LOW SURROGATE-DCAB, in that order. I can’t work out if Emacs should be able to handle these multi code‐point characters being entered from a ‘keyboard’ input or not. If so, does anyone have any idea what I need to do? (Another minor irritation is that some characters (like pointing hands) seem to insert the desired character then follow up with VARIATION SELECTOR-15. I assume this is supposed to tell us what colour we want the hand? If so should it be displayed?) -- Alan Third --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-macOS-character-palette.patch" >From ad16b98288abe91732217535e308ae445303ab59 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 24 Dec 2017 15:40:03 +0000 Subject: [PATCH] Add macOS character-palette --- lisp/term/ns-win.el | 8 ++++++++ src/nsfns.m | 14 ++++++++++++++ src/nsterm.m | 7 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index d512e8e506..7955ae0cb0 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -144,6 +144,8 @@ global-map (define-key global-map [?\s-z] 'undo) (define-key global-map [?\s-|] 'shell-command-on-region) (define-key global-map [s-kp-bar] 'shell-command-on-region) +;; The key-chord below is C-s-SPC +(define-key global-map [C-s-268632064] 'ns-do-show-character-palette) ;; (as in Terminal.app) (define-key global-map [s-right] 'ns-next-frame) (define-key global-map [s-left] 'ns-prev-frame) @@ -575,6 +577,12 @@ ns-do-emacs-info-panel (interactive) (ns-emacs-info-panel)) +(declare-function ns-show-character-palette "nsfns.m" ()) + +(defun ns-do-show-character-palette () + (interactive) + (ns-show-character-palette)) + (defun ns-next-frame () "Switch to next visible frame." (interactive) diff --git a/src/nsfns.m b/src/nsfns.m index 05605bf657..402771e2f8 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -3135,6 +3135,19 @@ The position is returned as a cons cell (X . Y) of the (pt.y - screen.frame.origin.y))); } +DEFUN ("ns-show-character-palette", + Fns_show_character_palette, + Sns_show_character_palette, 0, 0, 0, + doc: /* Show the macOS character palette. */) + (void) +{ + struct frame *f = SELECTED_FRAME (); + EmacsView *view = FRAME_NS_VIEW (f); + [NSApp orderFrontCharacterPalette:view]; + + return Qnil; +} + /* ========================================================================== Class implementations @@ -3326,6 +3339,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename defsubr (&Sns_frame_restack); defsubr (&Sns_set_mouse_absolute_pixel_position); defsubr (&Sns_mouse_absolute_pixel_position); + defsubr (&Sns_show_character_palette); defsubr (&Sx_display_mm_width); defsubr (&Sx_display_mm_height); defsubr (&Sx_display_screens); diff --git a/src/nsterm.m b/src/nsterm.m index 07ac8f978f..65a9aac4a7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6284,11 +6284,16 @@ flag set (this is probably a bug in the OS). - (void)insertText: (id)aString { int code; - int len = [(NSString *)aString length]; + int len; int i; NSTRACE ("[EmacsView insertText:]"); + if ([aString isKindOfClass:[NSAttributedString class]]) + aString = [aString string]; + + len = [(NSString *)aString length]; + if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %d", aString, len); processingCompose = NO; -- 2.14.3 --82I3+IH0IqGh5yIs--