From 28d321e5d662a71557730c736564c4a5147db520 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:03:51 +0100 Subject: [PATCH] update hl-todo Signed-off-by: Andreas Gerler --- elpa/hl-todo-20230428.1332/hl-todo-pkg.el | 15 -- .../hl-todo-autoloads.el | 79 +++--- elpa/hl-todo-20240805.1444/hl-todo-pkg.el | 11 + .../hl-todo.el | 230 ++++++++++++------ elpa/hl-todo-readme.txt | 22 -- 5 files changed, 203 insertions(+), 154 deletions(-) delete mode 100644 elpa/hl-todo-20230428.1332/hl-todo-pkg.el rename elpa/{hl-todo-20230428.1332 => hl-todo-20240805.1444}/hl-todo-autoloads.el (66%) create mode 100644 elpa/hl-todo-20240805.1444/hl-todo-pkg.el rename elpa/{hl-todo-20230428.1332 => hl-todo-20240805.1444}/hl-todo.el (65%) delete mode 100644 elpa/hl-todo-readme.txt diff --git a/elpa/hl-todo-20230428.1332/hl-todo-pkg.el b/elpa/hl-todo-20230428.1332/hl-todo-pkg.el deleted file mode 100644 index 523edff1..00000000 --- a/elpa/hl-todo-20230428.1332/hl-todo-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "hl-todo" "20230428.1332" "Highlight TODO and similar keywords" - '((emacs "25.1") - (compat "29.1.3.4")) - :commit "b27cddf7373408681cc949c8ef829f87a01ed3f3" :authors - '(("Jonas Bernoulli" . "jonas@bernoul.li")) - :maintainers - '(("Jonas Bernoulli" . "jonas@bernoul.li")) - :maintainer - '("Jonas Bernoulli" . "jonas@bernoul.li") - :keywords - '("convenience") - :url "https://github.com/tarsius/hl-todo") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/hl-todo-20230428.1332/hl-todo-autoloads.el b/elpa/hl-todo-20240805.1444/hl-todo-autoloads.el similarity index 66% rename from elpa/hl-todo-20230428.1332/hl-todo-autoloads.el rename to elpa/hl-todo-20240805.1444/hl-todo-autoloads.el index 695a64b0..9179f113 100644 --- a/elpa/hl-todo-20230428.1332/hl-todo-autoloads.el +++ b/elpa/hl-todo-20240805.1444/hl-todo-autoloads.el @@ -1,35 +1,35 @@ -;;; hl-todo-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; hl-todo-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "hl-todo" "hl-todo.el" (0 0 0 0)) ;;; Generated autoloads from hl-todo.el (autoload 'hl-todo-mode "hl-todo" "\ Highlight TODO and similar keywords in comments and strings. -This is a minor mode. If called interactively, toggle the -`Hl-Todo mode' mode. If the prefix argument is positive, enable -the mode, and if it is zero or negative, disable the mode. +This is a minor mode. If called interactively, toggle the `Hl-Todo +mode' mode. If the prefix argument is positive, enable the mode, and if +it is zero or negative, disable the mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, -evaluate `hl-todo-mode'. - -The mode's hook is called both when the mode is enabled and when -it is disabled. +evaluate the variable `hl-todo-mode'. -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (put 'global-hl-todo-mode 'globalized-minor-mode t) - (defvar global-hl-todo-mode nil "\ Non-nil if Global Hl-Todo mode is enabled. See the `global-hl-todo-mode' command @@ -37,9 +37,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `global-hl-todo-mode'.") - (custom-autoload 'global-hl-todo-mode "hl-todo" nil) - (autoload 'global-hl-todo-mode "hl-todo" "\ Toggle Hl-Todo mode in all buffers. With prefix ARG, enable Global Hl-Todo mode if ARG is positive; @@ -54,29 +52,25 @@ Hl-Todo mode is enabled in all buffers where See `hl-todo-mode' for more information on Hl-Todo mode. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'hl-todo-next "hl-todo" "\ Jump to the next TODO or similar keyword. The prefix argument ARG specifies how many keywords to move. A negative argument means move backward that many keywords. -\(fn ARG)" t nil) - +(fn ARG)" t) (autoload 'hl-todo-previous "hl-todo" "\ Jump to the previous TODO or similar keyword. The prefix argument ARG specifies how many keywords to move. A negative argument means move forward that many keywords. -\(fn ARG)" t nil) - +(fn ARG)" t) (autoload 'hl-todo-occur "hl-todo" "\ Use `occur' to find all TODO or similar keywords. This actually finds a superset of the highlighted keywords, because it uses a regexp instead of a more sophisticated matcher. It also finds occurrences that are not within a -string or comment." t nil) - +string or comment." t) (autoload 'hl-todo-rgrep "hl-todo" "\ Use `rgrep' to find all TODO or similar keywords. This actually finds a superset of the highlighted keywords, @@ -88,29 +82,40 @@ argument does not matter; with any prefix you can edit the constructed shell command line before it is executed. Also see option `hl-todo-keyword-faces'. -\(fn REGEXP &optional FILES DIR CONFIRM)" t nil) +(fn REGEXP &optional FILES DIR CONFIRM)" t) +(autoload 'hl-todo-flymake "hl-todo" "\ +Flymake backend for `hl-todo-mode'. +Diagnostics are reported to REPORT-FN. Use `add-hook' to +register this function in `flymake-diagnostic-functions' before +enabling `flymake-mode'. +(fn REPORT-FN &rest PLIST)") (autoload 'hl-todo-insert "hl-todo" "\ -Insert TODO or similar 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. +current line. When called interactively the KEYWORD is read +via `completing-read'. -\(fn KEYWORD)" t nil) +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. +(fn KEYWORD)" t) (register-definition-prefixes "hl-todo" '("hl-todo-")) - -;;;*** -;;;### (autoloads nil nil ("hl-todo-pkg.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'hl-todo-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; hl-todo-autoloads.el ends here diff --git a/elpa/hl-todo-20240805.1444/hl-todo-pkg.el b/elpa/hl-todo-20240805.1444/hl-todo-pkg.el new file mode 100644 index 00000000..39645c55 --- /dev/null +++ b/elpa/hl-todo-20240805.1444/hl-todo-pkg.el @@ -0,0 +1,11 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "hl-todo" "20240805.1444" + "Highlight TODO and similar keywords." + '((emacs "26.1") + (compat "30.0.0.0")) + :url "https://github.com/tarsius/hl-todo" + :commit "82eba6b8f7b5a4cbcf22436d5c5b88fb3134f57e" + :revdesc "82eba6b8f7b5" + :keywords '("convenience") + :authors '(("Jonas Bernoulli" . "emacs.hl-todo@jonas.bernoulli.dev")) + :maintainers '(("Jonas Bernoulli" . "emacs.hl-todo@jonas.bernoulli.dev"))) diff --git a/elpa/hl-todo-20230428.1332/hl-todo.el b/elpa/hl-todo-20240805.1444/hl-todo.el similarity index 65% rename from elpa/hl-todo-20230428.1332/hl-todo.el rename to elpa/hl-todo-20240805.1444/hl-todo.el index ac3b44f0..18f4343c 100644 --- a/elpa/hl-todo-20230428.1332/hl-todo.el +++ b/elpa/hl-todo-20240805.1444/hl-todo.el @@ -1,12 +1,14 @@ ;;; hl-todo.el --- Highlight TODO and similar keywords -*- lexical-binding:t -*- -;; Copyright (C) 2013-2023 Jonas Bernoulli +;; Copyright (C) 2013-2024 Jonas Bernoulli -;; Author: Jonas Bernoulli +;; Author: Jonas Bernoulli ;; Homepage: https://github.com/tarsius/hl-todo ;; Keywords: convenience -;; Package-Requires: ((emacs "25.1") (compat "29.1.3.4")) +;; Package-Version: 20240805.1444 +;; Package-Revision: 82eba6b8f7b5 +;; Package-Requires: ((emacs "26.1") (compat "30.0.0.0")) ;; SPDX-License-Identifier: GPL-3.0-or-later @@ -39,24 +41,20 @@ ;; known keywords, and to insert a keyword. If you want to use these ;; commands, then you should bind them in `hl-todo-mode-map', e.g.: ;; -;; (define-key hl-todo-mode-map (kbd "C-c p") #'hl-todo-previous) -;; (define-key hl-todo-mode-map (kbd "C-c n") #'hl-todo-next) -;; (define-key hl-todo-mode-map (kbd "C-c o") #'hl-todo-occur) -;; (define-key hl-todo-mode-map (kbd "C-c i") #'hl-todo-insert) - -;; See [[https://www.emacswiki.org/emacs/FixmeMode][this list]] on the Emacswiki for other packages that implement -;; the same basic features, but which might also provide additional -;; features that you might like, but which I don't deem necessary. +;; (keymap-set hl-todo-mode-map "C-c p" #'hl-todo-previous) +;; (keymap-set hl-todo-mode-map "C-c n" #'hl-todo-next) +;; (keymap-set hl-todo-mode-map "C-c o" #'hl-todo-occur) +;; (keymap-set hl-todo-mode-map "C-c i" #'hl-todo-insert) ;;; Code: -(require 'cl-lib) (require 'compat) - (eval-when-compile (require 'subr-x)) +(eval-when-compile (require 'cl-lib)) (defvar grep-find-template) (declare-function grep-read-files "grep" (regexp)) +(declare-function flymake-make-diagnostic "flymake") (defgroup hl-todo nil "Highlight TODO and similar keywords in comments and strings." @@ -71,17 +69,14 @@ color specified using the option `hl-todo-keyword-faces' as foreground color." :group 'hl-todo) -(define-obsolete-variable-alias 'hl-todo-activate-in-modes - 'hl-todo-include-modes "hl-todo 3.1.0") - -(defcustom hl-todo-include-modes '(prog-mode text-mode) +(defcustom hl-todo-include-modes '(prog-mode text-mode conf-mode) "Major-modes in which `hl-todo-mode' is activated. This is used by `global-hl-todo-mode', which activates the local `hl-todo-mode' in all buffers whose major-mode derive from one of the modes listed here, but not from one of the modes listed in `hl-todo-exclude-modes'." - :package-version '(hl-todo . "2.1.0") + :package-version '(hl-todo . "3.7.0") :group 'hl-todo :type '(repeat function)) @@ -107,16 +102,17 @@ located inside a string." :type '(repeat function)) (defcustom hl-todo-keyword-faces - '(("HOLD" . "#d0bf8f") - ("TODO" . "#cc9393") - ("NEXT" . "#dca3a3") - ("THEM" . "#dc8cc3") - ("PROG" . "#7cb8bb") - ("OKAY" . "#7cb8bb") - ("DONT" . "#5f7f5f") - ("FAIL" . "#8c5353") - ("DONE" . "#afd8af") + '(("HOLD" . "#d0bf8f") + ("TODO" . "#cc9393") + ("NEXT" . "#dca3a3") + ("THEM" . "#dc8cc3") + ("PROG" . "#7cb8bb") + ("OKAY" . "#7cb8bb") + ("DONT" . "#5f7f5f") + ("FAIL" . "#8c5353") + ("DONE" . "#afd8af") ("NOTE" . "#d0bf8f") + ("MAYBE" . "#d0bf8f") ("KLUDGE" . "#d0bf8f") ("HACK" . "#d0bf8f") ("TEMP" . "#d0bf8f") @@ -151,7 +147,16 @@ a Grep implementation other than GNU's, then that may break :type '(repeat (cons (string :tag "Keyword") (choice :tag "Face " (string :tag "Color") - (sexp :tag "Face"))))) + (sexp :tag "Face")))) + :set (lambda (symbol value) + (set-default-toplevel-value symbol value) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (when (and (bound-and-true-p hl-todo-mode) + (boundp 'hl-todo--regexp)) + (setq hl-todo--regexp nil) + (hl-todo-mode -1) + (hl-todo-mode 1)))))) (defcustom hl-todo-color-background nil "Whether to emphasize keywords using the background color. @@ -193,13 +198,19 @@ including alphanumeric characters, cannot be used here." :group 'hl-todo :type 'boolean) +(defvar hl-todo--keywords + `((,(lambda (bound) (hl-todo--search nil bound)) + (1 (hl-todo--get-face) prepend t)))) + (defvar-local hl-todo--regexp nil) -(defvar-local hl-todo--keywords nil) -(defun hl-todo--regexp () +(defsubst hl-todo--regexp () + "Return regular expression matching TODO or similar keyword." (or hl-todo--regexp (hl-todo--setup-regexp))) (defun hl-todo--setup-regexp () + "Setup keyword regular expression. +See the function `hl-todo--regexp'." (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 @@ -215,20 +226,14 @@ including alphanumeric characters, cannot be used here." (if hl-todo-require-punctuation "+" "*"))) "\\)"))) -(defun hl-todo--setup () - (hl-todo--setup-regexp) - (setq hl-todo--keywords - `((,(lambda (bound) (hl-todo--search nil bound)) - (1 (hl-todo--get-face) prepend t)))) - (font-lock-add-keywords nil hl-todo--keywords t)) - (defvar hl-todo--syntax-table (copy-syntax-table text-mode-syntax-table)) -(defvar syntax-ppss-table) ; Silence Emacs 25's byte-compiler. - (defun hl-todo--search (&optional regexp bound backward) + "Search for keyword REGEXP, optionally up to BOUND and BACKWARD. +If REGEXP is not given, it defaults to the return value of the +function `hl-todo--regexp'." (unless regexp - (setq regexp hl-todo--regexp)) + (setq regexp (hl-todo--regexp))) (cl-block nil (while (let ((case-fold-search nil) (syntax-ppss-table (syntax-table))) @@ -242,22 +247,29 @@ including alphanumeric characters, cannot be used here." (cl-return nil)))))) (defun hl-todo--inside-comment-or-string-p () + "Check syntax state if point is located inside comment or string literal." (nth 8 (syntax-ppss))) (defun hl-todo--get-face () + "Return face for current keyword during font locking." (let ((keyword (match-string 2))) (hl-todo--combine-face - (cdr (cl-find-if (lambda (elt) - (string-match-p (format "\\`%s\\'" (car elt)) - keyword)) - hl-todo-keyword-faces))))) - -(defun hl-todo--combine-face (face) - (if (stringp face) + (cdr (or + ;; Fast allocation free lookup for literal keywords. + (assoc keyword hl-todo-keyword-faces) + ;; Slower regexp lookup. + (compat-call assoc keyword hl-todo-keyword-faces + (lambda (a b) + (string-match-p (format "\\`%s\\'" a) b)))))))) + +(defun hl-todo--combine-face (color) + "Combine COLOR string with `hl-todo' default face. +If COLOR is a face symbol, do not combine, return COLOR instead." + (if (stringp color) `((,(if hl-todo-color-background :background :foreground) - ,face) + ,color) hl-todo) - face)) + color)) (defvar-keymap hl-todo-mode-map :doc "Keymap for `hl-todo-mode'.") @@ -269,7 +281,7 @@ including alphanumeric characters, cannot be used here." :keymap hl-todo-mode-map :group 'hl-todo (if hl-todo-mode - (hl-todo--setup) + (font-lock-add-keywords nil hl-todo--keywords t) (font-lock-remove-keywords nil hl-todo--keywords)) (when font-lock-mode (jit-lock-mode 1))) @@ -279,6 +291,8 @@ including alphanumeric characters, cannot be used here." hl-todo-mode hl-todo--turn-on-mode-if-desired) (defun hl-todo--turn-on-mode-if-desired () + "Enable local minor mode `hl-todo-mode' if test succeeds. +Depends on `hl-todo-include-modes' and `hl-todo-exclude-modes'." (when (and (apply #'derived-mode-p hl-todo-include-modes) (not (apply #'derived-mode-p hl-todo-exclude-modes)) (not (bound-and-true-p enriched-mode))) @@ -373,44 +387,100 @@ Also see option `hl-todo-keyword-faces'." current-prefix-arg)))) (rgrep regexp files dir confirm)) +;;;###autoload +(defun hl-todo-flymake (report-fn &rest _plist) + "Flymake backend for `hl-todo-mode'. +Diagnostics are reported to REPORT-FN. Use `add-hook' to +register this function in `flymake-diagnostic-functions' before +enabling `flymake-mode'." + (let ((diags nil) + (buf (current-buffer)) + (comment (concat (regexp-quote comment-start) "\\s-+"))) + (when hl-todo-mode + (save-excursion + (save-restriction + (save-match-data + (goto-char (point-min)) + (while (hl-todo--search) + (let ((beg (match-beginning 0)) + (end (pos-eol)) + (bol (pos-bol))) + ;; Take whole line when keyword is not at the start of comment. + (save-excursion + (goto-char beg) + (unless (looking-back comment bol) + (goto-char bol) + ;; Skip whitespace at the beginning of line. + (when (and (not (looking-at-p "\\S-")) + (re-search-forward "\\S-" beg t)) + (forward-char -1)) + ;; Skip comment. + (re-search-forward comment beg t) + (setq beg (point)))) + (push (flymake-make-diagnostic + buf beg end :note + (buffer-substring-no-properties beg end)) + diags))))))) + (funcall report-fn (nreverse diags)))) + ;;;###autoload (defun hl-todo-insert (keyword) - "Insert TODO or similar 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." +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: " - (cl-mapcan (pcase-lambda (`(,keyword . ,face)) - (and (equal (regexp-quote keyword) keyword) - (list (propertize keyword 'face - (hl-todo--combine-face face))))) - hl-todo-keyword-faces)))) - (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))))) - -(define-obsolete-function-alias 'hl-todo-insert-keyword - #'hl-todo-insert "hl-todo 3.0.0") + (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)))))) + +(defun hl-todo-magit-revision () + "Highlight TODO and similar keywords in commit messages and notes. +If `global-hl-todo-mode' is disabled, do nothing." + (when global-hl-todo-mode + (let ((case-fold-search nil) + (regexp (hl-todo--regexp))) + (while (re-search-forward regexp nil t) + (put-text-property (match-beginning 1) + (match-end 1) + 'font-lock-face (hl-todo--get-face)))))) + +(add-hook 'magit-wash-message-hook #'hl-todo-magit-revision) ;;; _ (provide 'hl-todo) diff --git a/elpa/hl-todo-readme.txt b/elpa/hl-todo-readme.txt deleted file mode 100644 index 78709f5d..00000000 --- a/elpa/hl-todo-readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -Highlight TODO and similar keywords in comments and strings. - -You can either explicitly turn on `hl-todo-mode' in certain buffers -or use the the global variant `global-hl-todo-mode', which enables -the local mode based on each buffer's major-mode and the options -`hl-todo-include-modes' and `hl-todo-exclude-modes'. By default -`hl-todo-mode' is enabled for all buffers whose major-mode derive -from either `prog-mode' or `text-mode', except `org-mode'. - -This package also provides commands for moving to the next or -previous keyword, to invoke `occur' with a regexp that matches all -known keywords, and to insert a keyword. If you want to use these -commands, then you should bind them in `hl-todo-mode-map', e.g.: - - (define-key hl-todo-mode-map (kbd "C-c p") 'hl-todo-previous) - (define-key hl-todo-mode-map (kbd "C-c n") 'hl-todo-next) - (define-key hl-todo-mode-map (kbd "C-c o") 'hl-todo-occur) - (define-key hl-todo-mode-map (kbd "C-c i") 'hl-todo-insert) - -See [[https://www.emacswiki.org/emacs/FixmeMode][this list]] on the Emacswiki for other packages that implement -the same basic features, but which might also provide additional -features that you might like, but which I don't deem necessary. -- 2.47.3