Function: todo-padded-string

todo-padded-string is a byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-padded-string STR)

Documentation

Return category name or label string STR padded with spaces.

The placement of the padding is determined by the value of user option todo-categories-align.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-padded-string (str)
  "Return category name or label string STR padded with spaces.
The placement of the padding is determined by the value of user
option `todo-categories-align'."
  (let* ((len (todo-adjusted-category-label-length))
	 (strlen (length str))
	 (strlen-odd (eq (logand strlen 1) 1))
	 (padding (max 0 (/ (- len strlen) 2)))
	 (padding-left (cond ((eq todo-categories-align 'left) 0)
			     ((eq todo-categories-align 'center) padding)
			     ((eq todo-categories-align 'right)
			      (if strlen-odd (1+ (* padding 2)) (* padding 2)))))
	 (padding-right (cond ((eq todo-categories-align 'left)
			       (if strlen-odd (1+ (* padding 2)) (* padding 2)))
			      ((eq todo-categories-align 'center)
			       (if strlen-odd (1+ padding) padding))
			      ((eq todo-categories-align 'right) 0))))
    (concat (make-string padding-left 32) str (make-string padding-right 32))))