The built-in backslash fringe bitmap is somewhat mysterious in that it is not available to the user through a common name such as backslash
or back-slash
. I created my own -- using fringe-helper-convert
and define-fringe-bitmap
-- but it looks like a miniature staircase instead of a good looking smooth line.
Is there a special name for the built-in backslash fringe bitmap, and if so, what is it called?
The following snippet demonstrates how to display a bitmap in the right fringe (assuming the fringe is visible and wide enough) -- the example uses a question-mark
since the built-in backslash appears to be unavailable?
(let ((peol (point-at-eol)))
(overlay-put (make-overlay peol peol) 'after-string
(propertize (char-to-string ?\uE000) 'display
'(right-fringe question-mark font-lock-keyword-face))))
Here are links to the limited documentation regarding fringe bitmaps:
http://www.gnu.org/software/emacs/manual/html_node/elisp/Fringe-Bitmaps.html
http://www.gnu.org/software/emacs/manual/html_node/elisp/Customizing-Bitmaps.html
The built-in fringe backslash is visible in the right fringe in a GUI version of Emacs when the fringes are turned OFF -- i.e., (set-window-fringes (selected-window) 0 0)
Here is my staircase-looking version of the backslash, which is not a smooth line.
;; 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)))
(define-fringe-bitmap 'backslash (fringe-helper-convert
"XX......"
"XX......"
" XX....."
".XX....."
"..XX...."
"..XX...."
"...XX..."
"...XX..."
"....XX.."
"....XX.."
".....XX."
".....XX.") nil nil 'center)
(set-window-fringes (selected-window) 0 0)
causes Emacs to display the backslash in the right fringe when the line wraps at the window edge.