Function: hl-todo-insert
hl-todo-insert is an interactive and natively compiled function
defined in hl-todo.el.
Signature
(hl-todo-insert KEYWORD)
Documentation
Read a TODO or similar keyword and insert it at point.
If point is not inside a string or comment, then insert a new
comment. If point is at the end of the line, then insert the
comment there, otherwise insert it as a new line before the
current line. When called interactively the KEYWORD is read
via completing-read.
If hl-todo-require-punctuation is non-nil and
hl-todo-highlight-punctuation contains a single character,
then append that character to the inserted string.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/b97f5zr6snxdbh1bgqmj50mq949vd13i-emacs-packages-deps/share/emacs/site-lisp/elpa/hl-todo-20261001.1547/hl-todo.el
;;;###autoload
(defun hl-todo-insert (keyword)
"Read a TODO or similar keyword and insert it at point.
If point is not inside a string or comment, then insert a new
comment. If point is at the end of the line, then insert the
comment there, otherwise insert it as a new line before the
current line. When called interactively the KEYWORD is read
via `completing-read'.
If `hl-todo-require-punctuation' is non-nil and
`hl-todo-highlight-punctuation' contains a single character,
then append that character to the inserted string."
(interactive
(list (completing-read
"Insert keyword: "
(mapcan (pcase-lambda (`(,keyword . ,face))
(and (equal (regexp-quote keyword) keyword)
(list (propertize keyword 'face
(hl-todo--combine-face face)))))
hl-todo-keyword-faces))))
(let ((keyword (if (and hl-todo-require-punctuation
(length= hl-todo-highlight-punctuation 1))
(concat keyword hl-todo-highlight-punctuation)
keyword)))
(cond
((hl-todo--inside-comment-or-string-p)
(insert (concat (and (not (memq (char-before) '(?\s ?\t))) " ")
keyword
(and (not (memq (char-after) '(?\s ?\t ?\n))) " "))))
((and (eolp)
(not (looking-back "^[\s\t]*" (line-beginning-position) t)))
(insert (concat (and (not (memq (char-before) '(?\s ?\t))) " ")
(format "%s %s " comment-start keyword))))
(t
(goto-char (line-beginning-position))
(insert (cond ((derived-mode-p 'lisp-mode 'emacs-lisp-mode)
(format "%s%s %s" comment-start comment-start keyword))
((string-suffix-p " " comment-start)
(format "%s%s" comment-start keyword))
(t
(format "%s %s" comment-start keyword))))
(unless (looking-at "[\s\t]*$")
(save-excursion (insert "\n")))
(indent-region (line-beginning-position) (line-end-position))))))