[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hline
From: |
Tim Visher |
Subject: |
Re: hline |
Date: |
Thu, 7 Jan 2021 09:51:05 -0500 |
On Thu, Jan 7, 2021 at 4:53 AM Jean Louis <bugs@gnu.support> wrote:
> * Emanuel Berg via Users list for the GNU Emacs text editor <
> help-gnu-emacs@gnu.org> [2021-01-07 09:24]:
> > (defun hline (&optional char)
> > (interactive "P")
> > (let ((len (- (window-width) (current-column) 1))
> > (c (or char ?-)) )
> > (insert (make-string len c)) ))
>
> I can undertand and find it useful. But you should maybe think of
> auto-fill-mode and fill-column, is it?
>
> If fill-column is 70, should line really go over all the visible
> window screen? As text does not.
>
I've done something similar to this that respected fill-column. I use it
quite a bit when writing software.
```
(defun header-comment (comment)
"Insert a header COMMENT
A header comment is a line of comment characters fill-column
long, a line of 3 comment characters followed by a space then
COMMENT, and a line of comment characters fill-column long
again."
(interactive "sComment: ")
(let* ((comment-char (string-to-char comment-start))
(wrapper (make-string fill-column comment-char))
(comment-line (format "%s %s"
(make-string 3 comment-char)
comment)))
(insert wrapper "\n" comment-line "\n" wrapper)))
```
- hline, Emanuel Berg, 2021/01/07