GNU bug report logs - #76494
[PATCH] Highlight fill-column-indicator when current line is longer than `fill-column'

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sun, 23 Feb 2025 04:22:02 UTC

Severity: wishlist

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76494 in the body.
You can then email your comments to 76494 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Sun, 23 Feb 2025 04:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 23 Feb 2025 04:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Highlight fill-column-indicator when current line is longer
 than `fill-column'
Date: Sat, 22 Feb 2025 22:21:02 -0600
[Message part 1 (text/plain, inline)]
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)

[0001-Highlight-fill-column-indicator-when-current-line-is.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
                                                   - E.G via GNU Emacs.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Sun, 23 Feb 2025 06:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Sun, 23 Feb 2025 08:14:56 +0200
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Date: Sat, 22 Feb 2025 22:21:02 -0600
> 
> This patch allow warn to user if current line exceeds
> display-fill-column-indicator-column.

Thanks.

> 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 see your change adds a post-command-hook, but when and how is that
hook removed?

> 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"?

> +(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.

> +(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.")

This should also have a :version tag.  And fill-column-indicator
should be quoted, so that help command produce a cross-reference from
it.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Sun, 23 Feb 2025 07:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Sun, 23 Feb 2025 01:11:43 -0600
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> 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.

[0001-Highlight-fill-column-indicator-when-current-line-is.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]

-- 
                                                   - E.G via GNU Emacs.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Sun, 23 Feb 2025 08:00:02 GMT) Full text and rfc822 format available.

Message #14 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Sun, 23 Feb 2025 09:59:06 +0200
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 76494 <at> debbugs.gnu.org
> Date: Sun, 23 Feb 2025 01:11:43 -0600
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> 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.

The character is the same for all the screen lines, so if you change
it, that affects all the lines.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Mon, 24 Feb 2025 01:16:02 GMT) Full text and rfc822 format available.

Message #17 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Sun, 23 Feb 2025 19:15:07 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

> The character is the same for all the screen lines, so if you change
> it, that affects all the lines.

Not if you use setq-local which prevents this problem,
such as this code:

(add-hook 'display-fill-column-indicator-mode-hook
   (lambda ()
       (add-hook
        'post-command-hook
        (lambda ()
          (if (> (save-excursion (end-of-line) (current-column))
                 fill-column)
              (progn
                (setq-local
                 display-fill-column-indicator-character 9475)
                (face-remap-set-base 'fill-column-indicator
                                     (list :inherit 'error :stipple nil
                                           :box nil :strike-through nil
                                           :overline nil :underline nil)))
            (setq-local
             display-fill-column-indicator-character 9474)
            (face-remap-reset-base 'fill-column-indicator)))
        nil t)))

I couldn't find a way to implement it without it looking terrifying,
so I think I'll just settle with the highlight.

-- 
                                                   - E.G via GNU Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Mon, 24 Feb 2025 12:32:01 GMT) Full text and rfc822 format available.

Message #20 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Mon, 24 Feb 2025 14:31:39 +0200
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 76494 <at> debbugs.gnu.org
> Date: Sun, 23 Feb 2025 19:15:07 -0600
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > The character is the same for all the screen lines, so if you change
> > it, that affects all the lines.
> 
> Not if you use setq-local which prevents this problem,
> such as this code:

There might be some misunderstanding: using setq-local makes the
character local to a buffer, whereas I thought you wanted to use a
special character only for the lines that exceed the fill-column?
When I use your code, then whenever I'm on a line that is too long,
_all_ the fill-column indicators in the window change into the U+2503
character shown in red, not just the indicator of that single line.

Did I misunderstand what you are trying to accomplish?




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 24 Feb 2025 21:52:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76494; Package emacs. (Tue, 25 Feb 2025 03:33:02 GMT) Full text and rfc822 format available.

Message #25 received at 76494 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76494 <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Mon, 24 Feb 2025 21:32:29 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

> There might be some misunderstanding: using setq-local makes the
> character local to a buffer, whereas I thought you wanted to use a
> special character only for the lines that exceed the fill-column?

Even if I wanted to, that wouldn't be possible because of the way
display-fill-column-indicator is designed.

> When I use your code, then whenever I'm on a line that is too long,
> _all_ the fill-column indicators in the window change into the U+2503
> character shown in red, not just the indicator of that single line.

Yeah, that's correct, affects the entire indicator.


something like this:

                                           │
                                           │
                                           │
(print "..|........................")      │
          ^ (cursor)                       │
(print "---")                              │
                                           │
                                 indicator ^

                                           ┃
                                           ┃
                                           ┃
(print "...............|........................")
                       ^ (cursor)          ┃
(print "---")                              ┃
                                           ┃
                                 indicator ^

                                           │
                                           │
                                           │
(print ".......................................")
                                           │
(print "---")|                             │
             ^ (cursor)                    │
                                 indicator ^

-- 
                                                   - E.G via GNU Emacs.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sun, 09 Mar 2025 09:22:02 GMT) Full text and rfc822 format available.

Notification sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
bug acknowledged by developer. (Sun, 09 Mar 2025 09:22:02 GMT) Full text and rfc822 format available.

Message #30 received at 76494-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 76494-done <at> debbugs.gnu.org
Subject: Re: bug#76494: [PATCH] Highlight fill-column-indicator when current
 line is longer than `fill-column'
Date: Sun, 09 Mar 2025 11:21:40 +0200
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 76494 <at> debbugs.gnu.org
> Date: Sun, 23 Feb 2025 01:11:43 -0600
> 
> Eli Zaretskii <eliz <at> gnu.org> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 06 Apr 2025 11:24:28 GMT) Full text and rfc822 format available.

This bug report was last modified 74 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.