* hline
@ 2021-01-07 6:21 Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 9:49 ` hline Jean Louis
2021-01-07 15:23 ` hline Marcin Borkowski
0 siblings, 2 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-01-07 6:21 UTC (permalink / raw)
To: help-gnu-emacs
(defun hline (&optional char)
(interactive "P")
(let ((len (- (window-width) (current-column) 1))
(c (or char ?-)) )
(insert (make-string len c)) ))
(hline)------------------------------------------------------------------------
(hline 43)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M-x hline RET------------------------------------------------------------------
C-u 59 M-x hline RET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 6:21 hline Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-01-07 9:49 ` Jean Louis
2021-01-07 10:05 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 14:51 ` hline Tim Visher
2021-01-07 15:23 ` hline Marcin Borkowski
1 sibling, 2 replies; 9+ messages in thread
From: Jean Louis @ 2021-01-07 9:49 UTC (permalink / raw)
To: help-gnu-emacs
* 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.
Jean
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 9:49 ` hline Jean Louis
@ 2021-01-07 10:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 14:51 ` hline Tim Visher
1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-01-07 10:05 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
>> (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. [...]
:)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 9:49 ` hline Jean Louis
2021-01-07 10:05 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-01-07 14:51 ` Tim Visher
2021-01-08 1:00 ` hline Jean Louis
1 sibling, 1 reply; 9+ messages in thread
From: Tim Visher @ 2021-01-07 14:51 UTC (permalink / raw)
To: emacs
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)))
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 14:51 ` hline Tim Visher
@ 2021-01-08 1:00 ` Jean Louis
0 siblings, 0 replies; 9+ messages in thread
From: Jean Louis @ 2021-01-08 1:00 UTC (permalink / raw)
To: help-gnu-emacs
* 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)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 6:21 hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 9:49 ` hline Jean Louis
@ 2021-01-07 15:23 ` Marcin Borkowski
2021-01-07 22:44 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
` (2 more replies)
1 sibling, 3 replies; 9+ messages in thread
From: Marcin Borkowski @ 2021-01-07 15:23 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
On 2021-01-07, at 07:21, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> (defun hline (&optional char)
> (interactive "P")
> (let ((len (- (window-width) (current-column) 1))
> (c (or char ?-)) )
> (insert (make-string len c)) ))
Funny how I wrote an almost identical function just two days ago...
Though I used (1- (window-width)), since in my use case I knew that
(current-column) would be zero.
Anybody knows why it is necessary to subtract 1?
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 15:23 ` hline Marcin Borkowski
@ 2021-01-07 22:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 22:57 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 23:08 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-01-07 22:44 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski wrote:
>> (defun hline (&optional char)
>> (interactive "P")
>> (let ((len (- (window-width) (current-column) 1))
>> (c (or char ?-)) )
>> (insert (make-string len c)) ))
>
> Funny how I wrote an almost identical function just two days
> ago... Though I used (1- (window-width)), since in my use
> case I knew that (current-column) would be zero.
>
> Anybody knows why it is necessary to subtract 1?
Eh... "anybody"? ...
[74] column number 74
[X] you are here
* = you want to write the char here
$ = but not here
.. = etc
* * * * $ ..
[01] ... [74] [X] [76] [77] [78] [79] [80]
so 4 chars.
compute:
(- 80 75 1) ; 4
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 15:23 ` hline Marcin Borkowski
2021-01-07 22:44 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-01-07 22:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 23:08 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-01-07 22:57 UTC (permalink / raw)
To: help-gnu-emacs
> * * * * $ ..
> [01] ... [74] [X] [76] [77] [78] [79] [80]
Oh, that should be [00] (not [01]), but it doesn't matter for
the above example. But the subtraction works there as well:
(- 80 0 1) ; 79, let's try `C-u 79 a' at [00]
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: hline
2021-01-07 15:23 ` hline Marcin Borkowski
2021-01-07 22:44 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 22:57 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-01-07 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-01-07 23:08 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski wrote:
>> (defun hline (&optional char)
>> (interactive "P")
>> (let ((len (- (window-width) (current-column) 1))
>> (c (or char ?-)) )
>> (insert (make-string len c)) ))
>
> Funny how I wrote an almost identical function just two days ago...
> Though I used (1- (window-width)), since in my use case I knew that
> (current-column) would be zero.
>
> Anybody knows why it is necessary to subtract 1?
:O
I don't understand why YOU ask this?
But for everyone else's information, it can be better
explained like this, I think, than the examples I just posted.
If we want to cover the distance between A to B on a line,
this distance is B - A. However B is reported not the _
desired B but B + 1. So by subtracting 1 we get the real B |_|
:)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-01-08 1:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-07 6:21 hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 9:49 ` hline Jean Louis
2021-01-07 10:05 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 14:51 ` hline Tim Visher
2021-01-08 1:00 ` hline Jean Louis
2021-01-07 15:23 ` hline Marcin Borkowski
2021-01-07 22:44 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 22:57 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
2021-01-07 23:08 ` hline Emanuel Berg via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).