blob: 3841c6c608ada8014c9ef69bd690522ef21dca17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#+title: consult-hl-todo
Reworked version of [[https://github.com/eki3z/consult-todo][Eki Zhang's consult-todo.el]]. The reason for the
rewrite was that ~consult-todo-dir~ was completely broken for about a
year.
This library makes good use of =consult='s async pipeline, using it only
to feed in extra candidates and not to rerun the search command.
#+toc: headlines 1
* Setup
Because we use the format =TODO(author): msg=, some manual advising of
=hl-todo= is required for now.
#+begin_src emacs-lisp
(defun cmmm/hl-todo--setup-regexp-advice (&optional no-symbol)
"Advice to make fontification, grep -E and rg work with custom regex"
(when-let ((bomb (assoc "???" hl-todo-keyword-faces)))
;; If the user customized this variable before we started to
;; treat the strings as regexps, then the string "???" might
;; still be present. We have to remove it because it results
;; in the regexp search taking forever.
(setq hl-todo-keyword-faces (delete bomb hl-todo-keyword-faces)))
(setq hl-todo--regexp
(concat (if no-symbol "(" "\\(")
(pcase hl-todo-keyword-delimiters
('symbol (if no-symbol "\\<" "\\_<"))
('word "\\<")
(_ ""))
(if no-symbol "(" "\\(")
(mapconcat #'car hl-todo-keyword-faces
(if no-symbol "|" "\\|"))
(if no-symbol ")" "\\)")
(pcase hl-todo-keyword-delimiters
('symbol (if no-symbol "\\>" "\\_>"))
('word "\\>")
(_ ""))
(if no-symbol "(\\([^)]*\\)|)" "\\(?:(\\([^)]*\\))\\)?")
(and (not (equal hl-todo-highlight-punctuation ""))
(concat "[" hl-todo-highlight-punctuation "]"
(if hl-todo-require-punctuation "+" "*")))
(if no-symbol ")" "\\)"))))
(advice-add 'hl-todo--setup-regexp :override #'cmmm/hl-todo--setup-regexp-advice)
#+end_src
* Usage
- =M-x consult-hl-todo <RET>=
- =M-x consult-hl-todo-buffer-file <RET>=
|