From 3c30daf8a5c3424ad05d9637c30567d56004269d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 25 Jan 2022 16:54:47 -0600 Subject: Add function `font-lock-todo-insinuate' --- init.el | 4 +--- lisp/acdw.el | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index 21647cd..ed7252e 100644 --- a/init.el +++ b/init.el @@ -45,9 +45,7 @@ ;; "C-x C-3" #'+split-window-right-then ) ;; Font-lock keywords - (font-lock-add-keywords - nil - '(("\\<\\(TODO\\|XXX\\|FIXME\\|BUG\\):" 1 font-lock-warning-face t))) + (add-hook 'prog-mode-hook #'font-lock-todo-insinuate) ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults (global-set-key (kbd "C-h") 'delete-backward-char) (keyboard-translate ?\C-h ?\C-?) diff --git a/lisp/acdw.el b/lisp/acdw.el index 4e5afb5..d805a10 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -222,5 +222,24 @@ UNIT can be one of :kb, :mb, :gb, :tb, :pb, :eb, :zb, :yb; :kib, :mib, :gib, (:zib (* 1024 1024 1024 1024 1024 1024 1024)) (:yib (* 1024 1024 1024 1024 1024 1024 1024 1024))))) +;;; Font lock TODO keywords + +(defcustom font-lock-todo-keywords '("TODO" "XXX" "FIXME" "BUG") + "Keywords to highlight with `font-lock-todo-face'.") + +(defface font-lock-todo-face '((t :inherit font-lock-warning-face)) + "Face for TODO keywords.") + +(defun font-lock-todo-insinuate () + (let ((keyword-regexp + (rx bow (group (eval (let ((lst '(or))) + (dolist (kw font-lock-todo-keywords) + (push kw lst)) + (nreverse lst)))) + ":"))) + (font-lock-add-keywords + nil + `((,keyword-regexp 1 'font-lock-todo-face prepend))))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81