branch: externals/hyperbole commit 277dacbf0a0f56f1966bce32224652ad345ffa97 Author: Mats Lidell <mats.lid...@lidells.se> Commit: Mats Lidell <mats.lid...@lidells.se>
Add file exist check in ripgrep-msg and a test case --- ChangeLog | 6 ++++++ hibtypes.el | 5 +++-- test/hibtypes-tests.el | 28 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c5a236c28..5233c20b93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-08-23 Mats Lidell <ma...@gnu.org> + +* hibtypes.el (ripgrep-msg): Add check of file exist. + +* test/hibtypes-tests.el (ibtypes::ripgrep-msg-test): Test ripgrep-msg. + 2024-08-18 Bob Weiner <r...@gnu.org> * hywiki.el (hywiki-maybe-at-wikiword-beginning): Fix to handle word diff --git a/hibtypes.el b/hibtypes.el index faeaac5ea9..517cca26d7 100644 --- a/hibtypes.el +++ b/hibtypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 20:45:31 -;; Last-Mod: 18-Aug-24 at 09:14:53 by Mats Lidell +;; Last-Mod: 23-Aug-24 at 21:28:35 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -997,7 +997,8 @@ than a helm completion buffer)." (looking-at "[1-9][0-9]*[-:]\\|--$"))) (unless (or (looking-at "[1-9][0-9]*[-:]\\|--$") (and (setq file (buffer-substring-no-properties (line-beginning-position) (line-end-position))) - (string-empty-p (string-trim file)))) + (or (string-empty-p (string-trim file)) + (not (file-exists-p (string-trim file)))))) (ibut:label-set (concat file ":" line-num)) (hact 'hib-link-to-file-line file line-num))))))) diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el index 5d0c334f70..acac882990 100644 --- a/test/hibtypes-tests.el +++ b/test/hibtypes-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 20-Feb-21 at 23:45:00 -;; Last-Mod: 5-Aug-24 at 17:37:57 by Mats Lidell +;; Last-Mod: 10-Aug-24 at 23:27:05 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -297,7 +297,33 @@ ;; ipython-stack-frame ;; ripgrep-msg +(ert-deftest ibtypes::ripgrep-msg-test () + "Verify `ripgrep-msg'." + ;; Date is picked up as a line number but file existence test before + ;; concluding it is a button save it from being identified as + ;; a ripgrep-msg. + (with-temp-buffer + (insert "one two three\n2024-07-30 line\n") + (goto-line 2) + (should-not (eq (hattr:get (hbut:at-p) 'actype) 'hib-link-to-file-line)) + (should-not (ibtypes::ripgrep-msg))) + ;; Regular ripgrep-msg case. + (with-temp-buffer + (insert "hibtypes.el\n20: line\n") + (goto-line 2) + (mocklet (((hib-link-to-file-line "hibtypes.el" "20") => t) + ((file-exists-p "hibtypes.el") => t)) + (should (eq (hattr:get (hbut:at-p) 'actype) 'hib-link-to-file-line)) + (should (ibtypes::ripgrep-msg)))) + + ;; Regular match but file does not exist case. + (with-temp-buffer + (insert "unknown-file\n20: line\n") + (goto-line 2) + (should-not (eq (hattr:get (hbut:at-p) 'actype) 'hib-link-to-file-line)) + (should-not (ibtypes::ripgrep-msg)))) + ;; grep-msg ;; debugger-source