branch: externals/hyperbole commit a24e447c214c658bea898ca0b1afd9985e3f5772 Merge: 8f7f26468a daf4aa7e2a Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Merge branch 'master' into rsw --- ChangeLog | 26 ++++++++++++++++ Makefile | 6 ++-- hibtypes.el | 4 +-- hpath.el | 20 ++++++++----- install-test/melpa/.emacs | 13 ++++++++ man/hyperbole.texi | 4 ++- test/hpath-tests.el | 14 ++++++++- test/hui-tests.el | 76 ++++++++++++++++++++++++++++++++++++++++++++--- 8 files changed, 144 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88ed7f0110..1c31b5a05e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,32 @@ hyrolo-logic.el (hyrolo-<logical-operator>): No longer send a nil second arg to the 'hyrolo-next-match-function' call; no longer needed. +2024-03-29 Mats Lidell <ma...@gnu.org> + +* Makefile: Add install-melpa target. Used to validate hyperbole can be + installed from melpa. +* install-test/melpa/.emacs: .emacs used for the melpa install test. + +2024-03-24 Mats Lidell <ma...@gnu.org> + +* test/hui-tests.el (hui--ibut-link-directly-to-file) + (hui--ibut-link-directly-to-org-body, hui--gbut-link-directly-ibut): + Use L and C format for pathnames. + +* test/hpath-tests.el (hpath--hpath:line-and-column-regexp): Verify hpath:line-and-column-regexp. + +* hpath.el (hpath:section-line-and-column-regexp): Add optional line and + column chars, L and C, to regexp. + (hpath:file-position-to-line-and-column): Use L and C as standard + format for pathnames with line and column. + +2024-03-23 Mats Lidell <ma...@gnu.org> + +* test/hui-tests.el (hui--ibut-link-directly-to-org-header-first-column) + (hui--ibut-link-directly-to-org-header-second-column) + (hui--ibut-link-directly-to-org-body): Add tests for ibut links to org + mode files. + 2024-03-21 Mats Lidell <ma...@gnu.org> * .github/workflows/main.yml (jobs): Ensure grep for warnings does not diff --git a/Makefile b/Makefile index caa5789da1..94b6941604 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Author: Bob Weiner # # Orig-Date: 15-Jun-94 at 03:42:38 -# Last-Mod: 22-Mar-24 at 08:48:26 by Bob Weiner +# Last-Mod: 29-Mar-24 at 23:29:53 by Mats Lidell # # Copyright (C) 1994-2023 Free Software Foundation, Inc. # See the file HY-COPY for license information. @@ -523,9 +523,9 @@ test-all-output: # Hyperbole install tests - Verify that hyperbole can be installed # using different sources. See folder "install-test" .PHONY: install-elpa install-elpa-devel install-tarball install-straight install-all install-local -install-all: install-elpa install-elpa-devel install-tarball install-straight install-local +install-all: install-elpa install-elpa-devel install-melpa install-tarball install-straight install-local -install-elpa install-elpa-devel install-tarball install-straight install-elpaca: +install-elpa install-elpa-devel install-tarball install-melpa install-straight install-elpaca: @echo "Install Hyperbole using $@" (cd ./install-test/ && ./local-install-test.sh $(subst install-,,$@)) diff --git a/hibtypes.el b/hibtypes.el index 283aee77dd..4135151230 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: 4-Mar-24 at 00:37:13 by Bob Weiner +;; Last-Mod: 27-Mar-24 at 20:15:24 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -850,7 +850,7 @@ e.g. <ilink: my series of keys: ${hyperb:dir}/HYPB>." "Display path at position given by a pathname:line-num[:column-num] pattern. Also works for remote pathnames. May also contain hash-style link references with the following format: -\"<path>[#<link-anchor>]:<line-num>[:<column-num>]}\". +\"<path>[#<link-anchor>]:[L]<line-num>[:[C]<column-num>]}\". See `hpath:at-p' function documentation for possible delimiters. See `hpath:suffixes' variable documentation for suffixes that are added to or diff --git a/hpath.el b/hpath.el index a7a6161b27..dff3d5333d 100644 --- a/hpath.el +++ b/hpath.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 1-Nov-91 at 00:44:23 -;; Last-Mod: 21-Mar-24 at 16:06:32 by Bob Weiner +;; Last-Mod: 27-Mar-24 at 20:22:55 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -108,11 +108,12 @@ Posix has colon-separated and Windows has semicolon-separated path variable values.") (defconst hpath:section-line-and-column-regexp - "\\([^ \t\n\r\f:][^\t\n\r\f:]+\\(:[^0-9\t\n\r\f]*\\)*\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?$" - "Regexp that matches to a path with optional #section and :line-num:col-num. -Grouping 1 is path, grouping 3 is line number, grouping 4 is -column number. Allow for \\='c:' single letter drive prefixes on -MSWindows and Elisp vars with colons in them.") + "\\([^ \t\n\r\f:][^\t\n\r\f:]+\\(:[^0-9\t\n\r\f]*\\)*\\):L?\\([0-9]+\\)\\(:C?\\([0-9]+\\)\\)?$" + "Regexp that matches to a path with optional #section and :line:col. +Grouping 1 is path, grouping 3 is line number, grouping 4 is column +number. Allow for \\='c:' single letter drive prefixes on MSWindows and +Elisp vars with colons in them. Line and column can include a leading +and optional character, L for line and C for column.") (defconst hpath:variable-regexp "\\$@?\{\\([^\}]+\\)@?\}" "Regexp matching variable names that Hyperbole resolves within pathnames. @@ -1383,8 +1384,8 @@ The path in the result is abbreviated when possible." (save-excursion (goto-char position) (if (zerop (current-column)) - (format "%s:%d" (hpath:shorten path) (line-number-at-pos (point) t)) - (format "%s:%d:%d" + (format "%s:L%d" (hpath:shorten path) (line-number-at-pos (point) t)) + (format "%s:L%d:C%d" (hpath:shorten path) (line-number-at-pos (point) t) (current-column)))))) @@ -1426,6 +1427,9 @@ If PATHNAME does not start with a prefix character: of the link anchor and in the case of Koutlines, relative to the indent of the cell; + Line and column can also include a leading and optional character, L + for line and C for column, e.g. \"~/.bashrc:L20:C5\". + if it matches a regular expression in the alist returned by (hpath:get-external-display-alist), invoke the associated external display program; diff --git a/install-test/melpa/.emacs b/install-test/melpa/.emacs new file mode 100644 index 0000000000..890dafe36d --- /dev/null +++ b/install-test/melpa/.emacs @@ -0,0 +1,13 @@ +;; .emacs + +(when (< emacs-major-version 27) + (error "Hyperbole requires Emacs 27 or above; you are running version %d" emacs-major-version)) +(require 'package) +(setq package-native-compile t) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) +(unless (package-installed-p 'hyperbole) + (package-refresh-contents) + (package-install 'hyperbole)) +(hyperbole-mode 1) + +(message "%s" "Hyperbole successfully installed and activated") diff --git a/man/hyperbole.texi b/man/hyperbole.texi index bc8a07e22c..cf419409b2 100644 --- a/man/hyperbole.texi +++ b/man/hyperbole.texi @@ -7,7 +7,7 @@ @c Author: Bob Weiner @c @c Orig-Date: 6-Nov-91 at 11:18:03 -@c Last-Mod: 10-Mar-24 at 14:21:23 by Bob Weiner +@c Last-Mod: 27-Mar-24 at 20:28:14 by Mats Lidell @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -2562,6 +2562,8 @@ Make a valid @file{pathname:line-num[:column-num]} pattern display the path at @emph{line-num} and optional @emph{column-num}. Also works for remote pathnames. May also contain hash-style link references with the following format: @file{<path>[#<link-anchor>]:<line-num>[:<column-num>]}. +Line and column can also include a leading and optional character, L +for line and C for column. @findex ibtypes ilink @cindex implicit button link diff --git a/test/hpath-tests.el b/test/hpath-tests.el index 7df80ab1b5..fe79ceb4d9 100644 --- a/test/hpath-tests.el +++ b/test/hpath-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 28-Feb-21 at 23:26:00 -;; Last-Mod: 21-Feb-24 at 23:57:35 by Mats Lidell +;; Last-Mod: 24-Mar-24 at 10:10:33 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -379,5 +379,17 @@ (hy-delete-file-and-buffer f)) (delete-directory temp-dir)))) +(ert-deftest hpath--hpath:line-and-column-regexp () + "Verify that the regexp identifies paths with line and optional column. +See `hpath:line-and-column-regexp'." + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:1:2")) + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:L1:2")) + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:1:C2")) + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:L1:C2")) + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:1")) + (should (string-match hpath:line-and-column-regexp "/foo/bar.org:L1")) + (should-not (string-match hpath:line-and-column-regexp "/foo/bar.org:LL1")) + (should-not (string-match hpath:line-and-column-regexp "/foo/bar.org:C1"))) + (provide 'hpath-tests) ;;; hpath-tests.el ends here diff --git a/test/hui-tests.el b/test/hui-tests.el index 38f2553282..b4d6975b81 100644 --- a/test/hui-tests.el +++ b/test/hui-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 21-Feb-24 at 23:53:09 by Mats Lidell +;; Last-Mod: 21-Mar-24 at 17:30:27 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -784,7 +784,7 @@ With point on label suggest that ibut for rename." (find-file filea) (hui:ibut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb))) - (should (string= (buffer-string) (concat "\"" fileb ":1:10\"")))) + (should (string= (buffer-string) (concat "\"" fileb ":L1:C10\"")))) (hy-delete-file-and-buffer filea) (hy-delete-file-and-buffer fileb)))) @@ -827,7 +827,75 @@ With point on label suggest that ibut for rename." (find-file filea) (with-simulated-input "label RET" (hui:ibut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb)) 4)) - (should (string= (buffer-string) (concat "<[label]> - " "\"" fileb ":1:10\"")))) + (should (string= (buffer-string) (concat "<[label]> - " "\"" fileb ":L1:C10\"")))) + (hy-delete-file-and-buffer filea) + (hy-delete-file-and-buffer fileb)))) + +(ert-deftest hui--ibut-link-directly-to-org-header-first-column () + "Create a direct link to an org file header point in first column." + (let ((filea (make-temp-file "hypb" nil ".txt")) + (fileb (make-temp-file "hypb" nil ".org" "* header\nbody\n"))) + (unwind-protect + (progn + (delete-other-windows) + (find-file fileb) + (goto-char 1) + (split-window) + (find-file filea) + (hui:ibut-link-directly (get-buffer-window) + (get-buffer-window (get-file-buffer fileb))) + (should (string= (buffer-string) (concat "\"" fileb "#header\""))) + (goto-char (point-min)) + (search-forward "#") + (action-key) + (should (string= (buffer-name) (file-name-nondirectory fileb))) + (should (= (point) 1))) + (hy-delete-file-and-buffer filea) + (hy-delete-file-and-buffer fileb)))) + +(ert-deftest hui--ibut-link-directly-to-org-header-second-column () + "Create a direct link to an org file header point in second column." + (let ((filea (make-temp-file "hypb" nil ".txt")) + (fileb (make-temp-file "hypb" nil ".org" "* header\nbody\n"))) + (unwind-protect + (progn + (delete-other-windows) + (find-file fileb) + (goto-char 2) + (split-window) + (find-file filea) + (hui:ibut-link-directly (get-buffer-window) + (get-buffer-window (get-file-buffer fileb))) + (should (string= (buffer-string) (concat "\"" fileb "#header:L1:C1\""))) + (goto-char (point-min)) + (search-forward "#") + (action-key) + (should (string= (buffer-name) (file-name-nondirectory fileb))) + (should (= (point) 2))) + (hy-delete-file-and-buffer filea) + (hy-delete-file-and-buffer fileb)))) + +(ert-deftest hui--ibut-link-directly-to-org-body () + "Create a direct link to an org file body." + (let ((filea (make-temp-file "hypb" nil ".txt")) + (fileb (make-temp-file "hypb" nil ".org" "* header\nbody\n"))) + (unwind-protect + (progn + (delete-other-windows) + (find-file fileb) + (goto-char (point-min)) + (forward-line 1) + (should (looking-at-p "body")) + (split-window) + (find-file filea) + (hui:ibut-link-directly (get-buffer-window) + (get-buffer-window (get-file-buffer fileb))) + (should (string= (buffer-string) (concat "\"" fileb ":L2\""))) + (goto-char (point-min)) + (search-forward ":") + (action-key) + (should (string= (buffer-name) (file-name-nondirectory fileb))) + (should (= (line-number-at-pos) 2))) (hy-delete-file-and-buffer filea) (hy-delete-file-and-buffer fileb)))) @@ -908,7 +976,7 @@ With point on label suggest that ibut for rename." (hui:gbut-link-directly t) (with-current-buffer (find-buffer-visiting global-but-file) (should (string= (buffer-string) - (concat "First\n<[button]> - \"" file ":1\"")))))) + (concat "First\n<[button]> - \"" file ":L1\"")))))) (hy-delete-file-and-buffer global-but-file) (hy-delete-file-and-buffer file))))