[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ASCII formatting for plain text email



Pierre Willaime <pierre.willaime@univ-lorraine.fr> writes:

> Le 31/01/2023 à 21:14, Greg Wooledge a écrit :
>> A .signature file is only written once, so it doesn't matter how
>> tedious it is to produce the desired formatting.
>
> But you are right, .signature file is only written once and I am looking
> for a simple way to write email with some minimal ASCII formatting. This
> is why I am looking for an automatic solution.

As Greg already stated, you only need to calculate spaces if the content
will be changing (i.e., date or other field(s)).  Otherwise just write
what you want statically in signature file as mentioned.

> I do not want to do ASCII art, I am only searching a simple way to do
> something close to the debian-annouce emails.
>
> ------------------------------------------------------------------------
> The Debian Project                               https://www.debian.org/
> Updated Debian 11: 11.6 released                        press@debian.org
> December 17th, 2022            https://www.debian.org/News/2022/20221217
> ------------------------------------------------------------------------
>
> How this header is generated?
>
> So do someone knows:
>
> 1- a simple way to draw a line (without pressing 72 times on "-")
> -----------------------------------------------------------------------

Since you mentioned Emacs (in OP).  One answer has been posted already
about how to do so interactively.  Here is how to do so with ELisp:

#+begin_src emacs-lisp
  (insert-char ?- 72)
#+end_src

> 2- a simple way to align some text to the right (that is to say to
> automatically calculate how many spaces are needed to fill the gap
> between the text on the left an the text on the right for 72 characters
> line.

#+begin_src emacs-lisp
  (defun my-insert-line-justified (left-text right-text)
    "Insert justified line.
  Spaces between LEFT-TEXT and RIGHT-TEXT will be calculated
  automatically, based on 72 character overall width."
    (let* ((left-chars (length left-text))
	   (right-chars (length right-text))
	   (spaces-count (- 72 left-chars right-chars))
	   (spaces-string (make-string spaces-count ? )))
      (insert left-text spaces-string right-text)))
#+end_src

> 3- a simple way to do boxes (no present in debian-annouce header)

If you put together both things I provided above (perhaps along with
some '|' characters), you should be able to figure this out for
yourself.

As others have pointed out, consider doing so tastefully/sparingly.

-- 
Cheers,
TRS-80


Reply to: