GNU bug report logs - #35898
26.1; line-beginning-position sometimes does not yield line beginning position

Previous Next

Package: emacs;

Reported by: Markus Triska <triska <at> metalevel.at>

Date: Sat, 25 May 2019 13:25:01 UTC

Severity: normal

Tags: notabug

Found in version 26.1

Done: Stefan Kangas <stefan <at> marxist.se>

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 35898 in the body.
You can then email your comments to 35898 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35898; Package emacs. (Sat, 25 May 2019 13:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <triska <at> metalevel.at>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 25 May 2019 13:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Markus Triska <triska <at> metalevel.at>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; line-beginning-position sometimes does not yield line beginning
 position
Date: Sat, 25 May 2019 15:23:48 +0200
Please download hello.png with:

    $ wget https://www.metalevel.at/ei/hello.png

and then, starting Emacs with "emacs -Q", evaluate the following form:

    (progn
      (goto-char (point-min))
      (save-excursion (insert "\n"))
      (goto-char (+ (point) (cadr (insert-image-file "hello.png"))))
      (line-beginning-position))

This yields 592, whereas I expect it to yield 1.

For comparison, when I do C-a to move to the beginning of the line, it
moves to position 1, as expected.

Is there a way to make line-beginning-position yield the line beginning
position in cases like this? Would you please consider adding this feature?

Thank you and all the best,
Markus

In GNU Emacs 26.1 (build 3, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2019-04-09 built on mt-laptop
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35898; Package emacs. (Sat, 25 May 2019 14:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 35898 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Markus Triska <triska <at> metalevel.at>
Cc: 35898 <at> debbugs.gnu.org
Subject: Re: bug#35898: 26.1;
 line-beginning-position sometimes does not yield line beginning
 position
Date: Sat, 25 May 2019 17:01:01 +0300
> From: Markus Triska <triska <at> metalevel.at>
> Date: Sat, 25 May 2019 15:23:48 +0200
> 
>     $ wget https://www.metalevel.at/ei/hello.png
> 
> and then, starting Emacs with "emacs -Q", evaluate the following form:
> 
>     (progn
>       (goto-char (point-min))
>       (save-excursion (insert "\n"))
>       (goto-char (+ (point) (cadr (insert-image-file "hello.png"))))
>       (line-beginning-position))
> 
> This yields 592, whereas I expect it to yield 1.

Your expectations are unjustified, because line-beginning-position is
not supposed to work on visual lines, it works on logical/physical
lines, i.e. it scans the buffer for newline characters.

For visual-line operation, you can use either beginning-of-visual-line
or vertical-motion (the former actually calls the latter internally).

> Is there a way to make line-beginning-position yield the line beginning
> position in cases like this? Would you please consider adding this feature?

We already have features to query about the visual lines, so I don't
see why we would need line-beginning-position work in terms of visual
lines.  It will fail Lisp programs that want to disregard the visual
appearance of the buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35898; Package emacs. (Wed, 26 Aug 2020 00:58:02 GMT) Full text and rfc822 format available.

Message #11 received at 35898 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 35898 <at> debbugs.gnu.org, Markus Triska <triska <at> metalevel.at>
Subject: Re: bug#35898: 26.1; line-beginning-position sometimes does not yield
 line beginning position
Date: Tue, 25 Aug 2020 17:57:05 -0700
tags 35898 + notabug
close 35898
thanks

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Markus Triska <triska <at> metalevel.at>
>> Date: Sat, 25 May 2019 15:23:48 +0200
>>
>>     $ wget https://www.metalevel.at/ei/hello.png
>>
>> and then, starting Emacs with "emacs -Q", evaluate the following form:
>>
>>     (progn
>>       (goto-char (point-min))
>>       (save-excursion (insert "\n"))
>>       (goto-char (+ (point) (cadr (insert-image-file "hello.png"))))
>>       (line-beginning-position))
>>
>> This yields 592, whereas I expect it to yield 1.
>
> Your expectations are unjustified, because line-beginning-position is
> not supposed to work on visual lines, it works on logical/physical
> lines, i.e. it scans the buffer for newline characters.
>
> For visual-line operation, you can use either beginning-of-visual-line
> or vertical-motion (the former actually calls the latter internally).
>
>> Is there a way to make line-beginning-position yield the line beginning
>> position in cases like this? Would you please consider adding this feature?
>
> We already have features to query about the visual lines, so I don't
> see why we would need line-beginning-position work in terms of visual
> lines.  It will fail Lisp programs that want to disregard the visual
> appearance of the buffer.

As Eli has correctly explained, this is the expected behaviour.  So I'm
therefore closing this bug report.

If this conclusion is incorrect, please reply to this email (use "Reply
to all" in your email client) and we can reopen the bug report.

Best regards,
Stefan Kangas




Added tag(s) notabug. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 26 Aug 2020 00:58:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 35898 <at> debbugs.gnu.org and Markus Triska <triska <at> metalevel.at> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 26 Aug 2020 00:58:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 23 Sep 2020 11:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 214 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.