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: Mon, 17 Feb 2020 22:04:36 +0100 Message-ID: References: <87lfpgwzng.fsf@gmail.com> <83blq0ntm1.fsf@gnu.org> 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="8314"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) Cc: lg.zevlg@gmail.com, 38740@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 17 22:05:12 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 1j3nZo-000201-Ep for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Feb 2020 22:05:12 +0100 Original-Received: from localhost ([::1]:53050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nZn-0001B4-Gp for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Feb 2020 16:05:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40837) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3nZf-00017u-U2 for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 16:05:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3nZe-0006u9-NP for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 16:05:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3nZe-0006u2-JV for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 16:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3nZe-0004vF-EK for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 16:05: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: Mon, 17 Feb 2020 21:05: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.158197348618895 (code B ref 38740); Mon, 17 Feb 2020 21:05:02 +0000 Original-Received: (at 38740) by debbugs.gnu.org; 17 Feb 2020 21:04:46 +0000 Original-Received: from localhost ([127.0.0.1]:39299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3nZO-0004uh-5e for submit@debbugs.gnu.org; Mon, 17 Feb 2020 16:04:46 -0500 Original-Received: from mail-wr1-f51.google.com ([209.85.221.51]:37739) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3nZM-0004uU-AS for 38740@debbugs.gnu.org; Mon, 17 Feb 2020 16:04:44 -0500 Original-Received: by mail-wr1-f51.google.com with SMTP id w15so21407764wru.4 for <38740@debbugs.gnu.org>; Mon, 17 Feb 2020 13:04:44 -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=lO5qzXhVv3Gs8SZytTPTcPaby4dthBFJYK3We/aq0W4=; b=G5dth1g3xsMxFfDre0S9+8u1kmi3p5Im+Czrj0tUBOkfIOEnEkd4nNTneUi+HRSBXZ kr/6GKcLe4ALSdmdUYiY66lJZz7Bdu64n09UaK6jTObguFxBNUnOJnxne6QkWfd63Cuk 7fqWt1lrre+cjnM0Bd9hylj7ILxAPwbNrAVB5rTo1Ejll947U9fzHwF/d4EPXn2kDSBs qZFrhJtvYCjFOODl62D4WXrcQWsE0gboXCKF18YARMHsmVBKADleUhmIGETToUJR6m0B a7TW3FtLB4IowuUIHGeNTYsOEQnroZXE7IjJjIeY1Y3UMZa6kEt3VfWsadDk7+gKpSZ9 Itiw== 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=lO5qzXhVv3Gs8SZytTPTcPaby4dthBFJYK3We/aq0W4=; b=tkYZdiShM4EDLPLzjTAb1VM+WnYGpuZtJ5Oo8f2fM+Zn8fDUP+mzsAtyJAaatSTmDj +ummyYvYHp9HuVqTzwrVkT0mvRTzElGyaqA+/e4uHE5yb8e/HTx6AQXvGKgIt/uSt+1t oVomwDRyOStbB+ov4R2s4RImYG14lnnHO3jgi62wm9KnJkY045AUdNwO6hRF2QVMIr+2 x1I+L/rN+0DxlmtDdCZ/Via1Zb1dlwgSW5hiBu8bUdW1uaxv223MxLZNVqrV4x5WW7u4 CUKCu1ccQqHRLKS6Z5iL8dyCo6zUgbfDTMQDR41rIv8IyoVuXAEqN9wBB/YSv/V6J7aT iBxA== X-Gm-Message-State: APjAAAXkxvm5INPr5ZC3FjYdC5YlilD9fn1jRxpM9jnOCTdmh5Z/nEgf vChxl2ZDuXw5JZOa0n4Lm8Ijl81S4YQ= X-Google-Smtp-Source: APXvYqxZsaqy4ubvsajONp0fWSkEUxrO/xgtOeTcrVpExw31FNyO+wYlD6UbXHAYzPf4I8Gk8/ahWA== X-Received: by 2002:a5d:6445:: with SMTP id d5mr23732683wrw.244.1581973478243; Mon, 17 Feb 2020 13:04:38 -0800 (PST) Original-Received: from BERMB00016 ([2a02:8109:8ac0:2ff0:e051:7ad2:2a71:fe3c]) by smtp.gmail.com with ESMTPSA id o4sm2766601wrx.25.2020.02.17.13.04.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Feb 2020 13:04:37 -0800 (PST) In-Reply-To: <83blq0ntm1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 15 Feb 2020 10:27:02 +0200") 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:176163 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Federico Tedin >> Date: Wed, 05 Feb 2020 21:24:35 +0100 >> Cc: 38740@debbugs.gnu.org >> >> > 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. > > LGTM, thanks. I'm attaching the patch again but with the correct commit message formatting. - Fede --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-cursor-sensor-detect-when-current-buf-selected-w.patch Content-Description: patch >From 5c9edf2f69ff531229f06c3dbedb468aef01e69a Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Mon, 17 Feb 2020 21:58:43 +0100 Subject: [PATCH] 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.21.1 (Apple Git-122.3) --=-=-=--