From: Dima Kogan <dima@secretsauce.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 20498@debbugs.gnu.org
Subject: bug#20498: 25.0.50; PATCH: break potential infinite loop in (line-move-to-column)
Date: Tue, 05 May 2015 01:29:14 -0700 [thread overview]
Message-ID: <87383b5s9z.fsf@secretsauce.net> (raw)
In-Reply-To: <834mnsto2o.fsf@gnu.org>
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Dima Kogan <dima@secretsauce.net>
>> Date: Sun, 03 May 2015 12:32:33 -0700
>>
>> (line-move-to-column) has a loop that can become infinite:
>>
>> (while (and ...)
>> (goto-char (previous-char-property-change (point) line-beg)))
>>
>> If (= (point) line-beg) then the (goto-char) does nothing, and the
>> condition in the while never changes.
>
> The full fragment is this:
>
> (let ((line-beg (line-beginning-position)))
> (while (and (not (bolp)) (invisible-p (1- (point))))
> (goto-char (previous-char-property-change (point) line-beg))))))))
>
> So if (= (point) line-beg), then 'bolp' will return t, and we will
> break from the loop. Am I missing something?
>
>> I'm seeing this in the wild with ERC and erc-fill-mode disabled.
>
> Can you dig deeper into the problem, and tell the details about this
> infloop?
Hi. Thank you very much for double-checking. It indeed looks like (bolp)
should cover this case. It doesn't however. When ERC misbehaves in this
way I observe both
(= (line-beginning-position) (point)) --> t
(bolp) --> nil
This sounds wrong. Looking at the buffer with my eyes, the point is not
at the beginning of the line, so it LOOKS like the (bolp) result is
correct.
The docs for (line-beginning-position) state that this function respects
field boundaries. If I ignore those explicitly then I see the correct
behavior:
(let ((inhibit-field-text-motion t))
(line-beginning-position)) ---> correct start of line
So the correct patch would replace (line-beginning-position) to the
above expression. This is trivial, and I'm not actually attaching a
patch. If you want me to, tell me.
(line-beginning-position) is used in quite a few places in emacs, and
I'm wondering if in many of those uses the intent is to ignore fields.
next prev parent reply other threads:[~2015-05-05 8:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-03 19:32 bug#20498: 25.0.50; PATCH: break potential infinite loop in (line-move-to-column) Dima Kogan
2015-05-04 14:27 ` Eli Zaretskii
2015-05-05 8:29 ` Dima Kogan [this message]
2015-05-09 13:08 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87383b5s9z.fsf@secretsauce.net \
--to=dima@secretsauce.net \
--cc=20498@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.