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#25265: [PATCH] Rework NS event handling (bug#25265) Date: Sun, 1 Jan 2017 15:03:52 +0000 Message-ID: <20170101150352.GA61550@breton.holly.idiocy.org> References: <83vau0h2u5.fsf@gnu.org> <20161231160930.GA29122@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1483283123 16609 195.159.176.226 (1 Jan 2017 15:05:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Jan 2017 15:05:23 +0000 (UTC) User-Agent: Mutt/1.7.1 (2016-10-04) Cc: charles@aurox.ch, 25265@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 01 16:05: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 1cNhh6-0002SG-1B for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jan 2017 16:05:08 +0100 Original-Received: from localhost ([::1]:53650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNhh9-0005Mu-Uy for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jan 2017 10:05:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNhh4-0005KS-3Y for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 10:05:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cNhh0-0005Zb-VI for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 10:05:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51532) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cNhh0-0005ZX-RV for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 10:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cNhh0-0005ln-C7 for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 10:05: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, 01 Jan 2017 15:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25265 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25265-submit@debbugs.gnu.org id=B25265.148328305222119 (code B ref 25265); Sun, 01 Jan 2017 15:05:02 +0000 Original-Received: (at 25265) by debbugs.gnu.org; 1 Jan 2017 15:04:12 +0000 Original-Received: from localhost ([127.0.0.1]:38698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cNhgC-0005kh-0K for submit@debbugs.gnu.org; Sun, 01 Jan 2017 10:04:12 -0500 Original-Received: from mail-wj0-f169.google.com ([209.85.210.169]:33868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cNhgA-0005kT-NJ for 25265@debbugs.gnu.org; Sun, 01 Jan 2017 10:04:11 -0500 Original-Received: by mail-wj0-f169.google.com with SMTP id sd9so224974198wjb.1 for <25265@debbugs.gnu.org>; Sun, 01 Jan 2017 07:04:10 -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=OrSWavJqyX7WfDxHG08kkP+Biupuo4JnPB+Vaqest8M=; b=XMepzfVuJLVWKsh8afjJF1dDJXMYuG3cIQYOVSe1nt7s1pCv93x0R48SLoHbDpqxkl dZNkJmatYMXWv2K58OcE0+wfBy1hZlIMf8/fBfFhW8apyvou/ZsYXUYG55gp0LDhTtj2 TAAbLKhLwr3DCicQiV+e4BGCKCNeNFTw0mLXGzIUoHbWUSqmJH9kMDSlfWXemCO4u54i NCpzV1lpheA3JbmmudtyAiSQJvlywBN8jJveGPSfJlMHoenw+gzQijexxmoxv5sF7017 ZNqKxcNwPAfYAR+x+RjzC0Jvh7jlGPBR1ogyf1T7LKBqmTkXubDVXZ5jA57K7+pdSLYV +Jhg== 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=OrSWavJqyX7WfDxHG08kkP+Biupuo4JnPB+Vaqest8M=; b=HuCIgjJ5FLnaDVkQUhPqx7Bs+JVqFZk91LlS1iw8PEu8P7/ghyvjb3wJUYpV59bri6 Oi1DmOcsAczKeSqifvcDUqK9mLFG1aB7aqEJ20Bnm8L9iPyXOhdcC17DcGRR48USFQ/3 2FXsn35UvHq3hgttpicfb8Le5EaOmDuc07EXacFPPiObHz5veP5X/Rq7vvkN0flm1WhR riaeu3SQDlDib98j17dQQ+P/5QhVjxohZhU9mdC7ki6KH0JMGv5dABBb4AMhiOThdiqs M9E7ThgNTsMHfGRD8TvHyosta7xxg0m5JWEv1uBPQeFYiV+CnfN1uE17VImYtpV0HNc7 85nw== X-Gm-Message-State: AIkVDXItIqR43JU2TkKsCiTWwxJpcXEc3JLK+vb5N2wcnrczytkctHnXNTfEFBNR/aGXyQ== X-Received: by 10.194.52.42 with SMTP id q10mr45282684wjo.50.1483283044766; Sun, 01 Jan 2017 07:04:04 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-e07c-b900-3b81-e87f.holly.idiocy.org. [2001:8b0:3f8:8129:e07c:b900:3b81:e87f]) by smtp.gmail.com with ESMTPSA id l74sm79734414wmg.2.2017.01.01.07.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jan 2017 07:04:04 -0800 (PST) Content-Disposition: inline In-Reply-To: <20161231160930.GA29122@breton.holly.idiocy.org> 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:127658 Archived-At: On Sat, Dec 31, 2016 at 04:09:30PM +0000, Alan Third wrote: > * src/nsterm.m (unwind_apploopnr): Remove. > (ns_read_socket): Remove references to apploopnr. Make processing the > NS event loop conditional on being in the main thread. > (ns_select): Remove references to apploopnr. Remove all fd_handler > related stuff. Check if there are events waiting on the NS event > queue rather than running the event loop. Remove unused variables and > code. > (fd_handler): Remove. > (ns_term_init): Remove creation of fd_handler thread. > (hold_event, EmacsApp:sendEvent, EmacsView:mouseMoved, > EmacsView:windowDidExpose): Remove send_appdefined. > (ns_send_appdefined): Always check the event queue for > applicationDefined events rather than relying on send_appdefined var. > * src/nsterm.h: Remove reference to fd_handler method. OK, I’m running into performance bugs with this almost straight away. It all looks OK until I start flyspell-mode. Then it appears that redisplay is only called every two or three keypresses. It looks like Emacs is still going fine, though, as messages to the modeline appear, even if the action isn’t immediately displayed in the buffer. For example, I open up an org file and start flyspell-mode, then I hit the down arrow which should take me to a heading but the cursor doesn’t move. Then I hit TAB, and I get a message in the modeline telling me that the section associated with the heading has been expanded, but the buffer is still displayed with the cursor on the previous line and the section not expanded. Finally I hit the down arrow again and the buffer updates to display the expanded section and the cursor where I’d expect it. emacsclient runs with a delay, which I guess corresponds to the timeout on the NS event queue check. I’m not at all sure how to fix these problems. One option I thought about is to wrap the fd’s in ns_select with NSFileHandle, which should then mean we could look for notifications on the NS event queue, and emulate select that way. Unfortunately as far as I can see NSFileHandle only provides an event for ‘data available for reading’, and it looks like we’d need to be able to spot write availability too. (See under Notifications: https://developer.apple.com/reference/foundation/nsfilehandle) -- Alan Third