Browse Source

Fixed an error when no candidates where found

master
Josh Wolfe 2 years ago
parent
commit
3f91e52e26
1 changed files with 18 additions and 17 deletions
  1. 18
    17
      emacs/.emacs.d/lisp/doom-todo-ivy.el

+ 18
- 17
emacs/.emacs.d/lisp/doom-todo-ivy.el View File

@@ -14,23 +14,24 @@ face to render it with.")
(defun doom/ivy--tasks-candidates (tasks)
"Generate a list of task tags (specified by `doom/ivy-task-tags') for
`doom/ivy-tasks'."
(let* ((max-type-width
(cl-loop for task in doom/ivy-task-tags maximize (length (car task))))
(max-desc-width
(cl-loop for task in tasks maximize (length (cl-cdadr task))))
(max-width (max (- (frame-width) (1+ max-type-width) max-desc-width)
25)))
(cl-loop
with fmt = (format "%%-%ds %%-%ds%%s%%s:%%s" max-type-width max-width)
for alist in tasks
collect
(let-alist alist
(format fmt
(propertize .type 'face (cdr (assoc .type doom/ivy-task-tags)))
(string-trim (substring .desc 0 (min max-desc-width (length .desc))))
(propertize " | " 'face 'font-lock-comment-face)
(propertize (abbreviate-file-name .file) 'face 'font-lock-keyword-face)
(propertize .line 'face 'font-lock-constant-face))))))
(when tasks
(let* ((max-type-width
(cl-loop for task in doom/ivy-task-tags maximize (length (car task))))
(max-desc-width
(cl-loop for task in tasks maximize (length (cl-cdadr task))))
(max-width (max (- (frame-width) (1+ max-type-width) max-desc-width)
25)))
(cl-loop
with fmt = (format "%%-%ds %%-%ds%%s%%s:%%s" max-type-width max-width)
for alist in tasks
collect
(let-alist alist
(format fmt
(propertize .type 'face (cdr (assoc .type doom/ivy-task-tags)))
(string-trim (substring .desc 0 (min max-desc-width (length .desc))))
(propertize " | " 'face 'font-lock-comment-face)
(propertize (abbreviate-file-name .file) 'face 'font-lock-keyword-face)
(propertize .line 'face 'font-lock-constant-face)))))))

(defun doom/ivy--tasks (target)
(let* (case-fold-search

Loading…
Cancel
Save