#! emacs --script ;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/script/boxme.el (require 'cl-lib) (defun box-me (file &optional xc yc) (or xc (setq xc 74)) (or yc (setq yc 25)) (when (and (<= 3 xc) (<= 3 yc)) (let* ((yb ?|) (xb ?-) (cb ?+) (xci (- xc 2)) (tl (format "%c%s%c" cb (make-string xci xb) cb))) (with-temp-buffer (insert-file-contents file) (goto-char (point-max)) (let ((inhibit-message t)) (when (re-search-backward "^" (point-min) t) (replace-match (char-to-string yb)))) (goto-char (point-max)) (cl-loop do (goto-char (pos-eol)) (let ((len (abs (- xc (current-column) 1)))) ; why `abs'? (insert (make-string len ?\s))) (insert yb) until (not (zerop (forward-line -1)))) (goto-char (point-min)) (insert tl ?\n) (goto-char (point-max)) (open-line 1) (goto-char (point-max)) (insert tl) (message "%s\n" (buffer-substring-no-properties (point-min) (point-max))) (kill-emacs))))) (apply #'box-me (last command-line-args 1))