* what-page and first line of page?
@ 2009-09-14 10:42 Mario Lang
2009-09-15 1:22 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Mario Lang @ 2009-09-14 10:42 UTC (permalink / raw
To: emacs-devel
Hi.
I am editiing a long document where original page numbers are important.
When I use `what-page' to see to which physical page the position
of point currently corresponds, I notice that it does not
work on the first line which starts with ^L. I.e.:
line 1 or page 1
\fline 2 of page 1
line 1 of page 2
To make `what-page' return the correct page number I either
always have to immediately follow ^L with a newline, or
remove `beginning-of-line' in the definition of `what-page':
(defun what-page ()
"Print page and line number of point."
(interactive)
(save-restriction
(widen)
(save-excursion
;(beginning-of-line)
(let ((count 1)
(opoint (point)))
(goto-char 1)
(while (re-search-forward page-delimiter opoint t)
(setq count (1+ count)))
(message "Page %d, line %d"
count
(1+ (count-lines (point) opoint)))))))
I am arguing this is a bug. Does anyone know why
the `beginning-of-line' is actually in there?
--
CYa,
⡍⠁⠗⠊⠕
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: what-page and first line of page?
2009-09-14 10:42 what-page and first line of page? Mario Lang
@ 2009-09-15 1:22 ` Stefan Monnier
2009-09-16 11:15 ` bug#4445: " Juanma Barranquero
2009-09-16 11:15 ` Juanma Barranquero
0 siblings, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2009-09-15 1:22 UTC (permalink / raw
To: Mario Lang; +Cc: emacs-devel
> To make `what-page' return the correct page number I either
> always have to immediately follow ^L with a newline, or
> remove `beginning-of-line' in the definition of `what-page':
I removed the beginning-of-line (has been there since the original
commit 1.1 in 1989). BTW, such reports should be sent to the
bug-tracker rather than to emacs-devel.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4445: what-page and first line of page?
2009-09-15 1:22 ` Stefan Monnier
@ 2009-09-16 11:15 ` Juanma Barranquero
2009-09-16 11:15 ` Juanma Barranquero
1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2009-09-16 11:15 UTC (permalink / raw
To: Stefan Monnier; +Cc: Mario Lang, Emacs Bug Tracker, emacs-devel
On Tue, Sep 15, 2009 at 03:22, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> I removed the beginning-of-line (has been there since the original
> commit 1.1 in 1989).
Strangely enough, that `beginning-of-line' somewhat masked a bug in
`what-page' that happens when `re-search-forward' matches but does not
move the point.
For example,
emacs -Q lisp/ChangeLog
M-x what-page <RET> => "Page 1, line 1"
but
emacs -Q lisp/ChangeLog
<right>
M-x what-page <RET> => loops until C-g
This happens in ChangeLog files because `page-delimiter' has the value
"^\\<\\|^\f", which matches the empty string at the beginning of the
buffer.
I said the change "somewhat masked" the bug because before it, when
the point was on the first line of a ChangeLog, opoint was 1 (because
of the beginning-of-line), so the match failed and `what-page'
terminated. It only looped from line 2 on, while now it loops from
point 2 on.
Juanma
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: what-page and first line of page?
2009-09-15 1:22 ` Stefan Monnier
2009-09-16 11:15 ` bug#4445: " Juanma Barranquero
@ 2009-09-16 11:15 ` Juanma Barranquero
2009-09-16 13:15 ` bug#4447: " Stefan Monnier
2009-09-16 13:15 ` Stefan Monnier
1 sibling, 2 replies; 8+ messages in thread
From: Juanma Barranquero @ 2009-09-16 11:15 UTC (permalink / raw
To: Stefan Monnier; +Cc: Mario Lang, Emacs Bug Tracker, emacs-devel
On Tue, Sep 15, 2009 at 03:22, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> I removed the beginning-of-line (has been there since the original
> commit 1.1 in 1989).
Strangely enough, that `beginning-of-line' somewhat masked a bug in
`what-page' that happens when `re-search-forward' matches but does not
move the point.
For example,
emacs -Q lisp/ChangeLog
M-x what-page <RET> => "Page 1, line 1"
but
emacs -Q lisp/ChangeLog
<right>
M-x what-page <RET> => loops until C-g
This happens in ChangeLog files because `page-delimiter' has the value
"^\\<\\|^\f", which matches the empty string at the beginning of the
buffer.
I said the change "somewhat masked" the bug because before it, when
the point was on the first line of a ChangeLog, opoint was 1 (because
of the beginning-of-line), so the match failed and `what-page'
terminated. It only looped from line 2 on, while now it loops from
point 2 on.
Juanma
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4447: what-page and first line of page?
2009-09-16 11:15 ` Juanma Barranquero
@ 2009-09-16 13:15 ` Stefan Monnier
2009-09-16 13:15 ` Stefan Monnier
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2009-09-16 13:15 UTC (permalink / raw
To: Juanma Barranquero; +Cc: Mario Lang, Emacs Bug Tracker, emacs-devel
> Strangely enough, that `beginning-of-line' somewhat masked a bug in
> `what-page' that happens when `re-search-forward' matches but does not
> move the point.
Thanks, fixed,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: what-page and first line of page?
2009-09-16 11:15 ` Juanma Barranquero
2009-09-16 13:15 ` bug#4447: " Stefan Monnier
@ 2009-09-16 13:15 ` Stefan Monnier
2009-09-16 13:36 ` bug#4445: " Juanma Barranquero
2009-09-16 13:36 ` Juanma Barranquero
1 sibling, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2009-09-16 13:15 UTC (permalink / raw
To: Juanma Barranquero; +Cc: Mario Lang, Emacs Bug Tracker, emacs-devel
> Strangely enough, that `beginning-of-line' somewhat masked a bug in
> `what-page' that happens when `re-search-forward' matches but does not
> move the point.
Thanks, fixed,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4445: what-page and first line of page?
2009-09-16 13:15 ` Stefan Monnier
@ 2009-09-16 13:36 ` Juanma Barranquero
2009-09-16 13:36 ` Juanma Barranquero
1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2009-09-16 13:36 UTC (permalink / raw
To: Stefan Monnier; +Cc: Mario Lang, 4445, Emacs developers
On Wed, Sep 16, 2009 at 15:15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Thanks, fixed,
Not yet, I think.
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 1, line 1
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 2, line 1
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 2, line 2
though I'd say that's a problem with the `page-delimiter' regexp for
change-log-mode, not with `what-page' itself.
Juanma
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: what-page and first line of page?
2009-09-16 13:15 ` Stefan Monnier
2009-09-16 13:36 ` bug#4445: " Juanma Barranquero
@ 2009-09-16 13:36 ` Juanma Barranquero
1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2009-09-16 13:36 UTC (permalink / raw
To: Stefan Monnier; +Cc: Mario Lang, 4445, Emacs developers
On Wed, Sep 16, 2009 at 15:15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Thanks, fixed,
Not yet, I think.
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 1, line 1
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 2, line 1
2009-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
^
Page 2, line 2
though I'd say that's a problem with the `page-delimiter' regexp for
change-log-mode, not with `what-page' itself.
Juanma
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-09-16 13:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-14 10:42 what-page and first line of page? Mario Lang
2009-09-15 1:22 ` Stefan Monnier
2009-09-16 11:15 ` bug#4445: " Juanma Barranquero
2009-09-16 11:15 ` Juanma Barranquero
2009-09-16 13:15 ` bug#4447: " Stefan Monnier
2009-09-16 13:15 ` Stefan Monnier
2009-09-16 13:36 ` bug#4445: " Juanma Barranquero
2009-09-16 13:36 ` Juanma Barranquero
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.