[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hline
From: |
Jean Louis |
Subject: |
Re: hline |
Date: |
Fri, 8 Jan 2021 04:00:18 +0300 |
User-agent: |
Mutt/2.0 (3d08634) (2020-11-07) |
* Tim Visher <tim.visher@gmail.com> [2021-01-07 17:52]:
> 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)))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> Something
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
My similar thing
================
(defun underline-text (text &optional no-newlines)
"Asks for TEXT and returns it underlined. If optional
NEW-NEWLINES is true, it will not add new lines."
(let* ((l (length text))
(newlines (if no-newlines "" "\n\n")))
(format "%s\n%s%s" text
(with-output-to-string
(let ((count 0))
(while (< count l)
(princ "=")
(setq count (1+ count)))))
newlines)))
(defun underline-text-interactive (text)
"Underlines and insert text into buffer"
(interactive "sText: ")
(insert (underline-text text)))
- hline, Emanuel Berg, 2021/01/07