From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#38740: 28.0.50; cursor-sensor-mode error in post-command-hook Date: Wed, 05 Feb 2020 21:24:35 +0100 Message-ID: <87lfpgwzng.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="62121"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 38740@debbugs.gnu.org To: Evgeny Zajcev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 05 21:25:19 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1izREd-000G2w-5Z for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Feb 2020 21:25:19 +0100 Original-Received: from localhost ([::1]:55952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izREc-0005JS-72 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Feb 2020 15:25:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58890) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izREP-0005J8-VJ for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2020 15:25:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izREO-0007Jt-TG for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2020 15:25:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1izREM-0007I1-MP for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2020 15:25:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1izREM-0007Fj-Iz for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2020 15:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Feb 2020 20:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38740 X-GNU-PR-Package: emacs Original-Received: via spool by 38740-submit@debbugs.gnu.org id=B38740.158093429127856 (code B ref 38740); Wed, 05 Feb 2020 20:25:02 +0000 Original-Received: (at 38740) by debbugs.gnu.org; 5 Feb 2020 20:24:51 +0000 Original-Received: from localhost ([127.0.0.1]:46771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1izREA-0007FD-Os for submit@debbugs.gnu.org; Wed, 05 Feb 2020 15:24:50 -0500 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:37282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1izRE6-0007Ey-Hr for 38740@debbugs.gnu.org; Wed, 05 Feb 2020 15:24:48 -0500 Original-Received: by mail-wr1-f43.google.com with SMTP id w15so4400560wru.4 for <38740@debbugs.gnu.org>; Wed, 05 Feb 2020 12:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=TQA01c/0o7p+Bgadv4lD0qHJCJc/eBgXM4Ra44a7Xio=; b=u4rEGhrhv8NsazuHcdv0Dzrhc1UiGsW9GpGni7yo+NWjQfHX/nHtQAkMQpYaFJ4IZZ RLlQcYhZyiYB5gDA+/Dnh3VNzPVMJ3E+dCtYHzLOjlXnS2FuAt1Xd4KW1T77LVuGIADN Si0kuqdFO9EEtF5A2InxnpevMPvGT7/J7blYOtSnqY7LpS33mn/JK/Va1OFN7apNc+zN CYxdBirWlTooWJckvhGbnyWgyiy1/gvyAtZuJSBM2UHhaU4N7Y8svNTwtN8OeZfP0tnK nsjLLLf0xxKkUbWNfPDgCTzZ4EXIGEr/UGE9a73UQrLnudChOfoaSF9XP89sHwFW7UOd 2pRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=TQA01c/0o7p+Bgadv4lD0qHJCJc/eBgXM4Ra44a7Xio=; b=gTLZHOx+S5OF7eKSUDODPIOlPfto2RtHPgsI73z3ystZ3n0GwESHfqNEDfRrR+eelP tk/NBJAjR2QQ3zEoLQtsCBF5tY+P6Fn8F8PvICA1gzTLtlYruEn85fGMHAjullCm1Jqv Q36JKPE2LsGoadDCyeqrw2+XmUBwGuBeJGZkCPxZCQOlvkoZBmYa0vEFCs/dyCpciUP3 /XzlWpoQs7jzkIpGmTs0Wf5sJQggH79GuRRNKwfSeTHBzMBT9lFdTxhNTtwidVdN7ARw A8reKyfYJ8m4a9j6pAdH7kLlfnaLfxa1fVDCASFSRLc4j8g4VWGft0CdGsDZe3UeS1mh ZLIg== X-Gm-Message-State: APjAAAWe3JHoT4dp++aW3nueUaYK1v0RVzT3chtekr94evg6OPqWUX2y zFebl4RHTN/6o2tbVui0h6nR6i1C X-Google-Smtp-Source: APXvYqwKPuH4lkqaCAMzW4abIk/32w7SnhGx8OWEqjioMSUd7yZg1KJpsjsvfVzB2QTSPKjztkJuLA== X-Received: by 2002:a5d:448c:: with SMTP id j12mr258384wrq.125.1580934278299; Wed, 05 Feb 2020 12:24:38 -0800 (PST) Original-Received: from lead ([2a02:8109:8ac0:2ff0:bc4b:ff10:27fe:4afc]) by smtp.gmail.com with ESMTPSA id p26sm756569wmc.24.2020.02.05.12.24.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Feb 2020 12:24:37 -0800 (PST) In-Reply-To: (Evgeny Zajcev's message of "Wed, 25 Dec 2019 16:23:11 +0300") 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175714 Archived-At: --=-=-= Content-Type: text/plain > Evaluating next form in scratch buffer: > > (with-help-window "TEST" > (set-buffer standard-output) > (cursor-sensor-mode 1) > (insert "here")) > > Results in error: > > Error in post-command-hook (cursor-sensor--detect): (args-out-of-range 354582) > > Looks like cursor-sensor uses scratch's window instead of "TEST" buffer window. > > I do not remember getting such error in Emacs 26, 27 I found that `cursor-sensor--detect' reads the point position from the buffer displayed in the selected window, and then tries to read text properties in that position in the current buffer. In your example, those two buffers are not the same, the buffer at `standard-output' isn't being displayed yet. I'm attaching a short patch that checks for this case. - Fede --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=cursor.patch Content-Description: patch >From a4c1b8029587ab82afd21db646ad0c0fd691252a Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Wed, 5 Feb 2020 21:22:18 +0100 Subject: [PATCH 1/1] Fix cursor-sensor--detect when current buf != selected window's buf * lisp/emacs-lisp/cursor-sensor.el (cursor-sensor--detect): Avoid trying to read text properties from position taken from another buffer. (Bug#38740) --- lisp/emacs-lisp/cursor-sensor.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el index d8e8eeb16e..7728e78c47 100644 --- a/lisp/emacs-lisp/cursor-sensor.el +++ b/lisp/emacs-lisp/cursor-sensor.el @@ -146,9 +146,10 @@ cursor-sensor--detect ;; It's often desirable to make the cursor-sensor-functions property ;; non-sticky on both ends, but that means get-pos-property might ;; never see it. - (new (or (get-char-property point 'cursor-sensor-functions) - (unless (<= (point-min) point) - (get-char-property (1- point) 'cursor-sensor-functions)))) + (new (and (eq (current-buffer) (window-buffer)) + (or (get-char-property point 'cursor-sensor-functions) + (unless (<= (point-min) point) + (get-char-property (1- point) 'cursor-sensor-functions))))) (old (window-parameter window 'cursor-sensor--last-state)) (oldposmark (car old)) (oldpos (or (if oldposmark (marker-position oldposmark)) -- 2.17.1 --=-=-=--