-
-
Notifications
You must be signed in to change notification settings - Fork 29
Home
hl-todo-mode
uses font-lock but it can also be enabled in buffers
whose major-mode does not use font-lock itself. text-mode
is such
a mode and by default global-hl-todo-mode
enables hl-todo-mode
in buffers using that major-mode.
If font-lock-mode
would not be enabled otherwise, then it is enabled
just for the benefit of hl-todo-mode
. That in turn can conflict
with other things that propertize parts of the buffer without using
font-lock, because the first thing that font-lock does is to remove
such text properties.
Currently if enriched-mode
is enabled in a buffer, then
global-hl-todo-mode
does not enable hl-todo-mode
in that buffer.
Similar kludges can be added for other minor-modes but unfortunately
this has to be done on a case by case basis when users report issues.
Also see #55, and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42138.
tex-mode
and Tex-latex-mode
may discard font-lock keywords that
were added by third-party packages like hl-todo
. Our keywords
therefore have to be forcefully reinstated using:
(add-hook 'TeX-update-style-hook 'hl-todo-mode)
Also see #26, and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37945.
Emacs 30 supports margins indicator instead fringes, this allows indicators to be displayed in TUI/GUI
To enable it, use this code in your configuration:
(put 'hl-todo-flymake 'flymake-margin-string
(alist-get 'hl-todo-flymake flymake-margin-indicators-string))
(add-to-list 'x '(hl-todo-flymake "*" hl-todo-flymake-type))
(setopt flymake-indicator-type 'margins)
In case you want to have a list of all hl-todo keywords of your project you can use magit-todos
On the contrary, if you don't use git you can use this little hack:
;; Example with `nerd-icons`
(defun my/hl-todo-types-icons (locus beg end text _keyword)
(let ((keyword (string-remove-suffix ":" (substring-no-properties _keyword)))
type)
(pcase keyword
("TODO" (setq type (intern-soft (concat "hl-todo-flymake-" keyword))))
("BUG" (setq type (intern-soft (concat "hl-todo-flymake-" keyword))))
("WARNING" (setq type (intern-soft (concat "hl-todo-flymake-" keyword))))
("FIXME" (setq type (intern-soft (concat "hl-todo-flymake-" keyword))))
(_ (setq type 'hl-todo-flymake)))
(flymake-make-diagnostic locus beg end type text)))
(advice-add 'hl-todo-make-flymake-diagnostic :override #'my/hl-todo-types-icons)
(setopt flymake-indicator-type 'margins
flymake-margin-indicators-string
`((error "!!" compilation-error)
(warning "!" compilation-warning)
(note "!" compilation-info)
(hl-todo-flymake ,(nerd-icons-mdicon "nf-md-content_paste") hl-todo-flymake-type)
(hl-todo-flymake-TODO ,(nerd-icons-sucicon "nf-seti-checkbox_unchecked") nerd-icons-blue)
(hl-todo-flymake-BUG ,(nerd-icons-faicon "nf-fa-bug") compilation-error)
(hl-todo-flymake-FIXME ,(nerd-icons-faicon "nf-fa-wrench") compilation-error)
(hl-todo-flymake-WARNING ,(nerd-icons-faicon "nf-fa-flag") compilation-warning)))
(put 'hl-todo-flymake 'flymake-margin-string
(alist-get 'hl-todo-flymake flymake-margin-indicators-string))
(put 'hl-todo-flymake-TODO 'flymake-type-name " TODO")
(put 'hl-todo-flymake-TODO 'flymake-margin-string
(alist-get 'hl-todo-flymake-TODO flymake-margin-indicators-string))
(put 'hl-todo-flymake-TODO 'flymake-category 'flymake-note)
(put 'hl-todo-flymake-TODO 'face nil)
(put 'hl-todo-flymake-TODO 'mode-line-face 'nerd-icons-blue)
(put 'hl-todo-flymake-BUG 'flymake-type-name " BUG")
(put 'hl-todo-flymake-BUG 'flymake-margin-string
(alist-get 'hl-todo-flymake-BUG flymake-margin-indicators-string))
(put 'hl-todo-flymake-BUG 'flymake-category 'flymake-note)
(put 'hl-todo-flymake-BUG 'face nil)
(put 'hl-todo-flymake-BUG 'mode-line-face 'compilation-error)
(put 'hl-todo-flymake-WARNING 'flymake-type-name " WARNING")
(put 'hl-todo-flymake-WARNING 'flymake-margin-string
(alist-get 'hl-todo-flymake-WARNING flymake-margin-indicators-string))
(put 'hl-todo-flymake-WARNING 'flymake-category 'flymake-note)
(put 'hl-todo-flymake-WARNING 'face nil)
(put 'hl-todo-flymake-WARNING 'mode-line-face 'compilation-warning)
(put 'hl-todo-flymake-FIXME 'flymake-type-name " FIXME")
(put 'hl-todo-flymake-FIXME 'flymake-margin-string
(alist-get 'hl-todo-flymake-FIXME flymake-margin-indicators-string))
(put 'hl-todo-flymake-FIXME 'flymake-category 'flymake-note)
(put 'hl-todo-flymake-FIXME 'face nil)
(put 'hl-todo-flymake-FIXME 'mode-line-face 'compilation-error)