From c832f01d6314b7172bd2fbdaef6ac28f4146cced Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sat, 25 Nov 2023 11:37:16 +0100 Subject: [PATCH] update hl-todo Signed-off-by: Andreas Gerler --- elpa/hl-todo-20200103.1239/hl-todo-pkg.el | 2 - .../hl-todo-autoloads.el | 47 ++++- elpa/hl-todo-20230428.1332/hl-todo-pkg.el | 15 ++ .../hl-todo.el | 176 ++++++++++++------ 4 files changed, 176 insertions(+), 64 deletions(-) delete mode 100644 elpa/hl-todo-20200103.1239/hl-todo-pkg.el rename elpa/{hl-todo-20200103.1239 => hl-todo-20230428.1332}/hl-todo-autoloads.el (58%) create mode 100644 elpa/hl-todo-20230428.1332/hl-todo-pkg.el rename elpa/{hl-todo-20200103.1239 => hl-todo-20230428.1332}/hl-todo.el (68%) diff --git a/elpa/hl-todo-20200103.1239/hl-todo-pkg.el b/elpa/hl-todo-20200103.1239/hl-todo-pkg.el deleted file mode 100644 index e3cf4283..00000000 --- a/elpa/hl-todo-20200103.1239/hl-todo-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "hl-todo" "20200103.1239" "highlight TODO and similar keywords" '((emacs "25")) :commit "3bba4591c54951d2abab113ec5e58a6319808ca9" :keywords '("convenience") :authors '(("Jonas Bernoulli" . "jonas@bernoul.li")) :maintainer '("Jonas Bernoulli" . "jonas@bernoul.li") :url "https://github.com/tarsius/hl-todo") diff --git a/elpa/hl-todo-20200103.1239/hl-todo-autoloads.el b/elpa/hl-todo-20230428.1332/hl-todo-autoloads.el similarity index 58% rename from elpa/hl-todo-20200103.1239/hl-todo-autoloads.el rename to elpa/hl-todo-20230428.1332/hl-todo-autoloads.el index 98e44abf..695a64b0 100644 --- a/elpa/hl-todo-20200103.1239/hl-todo-autoloads.el +++ b/elpa/hl-todo-20230428.1332/hl-todo-autoloads.el @@ -1,4 +1,4 @@ -;;; hl-todo-autoloads.el --- automatically extracted autoloads +;;; hl-todo-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- ;; ;;; Code: @@ -12,8 +12,24 @@ (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. + +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. + \(fn &optional ARG)" t nil) +(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 @@ -27,11 +43,15 @@ or call the function `global-hl-todo-mode'.") (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; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. +otherwise, disable it. + +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. Hl-Todo mode is enabled in all buffers where `hl-todo--turn-on-mode-if-desired' would do it. + See `hl-todo-mode' for more information on Hl-Todo mode. \(fn &optional ARG)" t nil) @@ -55,9 +75,20 @@ 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. +string or comment." t nil) -\(fn)" t nil) +(autoload 'hl-todo-rgrep "hl-todo" "\ +Use `rgrep' 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. See `rgrep' for the meaning of REGEXP, +FILES, DIR and CONFIRM, except that the type of prefix +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) (autoload 'hl-todo-insert "hl-todo" "\ Insert TODO or similar keyword. @@ -68,7 +99,11 @@ current line. \(fn KEYWORD)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "hl-todo" '("hl-todo-"))) +(register-definition-prefixes "hl-todo" '("hl-todo-")) + +;;;*** + +;;;### (autoloads nil nil ("hl-todo-pkg.el") (0 0 0 0)) ;;;*** diff --git a/elpa/hl-todo-20230428.1332/hl-todo-pkg.el b/elpa/hl-todo-20230428.1332/hl-todo-pkg.el new file mode 100644 index 00000000..523edff1 --- /dev/null +++ b/elpa/hl-todo-20230428.1332/hl-todo-pkg.el @@ -0,0 +1,15 @@ +(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-20200103.1239/hl-todo.el b/elpa/hl-todo-20230428.1332/hl-todo.el similarity index 68% rename from elpa/hl-todo-20200103.1239/hl-todo.el rename to elpa/hl-todo-20230428.1332/hl-todo.el index 718ba5cd..ac3b44f0 100644 --- a/elpa/hl-todo-20200103.1239/hl-todo.el +++ b/elpa/hl-todo-20230428.1332/hl-todo.el @@ -1,35 +1,34 @@ -;;; hl-todo.el --- highlight TODO and similar keywords -*- lexical-binding: t -*- +;;; hl-todo.el --- Highlight TODO and similar keywords -*- lexical-binding:t -*- -;; Copyright (C) 2013-2020 Jonas Bernoulli +;; Copyright (C) 2013-2023 Jonas Bernoulli ;; Author: Jonas Bernoulli ;; Homepage: https://github.com/tarsius/hl-todo ;; Keywords: convenience -;; Package-Version: 20200103.1239 -;; Package-Requires: ((emacs "25")) +;; Package-Requires: ((emacs "25.1") (compat "29.1.3.4")) -;; This file is not part of GNU Emacs. - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; SPDX-License-Identifier: GPL-3.0-or-later +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation, either version 3 of the License, +;; or (at your option) any later version. +;; ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . +;; +;; You should have received a copy of the GNU General Public License +;; along with this file. If not, see . ;;; Commentary: ;; 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 +;; or use 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 @@ -40,10 +39,10 @@ ;; 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) +;; (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 @@ -51,10 +50,13 @@ ;;; Code: -(require' cl-lib) +(require 'cl-lib) +(require 'compat) + +(eval-when-compile (require 'subr-x)) -(eval-when-compile - (require 'subr-x)) +(defvar grep-find-template) +(declare-function grep-read-files "grep" (regexp)) (defgroup hl-todo nil "Highlight TODO and similar keywords in comments and strings." @@ -119,7 +121,7 @@ located inside a string." ("HACK" . "#d0bf8f") ("TEMP" . "#d0bf8f") ("FIXME" . "#cc9393") - ("XXX+" . "#cc9393")) + ("XXXX*" . "#cc9393")) "An alist mapping keywords to colors/faces used to display them. Each entry has the form (KEYWORD . COLOR). KEYWORD is used as @@ -129,16 +131,22 @@ Instead of a color (a string), each COLOR may alternatively be a face. The syntax class of the characters at either end has to be `w' -\(which means word) in `hl-todo--syntax-table'. That syntax -table derives from `text-mode-syntax-table' but uses `w' as the -class of \"?\". +\(which means word) in `hl-todo--syntax-table' (which derives +from `text-mode-syntax-table'). This package, like most of Emacs, does not use POSIX regexp backtracking. See info node `(elisp)POSIX Regexp' for why that matters. If you have two keywords \"TODO-NOW\" and \"TODO\", then they must be specified in that order. Alternatively you could -use \"TODO\\(-NOW\\)?\"." - :package-version '(hl-todo . "3.0.0") +use \"TODO\\(-NOW\\)?\". + +If you use the command `hl-todo-rgrep', rewrite KEYWORDs to +use \"*\" instead of \"+\" and generally make sure they are valid +as Emacs regexps and as basic regular expressions as understood +by Grep. If you customize variables in the `grep' group, or use +a Grep implementation other than GNU's, then that may break +`hl-todo-rgrep'." + :package-version '(hl-todo . "3.5.0") :group 'hl-todo :type '(repeat (cons (string :tag "Keyword") (choice :tag "Face " @@ -160,6 +168,12 @@ controls which of the two it is." :group 'hl-todo :type 'boolean) +(defcustom hl-todo-wrap-movement nil + "Whether movement commands wrap around when there are no more matches." + :package-version '(hl-todo . "3.4.0") + :group 'hl-todo + :type 'boolean) + (defcustom hl-todo-highlight-punctuation "" "String of characters to highlight after keywords. @@ -173,6 +187,12 @@ including alphanumeric characters, cannot be used here." :group 'hl-todo :type 'string) +(defcustom hl-todo-require-punctuation nil + "Whether to require punctuation after keywords." + :package-version '(hl-todo . "3.3.0") + :group 'hl-todo + :type 'boolean) + (defvar-local hl-todo--regexp nil) (defvar-local hl-todo--keywords nil) @@ -191,23 +211,27 @@ including alphanumeric characters, cannot be used here." "\\(" (mapconcat #'car hl-todo-keyword-faces "\\|") "\\)" "\\>" (and (not (equal hl-todo-highlight-punctuation "")) - (concat "[" hl-todo-highlight-punctuation "]*")) + (concat "[" hl-todo-highlight-punctuation "]" + (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) t t)))) + `((,(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) (unless regexp (setq regexp hl-todo--regexp)) (cl-block nil - (while (let ((case-fold-search nil)) + (while (let ((case-fold-search nil) + (syntax-ppss-table (syntax-table))) (with-syntax-table hl-todo--syntax-table (funcall (if backward #'re-search-backward #'re-search-forward) regexp bound t))) @@ -223,20 +247,20 @@ including alphanumeric characters, cannot be used here." (defun hl-todo--get-face () (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))))) + (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) - (list :inherit 'hl-todo - (if hl-todo-color-background :background :foreground) - face) + `((,(if hl-todo-color-background :background :foreground) + ,face) + hl-todo) face)) -(defvar hl-todo-mode-map (make-sparse-keymap) - "Keymap for `hl-todo-mode'.") +(defvar-keymap hl-todo-mode-map + :doc "Keymap for `hl-todo-mode'.") ;;;###autoload (define-minor-mode hl-todo-mode @@ -248,11 +272,7 @@ including alphanumeric characters, cannot be used here." (hl-todo--setup) (font-lock-remove-keywords nil hl-todo--keywords)) (when font-lock-mode - (save-excursion - (goto-char (point-min)) - (while (hl-todo--search) - (save-excursion - (font-lock-fontify-region (match-beginning 0) (match-end 0) nil)))))) + (jit-lock-mode 1))) ;;;###autoload (define-globalized-minor-mode global-hl-todo-mode @@ -260,7 +280,8 @@ including alphanumeric characters, cannot be used here." (defun hl-todo--turn-on-mode-if-desired () (when (and (apply #'derived-mode-p hl-todo-include-modes) - (not (apply #'derived-mode-p hl-todo-exclude-modes))) + (not (apply #'derived-mode-p hl-todo-exclude-modes)) + (not (bound-and-true-p enriched-mode))) (hl-todo-mode 1))) ;;;###autoload @@ -278,8 +299,17 @@ A negative argument means move backward that many keywords." (looking-at (hl-todo--regexp))) (goto-char (match-end 0))) (or (hl-todo--search) - (user-error "No more matches")))) - (cl-decf arg)))) + (if hl-todo-wrap-movement + nil + (user-error "No more matches"))))) + (cl-decf arg)) + (when (> arg 0) + (let ((pos (save-excursion + (goto-char (point-min)) + (let ((hl-todo-wrap-movement nil)) + (hl-todo-next arg)) + (point)))) + (goto-char pos))))) ;;;###autoload (defun hl-todo-previous (arg) @@ -295,9 +325,18 @@ A negative argument means move forward that many keywords." (hl-todo--search (concat (hl-todo--regexp) "\\=") nil t) (or (hl-todo--search nil nil t) (progn (goto-char start) - (user-error "No more matches"))))) + (if hl-todo-wrap-movement + nil + (user-error "No more matches")))))) (goto-char (match-end 0)) - (cl-decf arg)))) + (cl-decf arg)) + (when (> arg 0) + (let ((pos (save-excursion + (goto-char (point-max)) + (let ((hl-todo-wrap-movement nil)) + (hl-todo-previous arg)) + (point)))) + (goto-char pos))))) ;;;###autoload (defun hl-todo-occur () @@ -310,6 +349,30 @@ string or comment." (with-syntax-table hl-todo--syntax-table (occur (hl-todo--regexp)))) +;;;###autoload +(defun hl-todo-rgrep (regexp &optional files dir confirm) + "Use `rgrep' 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. See `rgrep' for the meaning of REGEXP, +FILES, DIR and CONFIRM, except that the type of prefix +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'." + (interactive + (progn + (require 'grep) + (grep-compute-defaults) + (unless grep-find-template + (error "grep.el: No `grep-find-template' available")) + (let ((regexp (with-temp-buffer (hl-todo--regexp)))) + (list regexp + (grep-read-files regexp) + (read-directory-name "Base directory: " nil default-directory t) + current-prefix-arg)))) + (rgrep regexp files dir confirm)) + ;;;###autoload (defun hl-todo-insert (keyword) "Insert TODO or similar keyword. @@ -336,17 +399,18 @@ current line." (format "%s %s " comment-start keyword)))) (t (goto-char (line-beginning-position)) - (insert (format "%s %s " - (if (derived-mode-p 'lisp-mode 'emacs-lisp-mode) - (format "%s%s" comment-start comment-start) - comment-start) - keyword)) + (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") + #'hl-todo-insert "hl-todo 3.0.0") ;;; _ (provide 'hl-todo) -- 2.47.3