all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
@ 2019-05-28 12:40 Stefan Kangas
  2019-05-28 12:49 ` Noam Postavsky
  2019-05-28 20:25 ` Juri Linkov
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-05-28 12:40 UTC (permalink / raw)
  To: 35943

There seems to be an off by one error in `count-lines-page'.

Steps to reproduce:

1. Run emacs -Q

2. Evaluate the following in the scratch buffer:

(with-temp-buffer
  (insert "Page 1/3
^L
Page 2/3
^L
Page 3/3")
  (forward-page)
  (count-lines-page))

NB. Convert "^L" to the actual control characters.

3. Result:

"Page has 2 lines (2 + 0)"

4. Expected result:

"Page has 1 lines (1 + 0)"

Thanks,
Stefan Kangas

In GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2019-04-13 built on joffe
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description:    Debian GNU/Linux 9.9 (stretch)





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-28 12:40 bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one) Stefan Kangas
@ 2019-05-28 12:49 ` Noam Postavsky
  2019-05-29  8:43   ` Stefan Kangas
  2019-05-28 20:25 ` Juri Linkov
  1 sibling, 1 reply; 8+ messages in thread
From: Noam Postavsky @ 2019-05-28 12:49 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 35943

Stefan Kangas <stefan@marxist.se> writes:

> NB. Convert "^L" to the actual control characters.

You can use "\C-l" for this.

> 3. Result:
>
> "Page has 2 lines (2 + 0)"
>
> 4. Expected result:
>
> "Page has 1 lines (1 + 0)"

The page starts right after the page separator, so with some more annotation:

(with-temp-buffer
  (insert "Page 1/3 line 1
\C-l page 2, line 1
Page 2/3, line 2
\C-l, page 3, line 1
Page 3/3, line 2")
  (forward-page)
  (count-lines-page))

You can see that pages 2 and 3 both have two lines.






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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-28 12:40 bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one) Stefan Kangas
  2019-05-28 12:49 ` Noam Postavsky
@ 2019-05-28 20:25 ` Juri Linkov
  2019-05-29  9:40   ` Stefan Kangas
  1 sibling, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-05-28 20:25 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 35943

> 3. Result:
>
> "Page has 2 lines (2 + 0)"
>
> 4. Expected result:
>
> "Page has 1 lines (1 + 0)"
            =======

BTW, this message is grammatically incorrect.  It uses plural form
for singular amount.  It should use `ngettext' to get the correct word.





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-28 12:49 ` Noam Postavsky
@ 2019-05-29  8:43   ` Stefan Kangas
  2019-05-29 11:17     ` Noam Postavsky
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2019-05-29  8:43 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 35943

close 35943
thanks

Noam Postavsky <npostavs@gmail.com> writes:
>
> Stefan Kangas <stefan@marxist.se> writes:
>
> > NB. Convert "^L" to the actual control characters.
>
> You can use "\C-l" for this.

Noted, thanks.

> You can see that pages 2 and 3 both have two lines.

Yes, this is the semantic I found counter-intuitive.  I might be the exception
here though, so I'm closing the bug.  Thanks for taking the time to comment, and
sorry about the noise.

Best regards,
Stefan Kangas





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-28 20:25 ` Juri Linkov
@ 2019-05-29  9:40   ` Stefan Kangas
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-05-29  9:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 35943

Juri Linkov <juri@linkov.net> writes:
> > "Page has 1 lines (1 + 0)"
>             =======
>
> BTW, this message is grammatically incorrect.  It uses plural form
> for singular amount.  It should use `ngettext' to get the correct word.

Thanks, I submitted the following bug report with a patch to fix this:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35981

Best regards,
Stefan Kangas





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-29  8:43   ` Stefan Kangas
@ 2019-05-29 11:17     ` Noam Postavsky
  2019-05-29 11:41       ` Stefan Kangas
  2019-05-29 13:50       ` Drew Adams
  0 siblings, 2 replies; 8+ messages in thread
From: Noam Postavsky @ 2019-05-29 11:17 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 35943

retitle 35943 page-delimiter doesn't include the newline by default
quit

Stefan Kangas <stefan@marxist.se> writes:

>> You can see that pages 2 and 3 both have two lines.
>
> Yes, this is the semantic I found counter-intuitive.  I might be the exception
> here though, so I'm closing the bug.

You can get the semantics you want by changing page-delimiter to include
the newline:

(setq page-delimiter "^\C-l\n")





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-29 11:17     ` Noam Postavsky
@ 2019-05-29 11:41       ` Stefan Kangas
  2019-05-29 13:50       ` Drew Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-05-29 11:41 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 35943

Noam Postavsky <npostavs@gmail.com> writes:
> You can get the semantics you want by changing page-delimiter to include
> the newline:

I had missed that, thanks for pointing it out.

Best regards,
Stefan Kangas





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

* bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one)
  2019-05-29 11:17     ` Noam Postavsky
  2019-05-29 11:41       ` Stefan Kangas
@ 2019-05-29 13:50       ` Drew Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Drew Adams @ 2019-05-29 13:50 UTC (permalink / raw)
  To: Noam Postavsky, Stefan Kangas; +Cc: 35943

> retitle 35943 page-delimiter doesn't include the newline by default

FWIW, I don't think page-delimiter should include the
newline by default.  It has long not included it, and
there are certainly both existing code and user habits
and expectations that depend on the longstanding default
behavior. Also, a form-feed char (^L) is traditionally
a/the page delimiter.

And as Noam points out, users can customize
`page-delimiter'.  The default value should not be
changed.





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

end of thread, other threads:[~2019-05-29 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-28 12:40 bug#35943: 26.2; `count-lines-page' gives wrong line count (off by one) Stefan Kangas
2019-05-28 12:49 ` Noam Postavsky
2019-05-29  8:43   ` Stefan Kangas
2019-05-29 11:17     ` Noam Postavsky
2019-05-29 11:41       ` Stefan Kangas
2019-05-29 13:50       ` Drew Adams
2019-05-28 20:25 ` Juri Linkov
2019-05-29  9:40   ` Stefan Kangas

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.