* calendar/todos.el: Fix tabular alignment in Todos Categories mode.

(todos-adjusted-category-label-length): New function.
(todos-padded-string): Use it.
This commit is contained in:
Stephen Berman 2013-01-08 22:40:41 +01:00
parent c4bf3e3daa
commit b58fa72f2a
2 changed files with 22 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2013-01-08 Stephen Berman <stephen.berman@gmx.net>
* calendar/todos.el: Fix tabular alignment in Todos Categories mode.
(todos-adjusted-category-label-length): New function.
(todos-padded-string): Use it.
2013-01-08 Stephen Berman <stephen.berman@gmx.net>
* calendar/todos.el (todos-move-item): Allow moving done items to

View file

@ -2141,15 +2141,26 @@ in Todos Filter Items mode."
(dolist (c categories longest)
(setq longest (max longest (length c))))))
(defun todos-adjusted-category-label-length ()
"Return adjusted length of category label button.
The adjustment ensures proper tabular alignment in Todos
Categories mode."
(let* ((categories (mapcar 'car todos-categories))
(longest (todos-longest-category-name-length categories))
(catlablen (length todos-categories-category-label))
(lc-diff (- longest catlablen)))
(if (and (natnump lc-diff)
(eq (logand lc-diff 1) 1)) ; oddp from cl.el
(1+ longest)
(max longest catlablen))))
(defun todos-padded-string (str)
"Return string STR padded with spaces.
"Return category name or label string STR padded with spaces.
The placement of the padding is determined by the value of user
option `todos-categories-align'."
(let* ((categories (mapcar 'car todos-categories))
(len (max (todos-longest-category-name-length categories)
(length todos-categories-category-label)))
(let* ((len (todos-adjusted-category-label-length))
(strlen (length str))
(strlen-odd (eq (logand strlen 1) 1)) ; oddp from cl.el
(strlen-odd (eq (logand strlen 1) 1))
(padding (max 0 (/ (- len strlen) 2)))
(padding-left (cond ((eq todos-categories-align 'left) 0)
((eq todos-categories-align 'center) padding)