Created
May 17, 2011 19:51
-
-
Save dmatveev/977243 to your computer and use it in GitHub Desktop.
A tiny and stupid function I use for section headers in my elisp code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun elisp-header (len text) | |
(interactive "p\nsHeader: ") | |
(let* ((total-len (if (< len 10) 80 len)) | |
(text-len (length text)) | |
(bar-len (/ (- total-len (+ 2 text-len)) 2)) | |
(left-len (- total-len (+ (* 2 bar-len) 2 text-len))) | |
(inserter (lambda (len) (dotimes (i len) (insert ";"))))) | |
(funcall inserter bar-len) | |
(insert (concat " " text " ")) | |
(funcall inserter bar-len) | |
(if (> left-len 0) (funcall inserter left-len)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment