I'd love to replace the ugly pixel arrows indicating truncated or wrapped lines with simple, tasteful text (maybe even a nice unicode character, like a \u2026
ellipsis). Is this possible?

- 712
- 6
- 17
-
You may want to look through `fringe.el`, which is where the fringe bitmaps are set up. – Michael Hoffman Apr 19 '13 at 23:16
-
The actual bitmap patterns are defined along with a comment showing the bitmap pattern in `fringe.c` . In `fringe.el` there is only a reference to a list of bitmaps in order to get the `_` connected name parts used in C synchronized with the `-` name parts used in elisp. – Claudio Apr 20 '23 at 00:54
2 Answers
No, it is not. Fringe “bitmaps” are really bitmaps, that is vectors of 0/1 bits, overlayed over the fringe. There is no way to directly render arbitrary unicode characters onto the fringe.
What you can do, is to render a unicode character into a 0/1 bitmap yourself. Any decent image editor (e.g. Gimp, Photoshop, Pixelmator, Paint.net, etc.) can do this. Then convert this bitmap into an fringe bitmap vector. The format of fringe bitmaps is described in Customizing Fringe Bitmaps.
Eventually you can use these bitmap vectors to replace the left-arrow
, right-arrow
(for truncated lines), left-curly-arrow
, and right-curly-arrow
(for continued lines) bitmaps, using the function define-fringe-bitmap
.
However, I'd say that this is more hassle than it is worth. The fringe is 8 pixels wide, so you'd have to squeeze your beautiful unicode character into an 8x8 bitmap. This means no subpixel rendering, no aliasing, no bytecode rendering, nothing of what makes characters on the screen nice and fancy. It'd be just as ugly as the arrows you have replaced.
-
Interesting! That said doesn't look like much hassle, especially seen that OP mentionned he wants to use an ellipsis. In a 8x8 bitmap that would be a 2x2 pixels dot, repeated 3 times, separated by one blank pixel (that would be 8 pixels wide). I agree with OP that the default arrow is more than fugly. Do you know where we could modify the left-arrow bitmap or add our own bitmap? – TacticalCoder Apr 20 '13 at 14:11
-
@TacticalCoder You can redefine fringe bitmaps with a simple call to `define-fringe-bitmap`, like [I did in Flycheck](https://github.com/lunaryorn/flycheck/blob/09a814a4a153e6be0571b5c270d0b46d7fe866e9/flycheck.el#L1821). And believe me, Fringe bitmaps *are* a hassle. Been there, done that. And there is no gain here. You can't do great art on a 8x8 black/white bitmap, and a 2x2 ellipse wouldn't be any nicer than the default arrows. These arrows are ugly precisely because these bitmaps are so limited. – Apr 20 '13 at 14:50
-
I'll take a look at what you did in flycheck. I've seen "pixel art" in 8x8 pixels which looked not too bad so I'll give it a try ; ) – TacticalCoder Apr 20 '13 at 15:57
-
@lunaryorn thanks for the clarifying, and that's a shame to hear...you should see how awful the bitmaps look on a retina screen. But, and maybe I should re-ask my question, doesn't the terminal version of Emacs use text? Is it possible to customize the characters used there and/or have the window-system Emacs use this text instead of bitmaps? – Metric Scantlings Apr 22 '13 at 17:25
-
I am sorry, but unfortunately I do not know how terminal emacs behaves here. I never use it. You may want to bring this issue (fringe bitmaps on retina displays) to the emacs mailing list. – Apr 23 '13 at 21:08
The answer by lunaryorn is correct, but it is perhaps beyond the reach of novice Emacs users -- e.g., programmer hobbyists such as myself.
The function fringe-helper-convert
written by Nikolaj Schumacher in his library Fringe Helper -- https://github.com/nschum/fringe-helper.el -- makes it easy for Emacs hobbyists like myself to create a vector that is used by the the function define-fringe-bitmap
(which is defined in the C-source code of Emacs). I chose a pilcrow, but the user is free to create any image that will fit -- e.g., using the capital letter X
and the period .
, the user could create the shape of a letter.
;; AUTHOR: Nikolaj Schumacher -- https://github.com/nschum/fringe-helper.el
(defun fringe-helper-convert (&rest strings)
"Convert STRINGS into a vector usable for `define-fringe-bitmap'.
Each string in STRINGS represents a line of the fringe bitmap.
Periods (.) are background-colored pixel; Xs are foreground-colored. The
fringe bitmap always is aligned to the right. If the fringe has half
width, only the left 4 pixels of an 8 pixel bitmap will be shown.
For example, the following code defines a diagonal line.
\(fringe-helper-convert
\"XX......\"
\"..XX....\"
\"....XX..\"
\"......XX\"\)"
(unless (cdr strings)
;; only one string, probably with newlines
(setq strings (split-string (car strings) "\n")))
(apply 'vector
(mapcar
(lambda (str)
(let ((num 0))
(dolist (c (string-to-list str))
(setq num (+ (* num 2) (if (eq c ?.) 0 1))))
num))
strings)))
The following example assumes a frame-char-height
of 20 pixels -- so that the bitmap image is the same height as the text in the buffer. The let-bound snippet creates a pilcrow shape in the right fringe at the end of the line (wherever point is when the snippet is evaluated). The example assumes the right fringe is at least a width of eleven -- e.g., (add-to-list 'default-frame-alist '(right-fringe . 11))
The unicode symbol converted to string -- (char-to-string ?\uE000)
could probably be substituted with " "
.
(define-fringe-bitmap 'pilcrow (fringe-helper-convert
"......."
"......."
"......."
"......."
"......."
".XXXXXX"
"XXXX.X."
"XXXX.X."
"XXXX.X."
".XXX.X."
"...X.X."
"...X.X."
"...X.X."
"...X.X."
"...X.X."
"...X.X."
"......."
"......."
"......."
"......."))
(let ((peol (point-at-eol)))
(overlay-put (make-overlay peol peol) 'after-string
(propertize (char-to-string ?\uE000) 'display
'(right-fringe pilcrow font-lock-keyword-face))))

- 13,099
- 3
- 49
- 158
-
You're not a novice anymore at this point, but I think it would help to mention that since Emacs supports binary literals "drawing" these bitmaps by hand isn't much harder: compare `(fringe-helper-convert "..XX..XX" "XX..XX..")` with `[#b00110011 #b11001100]` – Clément Apr 22 '20 at 03:04