;; start by boxing in a region [inspired by boxquote.el] (defun box-region (start end) (interactive "r") (goto-char start) (let ((x 0)) (if (not (= (char-after) 10)) (insert "\n")) (while (< (point) end) (insert " ") (setq pt (point)) (end-of-line) (if (> (- (point) pt) x) (setq x (- (point) pt))) (next-line 1) (beginning-of-line)) (next-line 1) (beginning-of-line) (setq leading-spaces (make-string x ?x)) (insert leading-spaces) (picture-draw-rectangle start (point)))) (defun box-defun () (interactive) (mark-defun) (box-region (region-beginning) (region-end))) (defun box-buffer () "Apply `boxquote-region' to a whole buffer." (interactive) (box-region (point-min) (point-max))) (defun box-insert-file (filename) "Insert the contents of a file, boxed with `box-region'." (interactive "fInsert file: ") (let ((target (current-buffer))) (with-temp-buffer (let ((source (current-buffer))) (insert-file-contents filename nil) (box-buffer) (with-current-buffer target (insert-buffer source)))))) (defun box-yank () "Do a `yank' and box it in with `boxquote-region'." (interactive) (let ((target (current-buffer))) (with-temp-buffer (let ((source (current-buffer))) (yank) (box-buffer) (with-current-buffer target (insert-buffer source)))))) (defun box-paragraph () "Apply `boxquote-region' to the current paragraph." (interactive) (mark-paragraph) (box-region (region-beginning) (region-end)))