Subject: page.el (forward-page): Avoid skipping pages

From: Pierre Neidhardt <[email-masked]>
Date: Tue, 26 May 2015 19:14:40 +0200

When `page-delimiter` starts at the beginning of the line and the position is
also at the beginning of the line, calling `forward-page` will skip one page.

Running `emacs -Q example.txt`:

	M-<
	C-x n p
	M->
	M-1 C-x n p

This should bring us from page 1 to page 2, but page 3 gets displayed instead.

The attached patch fixes it by changing the code to actually match its
surrounding comments.

In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.2)
 of 2015-04-20 on bitzer.hoetzel.info
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
System Description:	Arch Linux

Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LC_MESSAGES: sv_SE.UTF-8
  value of $LANG: sv_SE.UTF-8
  locale-coding-system: utf-8-unix

-- 
Pierre Neidhardt

Virginia law forbids bathtubs in the house; tubs must be kept in the yard.
diff --git a/lisp/textmodes/page.el b/lisp/textmodes/page.el
index 39db5bb..c875a49 100644
--- a/lisp/textmodes/page.el
+++ b/lisp/textmodes/page.el
@@ -37,7 +37,7 @@ A page boundary is any line whose beginning matches the regexp
   (while (and (> count 0) (not (eobp)))
     ;; In case the page-delimiter matches the null string,
     ;; don't find a match without moving.
-    (if (bolp) (forward-char 1))
+    (if (string= page-delimiter "") (forward-char 1))
     (if (re-search-forward page-delimiter nil t)
 	nil
       (goto-char (point-max)))