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.
Full log
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
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.