diff --git a/README.org b/README.org index b15c02c1..6699c786 100644 --- a/README.org +++ b/README.org @@ -136,6 +136,10 @@ Helm and Ivy are also supported. Note that the =helm= and =ivy= packages are no *Added* + Option =magit-todos-submodule-list= controls whether to-dos in submodules are displayed (default: off). (Thanks to [[https://github.com/matsievskiysv][Matsievskiy S.V.]]) +*Fixed* + ++ Evaluate `magit-todos-keywords-list` just in time to pick up current keywords in case `magit-todos-keywords` points to a list variable. (See #101.) + *Changed* + Option =magit-todos-exclude-globs= now excludes the `.git/` directory by default. (Thanks to [[https://github.com/Amorymeltzer][Amorymeltzer]].) + Library ~org~ is no longer loaded automatically, but only when needed. (This can reduce load time, especially if the user's Org configuration is complex.) ([[https://github.com/alphapapa/magit-todos/issues/120][#120]]. Thanks to [[https://github.com/meedstrom][Martin Edström]] and [[https://github.com/jsigman][Johnny Sigman]] for suggesting.) diff --git a/magit-todos.el b/magit-todos.el index 470745c2..974993e0 100644 --- a/magit-todos.el +++ b/magit-todos.el @@ -85,7 +85,8 @@ (defvar magit-todos-keywords-list nil "List of to-do keywords. -Set automatically by `magit-todos-keywords' customization.") +Set automatically from `magit-todos-keywords' and + `magit-todos-ignored-keywords' before building the search regex.") (defvar magit-todos-grep-result-regexp nil "Regular expression for grep results. @@ -226,19 +227,7 @@ Note: the suffix applies only to non-Org files." (defcustom magit-todos-ignored-keywords '("NOTE" "DONE") "Ignored keywords. Automatically removed from `magit-todos-keywords'." - :type '(repeat string) - :set (lambda (option value) - (set-default option value) - (when (boundp 'magit-todos-keywords) - ;; Avoid setting `magit-todos-keywords' before it's defined. - - ;; HACK: Testing with `fboundp' is the only way I have been able to find that fixes this - ;; problem. I tried using ":set-after '(magit-todos-ignored-keywords)" on - ;; `magit-todos-keywords', but it had no effect. I looked in the manual, which seems to - ;; suggest that using ":initialize 'custom-initialize-safe-set" might fix it--but that - ;; function is no longer to be found in the Emacs source tree. It was committed in 2005, - ;; and now it's gone, but the manual still mentions it. ??? - (custom-reevaluate-setting 'magit-todos-keywords)))) + :type '(repeat string)) (defcustom magit-todos-keywords 'hl-todo-keyword-faces "To-do keywords to display in Magit status buffer. @@ -252,14 +241,7 @@ regular expression." (variable :tag "List variable")) :set (lambda (option value) (set-default option value) - (let ((keywords (cl-typecase value - (null (user-error "Please add some keywords")) - (symbol (if (and (consp (symbol-value value)) - (consp (car (symbol-value value)))) - (mapcar #'car (symbol-value value)) - (symbol-value value))) - (list value)))) - (setq magit-todos-keywords-list (seq-difference keywords magit-todos-ignored-keywords))))) + (when (null value) (user-error "Please add some keywords")))) (defcustom magit-todos-max-items 10 "Automatically collapse the section if there are more than this many items." @@ -495,6 +477,16 @@ Type \\[magit-diff-show-or-scroll-up] to peek at the item at point." ;;;; Functions +(defun magit-todos--compile-keywords-list () + "Evaluate keywords setting and remove ignored keywords from the lot." + (let ((keywords (cl-typecase magit-todos-keywords + (symbol (if (and (consp (symbol-value magit-todos-keywords)) + (consp (car (symbol-value magit-todos-keywords)))) + (mapcar #'car (symbol-value magit-todos-keywords)) + (symbol-value magit-todos-keywords))) + (list magit-todos-keywords)))) + (setq magit-todos-keywords-list (seq-difference keywords magit-todos-ignored-keywords)))) + (defun magit-todos--coalesce-groups (groups) "Return GROUPS, coalescing any groups with `equal' keys. GROUPS should be an alist. Assumes that each group contains @@ -1178,6 +1170,7 @@ argument, a list of match items. When SYNC is non-nil, match items are returned." name callback callback) + (magit-todos--compile-keywords-list) (let* ((process-connection-type 'pipe) (directory (f-relative directory default-directory)) (extra-args (when ,extra-args-var