help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Enclosing text in a box


From: Eli Zaretskii
Subject: Re: Enclosing text in a box
Date: Fri, 18 Nov 2022 16:48:50 +0200

> From: Emanuel Berg <incal@dataswamp.org>
> Date: Wed, 16 Nov 2022 21:55:05 +0100
> 
> Eli Zaretskii wrote:
> 
> >> Asking users to handle such conditions would be too hard to
> >> do repeatedly.
> >
> > This is not userland, this is Emacs Lisp programming for
> > display, and yes, it is quite tricky
> 
> (defun sign (label)
>   (interactive "sLabel: ")
>   (let*((vertical   "|")
>         (horizontal  ?-)
>         (corner     "+")
>         (mid (format "%s %s %s" vertical label vertical))
>         (len (length mid))
>         (top (format "%s%s%s" corner (make-string (- len 2) horizontal) 
> corner))
>         (sgn (format "%s\n%s\n%s\n" top mid top)) )
>     (insert sgn) ))
> 
> ;; M-x sign This is not a bluff RET
> ;;
> ;; +---------------------+
> ;; | This is not a bluff |
> ;; +---------------------+

And now try with "fullwidth" characters, like the below:

  M-x sign RET This is not a bluff RET

This yields:

  +---------------------+
  | This is not a bluff |
  +---------------------+

Hmm...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]