doomemacs/modules/ui/hl-todo/config.el
Henrik Lissner 1c4217aa27
refactor: minor refactors & commentary revision
* lisp/doom-cli.el:
  - reference backport source commit.
  - doom-cli--restart: a type check is all we need here. This is a
    programmer error, not a user error.
* lisp/doom-editor.el (recentf): mention recentf-show-abbreviated (added in
  emacs-mirror/emacs@32906819ad)
* lisp/doom-keybinds.el (doom-init-leader-keys-h): move to
  doom-after-init-hook, in case the user customizes leader variables in
  a previous hook (like emacs-startup-hook or after-init-hook).
* lisp/doom-start.el: use eval-when! to compile out the section on
  non-macOS systems (when Doom gets around to compiling its core files,
  later).
* modules/config/literate/autoload.el (+literate-config-file): use
  file-name-concat instead of string concat. This relaxes the
  requirement that doom-user-dir end in a /; a requirement I intend to
  fully phase out.
* modules/lang/emacs-lisp/autoload.el (+emacs-lisp-non-package): remove
  empty map! macro in flycheck-emacs-lisp-check-form. The macro already
  no-ops at compile-time/in noninteractive sessions since b480ed51a3.
* modules/ui/hl-todo/config.el (hl-todo-keyword-faces): revise
  commentary for default hl-todo keywords.

Ref: emacs-mirror/emacs@32906819ad
Ref: b480ed51a3
2022-09-24 20:31:34 +02:00

51 lines
2.3 KiB
EmacsLisp

;;; ui/hl-todo/packages.el -*- lexical-binding: t; -*-
(use-package! hl-todo
:hook (prog-mode . hl-todo-mode)
:hook (yaml-mode . hl-todo-mode)
:config
(setq hl-todo-highlight-punctuation ":"
hl-todo-keyword-faces
'(;; For reminders to change or add something at a later date.
("TODO" warning bold)
;; For code (or code paths) that are broken, unimplemented, or slow,
;; and may become bigger problems later.
("FIXME" error bold)
;; For code that needs to be revisited later, either to upstream it,
;; improve it, or address non-critical issues.
("REVIEW" font-lock-keyword-face bold)
;; For code smells where questionable practices are used
;; intentionally, and/or is likely to break in a future update.
("HACK" font-lock-constant-face bold)
;; For sections of code that just gotta go, and will be gone soon.
;; Specifically, this means the code is deprecated, not necessarily
;; the feature it enables.
("DEPRECATED" font-lock-doc-face bold)
;; Extra keywords commonly found in the wild, whose meaning may vary
;; from project to project.
("NOTE" success bold)
("BUG" error bold)
("XXX" font-lock-constant-face bold)))
(defadvice! +hl-todo-clamp-font-lock-fontify-region-a (fn &rest args)
"Fix an `args-out-of-range' error in some modes."
:around #'hl-todo-mode
(letf! (defun font-lock-fontify-region (beg end &optional loudly)
(funcall font-lock-fontify-region (max beg 1) end loudly))
(apply fn args)))
;; Use a more primitive todo-keyword detection method in major modes that
;; don't use/have a valid syntax table entry for comments.
(add-hook! '(pug-mode-hook haml-mode-hook)
(defun +hl-todo--use-face-detection-h ()
"Use a different, more primitive method of locating todo keywords."
(set (make-local-variable 'hl-todo-keywords)
'(((lambda (limit)
(let (case-fold-search)
(and (re-search-forward hl-todo-regexp limit t)
(memq 'font-lock-comment-face (ensure-list (get-text-property (point) 'face))))))
(1 (hl-todo-get-face) t t))))
(when hl-todo-mode
(hl-todo-mode -1)
(hl-todo-mode +1)))))