unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds
@ 2016-12-04  6:28 npostavs
  2016-12-04 15:39 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: npostavs @ 2016-12-04  6:28 UTC (permalink / raw)
  To: 25104

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

tags: patch

From emacs -Q, insert the following in *scratch*, and evaluate it
twice.

(with-current-buffer (get-buffer-create "foo")
  (erase-buffer)
  (insert (make-string 200 ?\n))
  (cursor-sensor-mode +1)
  (display-buffer (current-buffer)))

The second time an error is triggered, here is a backtrace:

Debugger entered--Lisp error: (args-out-of-range 0)
  get-char-property(0 cursor-sensor-functions)
  cursor-sensor--detect(#<window 9 on *Backtrace*>)
  run-hook-with-args(cursor-sensor--detect #<window 9 on *Backtrace*>)
  redisplay--pre-redisplay-functions((#<window 9 on *Backtrace*>))
  apply(redisplay--pre-redisplay-functions (#<window 9 on *Backtrace*>))
  #[128 "\300\301\"\210\300\302\"\207" [apply redisplay--pre-redisplay-functions ignore nil] 4 nil nil]((#<window 9 on *Backtrace*>))
  redisplay_internal\ \(C\ function\)()

cursor-sensor-mode is a new feature in Emacs 25, so I propose the
following patch for emacs-25:


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1446 bytes --]

From 67817cd0727a1b257952afb93fc9a8238965b3c4 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 4 Dec 2016 01:06:52 -0500
Subject: [PATCH v1] Don't assume window-point and point are the same

The function `cursor-sensor--detect' calls `bobp' to decide whether to
check properties at (1- (window-point)).  However, (window-point) may be
at beginning of buffer, even if (point) is not.  In this case an
`args-out-of-range' error will be signaled.

* lisp/emacs-lisp/cursor-sensor.el (cursor-sensor--detect): Check the
value of (window-point) against (point-min), rather than (bobp) to
decide if (1- (window-point)) is accessible.
---
 lisp/emacs-lisp/cursor-sensor.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el
index 2231179..28b6188 100644
--- a/lisp/emacs-lisp/cursor-sensor.el
+++ b/lisp/emacs-lisp/cursor-sensor.el
@@ -114,7 +114,7 @@ cursor-sensor--detect
            ;; 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 (bobp)
+                    (unless (<= (point-min) point)
                       (get-char-property (1- point) 'cursor-sensor-functions))))
            (old (window-parameter window 'cursor-sensor--last-state))
            (oldposmark (car old))
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds
  2016-12-04  6:28 bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds npostavs
@ 2016-12-04 15:39 ` Eli Zaretskii
  2016-12-07  3:41   ` npostavs
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2016-12-04 15:39 UTC (permalink / raw)
  To: npostavs; +Cc: 25104

> From: npostavs@users.sourceforge.net
> Date: Sun, 04 Dec 2016 01:28:49 -0500
> 
> cursor-sensor-mode is a new feature in Emacs 25, so I propose the
> following patch for emacs-25:

Thanks, the patch looks trivially correct for me, and I agree it
should go to the release branch.  Please wait for a couple of days
(this being a weekend) for possible comments or objections, and push
then if none are raised.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds
  2016-12-04 15:39 ` Eli Zaretskii
@ 2016-12-07  3:41   ` npostavs
  0 siblings, 0 replies; 3+ messages in thread
From: npostavs @ 2016-12-07  3:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25104

tags 25104 fixed
close 25104 25.2
quit

Eli Zaretskii <eliz@gnu.org> writes:

>> From: npostavs@users.sourceforge.net
>> Date: Sun, 04 Dec 2016 01:28:49 -0500
>> 
>> cursor-sensor-mode is a new feature in Emacs 25, so I propose the
>> following patch for emacs-25:
>
> Thanks, the patch looks trivially correct for me, and I agree it
> should go to the release branch.  Please wait for a couple of days
> (this being a weekend) for possible comments or objections, and push
> then if none are raised.

Pushed as 35ce3fb.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-07  3:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-04  6:28 bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds npostavs
2016-12-04 15:39 ` Eli Zaretskii
2016-12-07  3:41   ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).