Subject: bug#76494: closed (Re: bug#76494: [PATCH] Highlight fill-column-indicator when current line is longer than `fill-column')

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 09 Mar 2025 09:22:02 +0000

Your bug report

#76494: [PATCH] Highlight fill-column-indicator when current line is longer than `fill-column'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
76494: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76494
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current line is longer than `fill-column'
From: Eli Zaretskii <[email-masked]>
To: Elijah Gabe Pérez <[email-masked]>
Cc: [email-masked]
Date: Sun, 09 Mar 2025 11:21:40 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Elijah Gabe Pérez <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 23 Feb 2025 01:11:43 -0600
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > I see your change adds a post-command-hook, but when and how is that
> > hook removed?
> 
> The hook is removed when display-fill-column-indicator-mode is turn-off,
> i forgot to remove the hook in the submitted patch, I've fixed it.
> 
> >> I also wanted to do the same for indicator character but I couldn't find
> >> a way to implement it.
> >
> > What do you mean by "indicator character"?
> 
> i meant `display-fill-column-indicator-character', I wanted to
> allow changing its character to a custom one.
> 
> example: use this `┃' character (or one chosen by the user)
> instead default `│' when changing the fill-column-indicator face.
> 
> >> +(defcustom display-fill-column-indicator-warning nil
> >> +  "Highlight fill-column-indicator when cursor is above `fill-column'.
> >> +Non-nil means highlight fill-column-indicator when cursor is
> >> +above `fill-column'."
> >> +  :type 'boolean)
> >
> > This lacks a :version tag.
> >
> > Also, what do you mean by "cursor is above `fill-column'"?  The
> > "above" part confuses me.
> 
> I updated the patch to clarify this part.

Thanks, installed on the master branch, and closing the bug.

Subject: [PATCH] Highlight fill-column-indicator when current line is longer than `fill-column'
From: Elijah Gabe Pérez <[email-masked]>
To: [email-masked]
Date: Sat, 22 Feb 2025 22:21:02 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

This patch allow warn to user if current line exceeds
display-fill-column-indicator-column.

When current line exceeds display-fill-column-indicator-column ...
                                           |
(print "......................................")
                                           |
... fill-column indicator face will change ^
temporarily to a noticeable face to warn the user that the current
column is getting too long.

I also wanted to do the same for indicator character but I couldn't find
a way to implement it.

(I hope this feature has been understood)

>From 4f608bb7dbb23b812284fada179a38485e660a9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Sat, 22 Feb 2025 12:19:07 -0600
Subject: [PATCH] Highlight fill-column-indicator when current line is longer
 than ...

... `fill-column'

* lisp/display-fill-column-indicator.el
(display-fill-column-indicator-warning): New use-option.
(display-fill-column-indicator-warning-face): New face.
(display-fill-column-indicator-mode):
Add `display-fill-column-indicator-warning'.
---
 lisp/display-fill-column-indicator.el | 29 ++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el
index c55a03533bd..ca4b51fab2a 100644
--- a/lisp/display-fill-column-indicator.el
+++ b/lisp/display-fill-column-indicator.el
@@ -42,6 +42,15 @@ display-fill-column-indicator
   :group 'display
   :link '(info-link "(emacs)Displaying Boundaries"))
 
+(defcustom display-fill-column-indicator-warning nil
+  "Highlight fill-column-indicator when cursor is above `fill-column'.
+Non-nil means highlight fill-column-indicator when cursor is
+above `fill-column'."
+  :type 'boolean)
+
+(defface display-fill-column-indicator-warning-face
+  '((t :inherit error :stipple nil))
+  "Face used to highlight fill-column-indicator when the line is too long.")
 
 ;;;###autoload
 (define-minor-mode display-fill-column-indicator-mode
@@ -68,7 +77,25 @@ display-fill-column-indicator-mode
                              (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0)
                                  (face-font 'default))))
                     ?\u2502
-                  ?|))))
+                  ?|)))
+
+        (if display-fill-column-indicator-warning
+            (add-hook
+             'post-command-hook
+             (lambda ()
+               (if-let* ((column (if (numberp display-fill-column-indicator-column)
+                                     display-fill-column-indicator-column
+                                   fill-column))
+                         ((> (save-excursion (end-of-line) (current-column))
+                             column)))
+                   (progn
+                     (face-remap-set-base
+                      'fill-column-indicator
+                      'display-fill-column-indicator-warning-face))
+                 (face-remap-reset-base 'fill-column-indicator)))
+             nil t)
+          )
+        )
     (setq display-fill-column-indicator nil)))
 
 (defun display-fill-column-indicator--turn-on ()
-- 
2.48.1

-- 
                                                   - E.G via GNU Emacs.