1

Switching from fill-column-indicator (sadly too many issues now, but it was a good run) to native display-fill-column-indicator has left me with some unsightly gaps:

display-fill-column-indicator-mode with gaps

(setq-default line-spacing 0.25) (setq-default display-fill-column-indicator-column 79) (global-display-fill-column-indicator-mode 1) 

I've tried adding :box or :stipple attributes to the fill-column-indicator face, but have been unable to achieve my desired result of a single solid line, like so:

a perfect fill column in a different editor

Is there a way to have an increased line-spacing with a solid display-fill-column-indicator?

2
  • Did you read Displaying Boundaries in the Emacs manual? They say that the default is U+2502 if it can be displayed, falling back to |. You might try playing around with that, or maybe defining your own combining character somehow that displays as a longer vertical bar. Commented May 17, 2024 at 1:41
  • 1
    I did — that's how I learned that fill-column-indicator was the face to adjust — but no character makes a seamless line with my line spacing. Commented May 17, 2024 at 14:15

2 Answers 2

3

In hopes that this helps anyone else, the solution was two-fold:

(setq-default line-spacing 0.25) (setq-default display-fill-column-indicator-column 79) (setq-default display-fill-column-indicator-character ?\ ) (set-face-attribute 'fill-column-indicator nil :background nil :foreground "white" :stipple '(7 1 " ")) (global-display-fill-column-indicator-mode 1) 

The result, with a very visible white fill column indicator example:

seamless fill column

2
  • That worked for my Emacs, Thank you! What is the syntax if I add that using (custom-set-faces ''fill-column-indicator ... I tried a lot but nothing worked but didn't error either Commented Apr 4 at 19:10
  • I guess this solution works as long as the whole buffer has one uniform font width. When there are differing font sizes involved, the literal bitmap will be used as a pattern resulting in ugly repetitions. Commented Apr 14 at 7:20
1

I was inspired by Metric Scantlings' approach using stipples, and adapted it to not have the horizontally repeated vertical line artifact when changing text scale that is mentioned by JohnDoe. Here is my solution, which leverages the stipple bitmap calculation done by indent-bars:

(use-package indent-bars ;; https://github.com/jdtsmith/indent-bars ;; Fast, configurable indentation guide-bars for Emacs. ;; ;; This package is also very useful because it builds correct stipple bitmaps ;; via `invent-bars--stipple'. ) ;; Display the fill indicator. (defun danylo/update-fill-column-indicator () "Adjust the stipple bitmap for the current font size, such that it displays as a single thin vertical line. Inspired by https://emacs.stackexchange.com/a/81307 but makes sure that the vertical line is not repeated horizontally at certain text zoom levels." (let* ((char-width-pixels (frame-char-width)) (rot (indent-bars--stipple-rot (selected-window) char-width-pixels))) (set-face-attribute 'fill-column-indicator nil :background 'unspecified :foreground "#5a6167" :stipple (indent-bars--stipple char-width-pixels 1 rot nil 0.1 0 "." 0))) ) (when (display-graphic-p) (progn (setq-default display-fill-column-indicator-character ?\ ) (add-hook 'after-init-hook 'danylo/update-fill-column-indicator) (advice-add 'set-fill-column :after (lambda (&rest _) (danylo/update-fill-column-indicator))) (advice-add 'default-text-scale-decrease :after (lambda (&rest _) (danylo/update-fill-column-indicator))) (advice-add 'default-text-scale-increase :after (lambda (&rest _) (danylo/update-fill-column-indicator))) (advice-add 'danylo/reset-font-size :after (lambda (&rest _) (danylo/update-fill-column-indicator))))) 

You can also see it in context in my dotfiles.

Result: enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.