el/dot-emacs.el: Fix page motion properly.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 25 Apr 2020 22:07:05 +0000 (23:07 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 25 Apr 2020 22:07:05 +0000 (23:07 +0100)
Emacs's built-in page motion machinery wants pages to start /after/ the
delimiter, but since I'm looking for page-heading banners, I want the
page to start /before/ the banner.  So add some advice so that Emacs
does the right thing.

el/dot-emacs.el

index 8ac22bb..0ff628b 100644 (file)
@@ -169,6 +169,17 @@ library."
     (set-frame-parameter frame 'menu-bar-lines 0)
     (set-frame-parameter frame 'menu-bar-lines old)))
 
+;; Page motion.
+
+(defun mdw-fixup-page-position ()
+  (unless (eq (char-before (point)) ?\f)
+    (forward-line 0)))
+
+(defadvice backward-page (after mdw-fixup compile activate)
+  (mdw-fixup-page-position))
+(defadvice forward-page (after mdw-fixup compile activate)
+  (mdw-fixup-page-position))
+
 ;; Splitting windows.
 
 (unless (fboundp 'scroll-bar-columns)