GNU bug report logs -
#35967
[PATCH] avoid flyspell error if point is at bob
Previous Next
Reported by: Alex Branham <alex.branham <at> gmail.com>
Date: Tue, 28 May 2019 20:45:01 UTC
Severity: normal
Tags: patch
Done: Alex Branham <alex.branham <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35967 in the body.
You can then email your comments to 35967 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Tue, 28 May 2019 20:45:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Branham <alex.branham <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 28 May 2019 20:45:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello -
The attached patch avoids an args-out-of-range error (from
`get-text-property') if `flyspell-prog-mode' is on and point is in a
comment at the beginning of the buffer.
Thanks,
Alex
[0001-Avoid-a-flyspell-error-if-point-is-at-beginning-of-b.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Wed, 29 May 2019 16:09:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 35967 <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Date: Tue, 28 May 2019 15:43:53 -0500
>
> >From e130dfcb542af667fbef6e6eb867c46eee6d9746 Mon Sep 17 00:00:00 2001
> From: Alex Branham <alex.branham <at> gmail.com>
> Date: Tue, 28 May 2019 15:40:26 -0500
> Subject: [PATCH] Avoid a flyspell error if point is at beginning of buffer
>
> * lisp/textmodes/flyspell.el (flyspell-generic-progmode-verify):
> Check if point is at bob. This prevents an error when e.g.
> 'flyspell-auto-correct-word' gets called with point at the
> beginning of the buffer.
> ---
> lisp/textmodes/flyspell.el | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
> index d18916dfd0..e711fe72b2 100644
> --- a/lisp/textmodes/flyspell.el
> +++ b/lisp/textmodes/flyspell.el
> @@ -424,8 +424,9 @@ like <img alt=\"Some thing.\">."
> (defun flyspell-generic-progmode-verify ()
> "Used for `flyspell-generic-check-word-predicate' in programming modes."
> ;; (point) is next char after the word. Must check one char before.
> - (let ((f (get-text-property (- (point) 1) 'face)))
> - (memq f flyspell-prog-text-faces)))
> + (unless (bobp)
> + (let ((f (get-text-property (- (point) 1) 'face)))
> + (memq f flyspell-prog-text-faces))))
Thanks.
Maybe it's just me, but whenever I see bobp, I always have to consult
the docs regarding what happens in a narrowed buffer. For that
reason, I prefer comparison with point-min instead.
Am I the only one troubled by that?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Thu, 30 May 2019 11:59:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 35967 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Alex Branham <alex.branham <at> gmail.com>
>> Date: Tue, 28 May 2019 15:43:53 -0500
>>
>> >From e130dfcb542af667fbef6e6eb867c46eee6d9746 Mon Sep 17 00:00:00 2001
>> From: Alex Branham <alex.branham <at> gmail.com>
>> Date: Tue, 28 May 2019 15:40:26 -0500
>> Subject: [PATCH] Avoid a flyspell error if point is at beginning of buffer
>>
>> * lisp/textmodes/flyspell.el (flyspell-generic-progmode-verify):
>> Check if point is at bob. This prevents an error when e.g.
>> 'flyspell-auto-correct-word' gets called with point at the
>> beginning of the buffer.
>> ---
>> lisp/textmodes/flyspell.el | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
>> index d18916dfd0..e711fe72b2 100644
>> --- a/lisp/textmodes/flyspell.el
>> +++ b/lisp/textmodes/flyspell.el
>> @@ -424,8 +424,9 @@ like <img alt=\"Some thing.\">."
>> (defun flyspell-generic-progmode-verify ()
>> "Used for `flyspell-generic-check-word-predicate' in programming modes."
>> ;; (point) is next char after the word. Must check one char before.
>> - (let ((f (get-text-property (- (point) 1) 'face)))
>> - (memq f flyspell-prog-text-faces)))
>> + (unless (bobp)
>> + (let ((f (get-text-property (- (point) 1) 'face)))
>> + (memq f flyspell-prog-text-faces))))
>
> Maybe it's just me, but whenever I see bobp, I always have to consult
> the docs regarding what happens in a narrowed buffer. For that
> reason, I prefer comparison with point-min instead.
>
> Am I the only one troubled by that?
I wouldn't say I'm troubled by what bobp does in a narrowed buffer
(I would expect it to heed buffer restrictions).
Rather, bobp conveys only some property of current state, whereas
explicit comparisons to point-min such as (> (point) (point-min)) or
(max (point-min) (1- (point))) additionally suggest that subsequent
buffer position operations are being guarded from out-of-bounds errors.
But that's just my reading into the distinction, so it probably comes
down to taste and habits.
--
Basil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Tue, 11 Jun 2019 14:13:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 35967 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> + (unless (bobp)
>> + (let ((f (get-text-property (- (point) 1) 'face)))
>> + (memq f flyspell-prog-text-faces))))
>
> Thanks.
>
> Maybe it's just me, but whenever I see bobp, I always have to consult
> the docs regarding what happens in a narrowed buffer. For that
> reason, I prefer comparison with point-min instead.
>
> Am I the only one troubled by that?
It doesn't take too long to check the docstring, does it? And it seems
fairly easy to remember that bobp should treat a narrowed buffer the
same way that beginning-of-buffer will.
My only complaint about bobp is that it's abbreviated perhaps a little
too far, to the point of obscurity. As in, who is "bob" and why are we
asking about him?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Tue, 11 Jun 2019 14:40:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 35967 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> gmail.com
> Cc: Alex Branham <alex.branham <at> gmail.com>, 35967 <at> debbugs.gnu.org
> Date: Tue, 11 Jun 2019 10:12:12 -0400
>
> it seems fairly easy to remember that bobp should treat a narrowed
> buffer the same way that beginning-of-buffer will.
Not for this old curmudgeon, evidently.
> My only complaint about bobp is that it's abbreviated perhaps a little
> too far, to the point of obscurity. As in, who is "bob" and why are we
> asking about him?
That question has a known answer: Bob's your uncle.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Fri, 14 Jun 2019 18:18:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 35967 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue 11 Jun 2019 at 09:39, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: npostavs <at> gmail.com
>> Cc: Alex Branham <alex.branham <at> gmail.com>, 35967 <at> debbugs.gnu.org
>> Date: Tue, 11 Jun 2019 10:12:12 -0400
>>
>> it seems fairly easy to remember that bobp should treat a narrowed
>> buffer the same way that beginning-of-buffer will.
>
> Not for this old curmudgeon, evidently.
Here's a new patch that checks for (equal (point) 1) rather than using
bobp. OK to push to master?
Alex
[0001-Avoid-a-flyspell-error-if-point-is-at-beginning-of-b.patch (text/x-patch, inline)]
From c7d7ccaf5b94a1146e4664ec21564f982686fcab Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham <at> gmail.com>
Date: Fri, 14 Jun 2019 13:15:36 -0500
Subject: [PATCH] Avoid a flyspell error if point is at beginning of buffer
* lisp/textmodes/flyspell.el (flyspell-generic-progmode-verify): Check
if point is at the beginning of the buffer. This prevents an error
when e.g. 'flyspell-auto-correct-word' gets called with point at the
beginning of the buffer.
---
lisp/textmodes/flyspell.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index d18916dfd0..7237a0f8ab 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -423,9 +423,10 @@ flyspell-prog-text-faces
(defun flyspell-generic-progmode-verify ()
"Used for `flyspell-generic-check-word-predicate' in programming modes."
- ;; (point) is next char after the word. Must check one char before.
- (let ((f (get-text-property (- (point) 1) 'face)))
- (memq f flyspell-prog-text-faces)))
+ (unless (eql (point) 1)
+ ;; (point) is next char after the word. Must check one char before.
+ (let ((f (get-text-property (- (point) 1) 'face)))
+ (memq f flyspell-prog-text-faces))))
;; Records the binding of M-TAB in effect before flyspell was activated.
(defvar flyspell--prev-meta-tab-binding)
--
2.21.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Fri, 14 Jun 2019 18:33:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 35967 <at> debbugs.gnu.org (full text, mbox):
Alex Branham <alex.branham <at> gmail.com> writes:
> Here's a new patch that checks for (equal (point) 1) rather than using
> bobp. OK to push to master?
> + (unless (eql (point) 1)
> + ;; (point) is next char after the word. Must check one char before.
> + (let ((f (get-text-property (- (point) 1) 'face)))
This will do the wrong thing when point is at the beginning of a
narrowed buffer. Score one point for bobp?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Fri, 14 Jun 2019 18:42:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 35967 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Fri 14 Jun 2019 at 13:31, npostavs <at> gmail.com wrote:
> Alex Branham <alex.branham <at> gmail.com> writes:
>
>> Here's a new patch that checks for (equal (point) 1) rather than using
>> bobp. OK to push to master?
>
>> + (unless (eql (point) 1)
>> + ;; (point) is next char after the word. Must check one char before.
>> + (let ((f (get-text-property (- (point) 1) 'face)))
>
> This will do the wrong thing when point is at the beginning of a
> narrowed buffer. Score one point for bobp?
Oh, of course. Here it is with (point-min), which should work I think.
Alex
[0001-Avoid-a-flyspell-error-if-point-is-at-beginning-of-b.patch (text/x-patch, inline)]
From f4ecc0a1657e736173f6daeabbe870dae4e8a7f1 Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham <at> gmail.com>
Date: Fri, 14 Jun 2019 13:15:36 -0500
Subject: [PATCH] Avoid a flyspell error if point is at beginning of buffer
* lisp/textmodes/flyspell.el (flyspell-generic-progmode-verify): Check
if point is at the beginning of the buffer. This prevents an error
when e.g. 'flyspell-auto-correct-word' gets called with point at the
beginning of the buffer.
---
lisp/textmodes/flyspell.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index d18916dfd0..22f9db4363 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -423,9 +423,10 @@ flyspell-prog-text-faces
(defun flyspell-generic-progmode-verify ()
"Used for `flyspell-generic-check-word-predicate' in programming modes."
- ;; (point) is next char after the word. Must check one char before.
- (let ((f (get-text-property (- (point) 1) 'face)))
- (memq f flyspell-prog-text-faces)))
+ (unless (eql (point) (point-min))
+ ;; (point) is next char after the word. Must check one char before.
+ (let ((f (get-text-property (- (point) 1) 'face)))
+ (memq f flyspell-prog-text-faces))))
;; Records the binding of M-TAB in effect before flyspell was activated.
(defvar flyspell--prev-meta-tab-binding)
--
2.21.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Fri, 14 Jun 2019 19:15:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 35967 <at> debbugs.gnu.org (full text, mbox):
On Jun 14 2019, Alex Branham <alex.branham <at> gmail.com> wrote:
> diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
> index d18916dfd0..22f9db4363 100644
> --- a/lisp/textmodes/flyspell.el
> +++ b/lisp/textmodes/flyspell.el
> @@ -423,9 +423,10 @@ flyspell-prog-text-faces
>
> (defun flyspell-generic-progmode-verify ()
> "Used for `flyspell-generic-check-word-predicate' in programming modes."
> - ;; (point) is next char after the word. Must check one char before.
> - (let ((f (get-text-property (- (point) 1) 'face)))
> - (memq f flyspell-prog-text-faces)))
> + (unless (eql (point) (point-min))
> + ;; (point) is next char after the word. Must check one char before.
> + (let ((f (get-text-property (- (point) 1) 'face)))
Perhaps change this to (1- (point)).
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Reply sent
to
Alex Branham <alex.branham <at> gmail.com>
:
You have taken responsibility.
(Mon, 17 Jun 2019 19:06:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alex Branham <alex.branham <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 17 Jun 2019 19:06:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 35967-done <at> debbugs.gnu.org (full text, mbox):
On Fri 14 Jun 2019 at 14:14, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
>> + (let ((f (get-text-property (- (point) 1) 'face)))
>
> Perhaps change this to (1- (point)).
Thanks, I made that change and pushed as 1942f4ccba52896e3e97789dc6b51926ad74c591 on the master branch.
Alex
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35967
; Package
emacs
.
(Tue, 18 Jun 2019 12:20:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 35967 <at> debbugs.gnu.org (full text, mbox):
> Am I the only one troubled by that?
I find it a lot more clear than (eq (point) (point-min)).
But if we start avoiding `bobp`, we should then tweak the byte-compiler to
turn (eq (point) (point-min)) into `bobp` for us.
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 17 Jul 2019 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 56 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.