読者です 読者をやめる 読者になる 読者になる

tanzaku.el

emacs 七夕

https://github.com/kazeburo/tanzak


を見て.

コード

複数行対応がない等問題が多々あります.

(require 'cl-lib)

(defconst tanzaku--vertial-rules
  '(("/" . "\")
    ("‥" . ":")
    ("−" . "|")
    ("─" . "|")
    ("ー" . "|")

    ("→" . "↓")
    ("↑" . "→")
    ("←" . "↑")
    ("↓" . "←")

    ("=" . "॥")

    ("〖" . "︗")
    ("〗" . "︘")
    ("【" . "︗")
    ("】" . "︘")

    ("…" . "︙")

    ("〜" . "∫ ")
    ("『" . " ┓")
    ("』" . "┗ ")
    ("[" . "┌┐")
    ("]" . "└┘")
    ("<" . "∧ ")
    (">" . "∨ ")
    ("《" . "∧ ")
    ("》" . "∨ ")))

(defun tanzaku--convert-vertical (input)
  (let ((str input))
    (cl-loop for (from . to) in tanzaku--vertial-rules
             do
             (setq str (replace-regexp-in-string from to str))
             finally
             return str)))

(defun tanzaku (negaigoto)
  (interactive
   (list (read-string "願い事: ")))
  (cl-loop for c across negaigoto
           collect (concat "┃" (japanese-zenkaku (char-to-string c)) "┃") into lst
           finally
           (with-current-buffer (get-buffer-create "*tanzaku*")
             (erase-buffer)
             (let* ((lst (append (cons "┏┷┓" (cons "┃ ┃" lst)) '("┃ ┃" "┗━┛")))
                    (input (mapconcat 'identity lst "\n")))
               (insert (tanzaku--convert-vertical input)))
             (goto-char (point-min))
             (pop-to-buffer (current-buffer)))))

イメージ