Subject: bug#77544: (WIP) [PATCH] Prettify page separators.

From: Elijah Gabe Pérez <[email-masked]>
Date: Fri, 04 Apr 2025 23:01:02 -0600

Tags: patch

This feature prettify the page separator character (^L) with
a horizontal line (to end of buffer) only if the character
is at beginning of line.

Unlike popular packages like page-break-lines and form-feed(-st), this
one is written in C and does not present performance problems (I hope).

This package tries to be close to page-break-lines and be an alternative
to make-separator-line.

This partially works, however there are a few bugs that I can't find a
solution for:

- It won't display the characters inserted in front.
  I want to make it similar to display-fill-column, that only
  insert the horizontal line character if the row is empty.
- For some reason it inserts newlines after inserting the character.
- The highlighting stops when inserting or deleting newlines from
  previous or next line.

I would like to hear your suggestions.

Thanks.

>From 1e058cc212fd5b46b2aed60b3ef3846f7a89bb15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Fri, 4 Apr 2025 22:17:23 -0600
Subject: [PATCH] Prettify page separators.  (bug#)

Prettify page separator characters (^L) with a horizontal line.

* src/xdisp.c (get_next_display_element): TODO:
---
 src/xdisp.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index c396b213b92..9d5056d2bce 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8430,6 +8430,34 @@ get_next_display_element (struct it *it)
 	      int lface_id = 0;
 	      int escape_glyph;
 
+	      if (c == '\f' && it->current_x == it->first_visible_x)
+		{
+		  const int save_face_id = it->face_id;
+		  const int save_char = it->char_to_display;
+		  const int save_current_x = it->current_x;
+		  const int save_ascent = it->ascent;
+		  const int save_descent = it->descent;
+
+		  face_id =
+		    merge_faces (it->w, Qtrailing_whitespace, 0, it->face_id);
+		  XSETINT (it->ctl_chars[0], 0);
+		  ctl_len = 0;
+
+		  it->char_to_display = '-';
+		  it->face_id = face_id;
+		  for ( ; it->current_x - it->end_charpos <= it->last_visible_x; it->current_x++)
+		    {
+		      PRODUCE_GLYPHS (it);
+		    }
+
+		  it->current_x = save_current_x;
+		  it->face_id = save_face_id;
+		  it->char_to_display = save_char;
+		  it->ascent = save_ascent;
+		  it->descent = save_descent;
+		  goto display_control;
+		}
+
 	      /* Handle control characters with ^.  */
 
 	      if (ASCII_CHAR_P (c) && it->ctl_arrow_p)
-- 
2.49.0

-- 
                                          - E.G via GNU Emacs and Org.