[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Underline the current line (function inside)
From: |
Eli Zaretskii |
Subject: |
Re: Underline the current line (function inside) |
Date: |
Fri, 11 Jun 2021 17:52:03 +0300 |
> Date: Fri, 11 Jun 2021 17:32:26 +0300
> From: Jean Louis <bugs@gnu.support>
>
> This function is handy to underline the current line:
>
> (defun underline-line ()
> "Underline the current line."
> (interactive)
> (let* ((start (line-beginning-position))
> (end (line-end-position))
> (length (- end start)))
> (end-of-line)
> (newline)
> (insert (make-string length ?=))
> (newline)))
This assumes that each character takes 1 column. That is false in
general, because some characters have zero width on display, and some
others take closer to two columns.
You need to use string-width instead, or count columns instead of
buffer positions.
And, of course, all this assumes fixed-pitch font.