Skip to content

Instantly share code, notes, and snippets.

@dmatveev
Created May 17, 2011 19:51
Show Gist options
  • Save dmatveev/977243 to your computer and use it in GitHub Desktop.
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
(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