@NickD provided a good answer: use a face.
OP's comment to Nick's answer says that he'll try to write a function that, given a string, returns a propertized string. Such functions already exist: propertize does that, and so does add-face-text-property.
(setq ss (propertize "abcde" 'face '(:foreground "red")))
(setq ss &...
You need to create a string with the appropriate face. You do that by attaching a face text property to the string, giving it value of some face (predefined or defined for the specific purpose - you can look at all the predefined faces with M-x list-faces-display and pick one from there, or you can define your own face).
E.g. here's a snippet to use a ...
It appears that the dashes are caused by the variable mode-line-end-spaces, which is the last item in mode-line-format by default. The default value of mode-line-end-spaces is (:eval (unless (display-graphic-p) "-%-")), which explains why the dashes only appear in terminal Emacs but not in GUI Emacs.
This seems to remove the dashes, but I'm not ...
Refer to the manual:
C-hig (elisp)Properties in Mode
Or in the online manual (which is always for the most recent stable release of Emacs): https://www.gnu.org/software/emacs/manual/html_node/elisp/Properties-in-Mode.html
I think there's no point in quoting an excerpt here -- you need to read the whole page.
Following @lawlist advise, using :box attribute for mode-line-inactive made it.
The mode lines images shown in the question are from inactive frames.
The second image shows an inactive frame with a mode line that does not render the straight lines.
(set-face-attribute 'mode-line-inactive nil :box t)
renders the straight line with foreground color:
I did not find a way to integrate it into the Spacemacs intended use of packages.
Adding this snippet to my dotspacemacs/user-config:
:init (doom-modeline-mode 1)
;; Enable flashing mode-line on errors
;; Corrects (and improves) org-mode's native fontification....
Revisiting this old topic, (string-to-number (format-mode-line "%l") still holds up quite well against (line-number-at-position). I found it is also highly cached for "nearby" line positions. For example, operating on /usr/dict/words (236k lines here):
(let* ((buf (get-buffer "words"))
(win (get-buffer-window buf))