From b58fa72f2ad2f2c268a3e6eb8d884fe0f229dfac Mon Sep 17 00:00:00 2001 From: Stephen Berman Date: Tue, 8 Jan 2013 22:40:41 +0100 Subject: [PATCH] * calendar/todos.el: Fix tabular alignment in Todos Categories mode. (todos-adjusted-category-label-length): New function. (todos-padded-string): Use it. --- lisp/ChangeLog | 6 ++++++ lisp/calendar/todos.el | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 754e936f2b3..c529800e564 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-01-08 Stephen Berman + + * 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 * calendar/todos.el (todos-move-item): Allow moving done items to diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 0b3a3b57a9b..c5792338930 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el @@ -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) -- 2.39.5