branch: externals/hyperbole commit 91de35dac59fcbedf9d39bbbd7145fb7f6514b05 Merge: fba4d6b6d4 737ee4f9f1 Author: Robert Weiner <r...@gnu.org> Commit: GitHub <nore...@github.com>
Merge pull request #519 from rswgnu/rsw hyrolo.py - For Org files, include '#+PROPERTY:' lines in file hdr --- ChangeLog | 14 ++++++++++++++ hib-social.el | 31 ++++++++++++++++--------------- hui-select.el | 12 ++++++++---- hyrolo.py | 35 ++++++++++++++++++++++++++++------- man/hyperbole.texi | 10 +++++----- 5 files changed, 71 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78e07d7d54..d4e9989bae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2024-04-16 Bob Weiner <r...@gnu.org> + +* hyrolo.py: For Org files, create hyrolo match file header from all + initial buffer-level '#+PROPERTY:' lines. + +* hib-social.el (github-reference): Allow for a - character following + commit, issue or pull keywords; already supported / and = characters. + (gitlab-reference): Allow for a - character following + any ref-type keyword. + +* hui-select.el (hui-select-initialize): Disable C++ defun selection regexp until + regexp is rewritten to prevent Emacs hangs. See Emacs bug#61436 from 2023 + and; gh#rswgnu/hyperbole/issue-518 from 2024. + 2024-04-14 Mats Lidell <ma...@gnu.org> * test/hbut-tests.el (hypb--gbut-act-with-web-link): Test for gbut:act diff --git a/hib-social.el b/hib-social.el index 129790c931..13b32c7a9e 100644 --- a/hib-social.el +++ b/hib-social.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 20-Jul-16 at 22:41:34 -;; Last-Mod: 13-Apr-24 at 11:17:42 by Bob Weiner +;; Last-Mod: 16-Apr-24 at 22:10:55 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -166,7 +166,7 @@ ;; gl#projects List all available projects ;; ;; gl#milestone=38 Show a specific project milestone -;; gl#snippet/1689487 Show a specific project snippet +;; gl#snippet=1689487 Show a specific project snippet ;;; Code: ;;; ************************************************************************ @@ -367,7 +367,7 @@ or /<project>. are listed; one of the words: branch, commit, issue, pull or tag followed - by a '/' or '=' and an item-id; the item is shown; + by by '/', '-', or '=', and an item-id; the item is shown; an issue reference given by a positive integer, e.g. 92 or prefaced with GH-, e.g. GH-92; the issue is displayed; @@ -390,7 +390,7 @@ PROJECT value is provided, it defaults to the value of (url-to-format (assoc-default "github" hibtypes-social-hashtag-alist #'string-match)) (ref-type)) (when url-to-format - (cond ((string-match "\\`\\(branch\\|commit\\|issue\\|pull\\|tag\\)[/=]" reference) + (cond ((string-match "\\`\\(branch\\|commit\\|issue\\|pull\\|tag\\)[-/=]" reference) ;; [branch | commit | issue | pull | tag]/ref-item nil) ((string-match "\\`/?\\(\\([^/#@]+\\)/\\)\\([^/#@]+\\)\\'" reference) @@ -426,20 +426,21 @@ PROJECT value is provided, it defaults to the value of (setq ref-type reference reference "")) ((and (< (length reference) 8) (string-match "\\`\\([gG][hH]-\\)?[0-9]+\\'" reference)) - ;; Issue ref-id reference + ;; Issue 'number' or 'GH-number' ref-id reference (setq ref-type "issues/" reference (substring reference (match-end 1) (match-end 0)))) - ((string-match "\\`\\(commit\\|issue\\|pull\\)[/=]" reference) + ((string-match "\\`\\(commit\\|issue\\|pull\\)[-/=]" reference) ;; Specific reference preceded by keyword branch, commit, - ;; issue, or pull + ;; issue, or pull and followed by -, /, = or #. (setq ref-type (substring reference 0 (match-end 1)) reference (substring reference (match-end 0)) - ref-type (concat ref-type (if (string-equal ref-type "issue") "s/" "/")))) ((string-match "\\`[0-9a-f]+\\'" reference) + ref-type (concat ref-type (if (string-equal ref-type "issue") "s/" "/")))) + ((string-match "\\`[0-9a-f]+\\'" reference) ;; Commit reference (setq ref-type "commit/")) (t ;; Specific branch or commit tag reference - (if (string-match "\\`\\(branch\\|tag\\)/" reference) + (if (string-match "\\`\\(branch\\|tag\\)[-/=]" reference) ;; Reference is a specific branch or tag. ;; If preceded by optional keyword, remove that from the reference. (setq ref-type "blob/" @@ -482,8 +483,8 @@ or /<project-or-group> (where a group is a collection of projects). listed; one of the words: branch, commit(s), issue(s), milestone(s), - pull(s), snippet(s) or tag(s) followed by a '/' or '=' and an - item-id; the item is shown; + pull(s), snippet(s) or tag(s) followed by a '/', '-' or '=' + and an item-id; the item is shown; an issue reference given by a positive integer, e.g. 92 or prefaced with GL-, e.g. GL-92; the issue is displayed; @@ -592,15 +593,15 @@ PROJECT value is provided, it defaults to the value of ;; Labeled category of issues (setq ref-type "issues?label_name%5B%5D=" reference (substring reference (match-end 0)))) - ((string-match "\\`\\(commit\\|issues\\|milestones\\|pull\\|snippets\\|tags\\)[/=]" reference) + ((string-match "\\`\\(commit\\|issues\\|milestones\\|pull\\|snippets\\|tags\\)[-/=]" reference) ;; Ref-id preceded by a keyword (setq ref-type (concat (substring reference 0 (match-end 1)) "/") reference (substring reference (match-end 0)))) - ((string-match "\\`\\(issue\\|milestone\\|snippet\\|tag\\)[/=]" reference) + ((string-match "\\`\\(issue\\|milestone\\|snippet\\|tag\\)[-/=]" reference) ;; Ref-id preceded by a singular keyword that must be converted to plural (setq ref-type (concat (substring reference 0 (match-end 1)) "s/") reference (substring reference (match-end 0)))) - ((string-match "\\`\\(commit\\|pull\\)s[/=]" reference) + ((string-match "\\`\\(commit\\|pull\\)s[-/=]" reference) ;; Ref-id preceded by a plural keyword that must be converted to singular (setq ref-type (concat (substring reference 0 (match-end 1)) "/") reference (substring reference (1+ (match-end 0))))) @@ -610,7 +611,7 @@ PROJECT value is provided, it defaults to the value of (t ;; Specific branch or commit tag reference (setq ref-type "tree/") - (when (string-match "\\`\\(branch\\|tag\\)[/=]" reference) + (when (string-match "\\`\\(branch\\|tag\\)[-/=]" reference) ;; If preceded by optional keyword, remove that from the reference. (setq reference (substring reference (match-end 0))))))) (if (and (stringp user) (stringp project)) diff --git a/hui-select.el b/hui-select.el index 4bd62edaa1..8c4cc4bf57 100644 --- a/hui-select.el +++ b/hui-select.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Oct-96 at 02:25:27 -;; Last-Mod: 19-Jan-24 at 18:17:28 by Mats Lidell +;; Last-Mod: 16-Apr-24 at 22:21:45 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -401,9 +401,13 @@ Also, add language-specific syntax setups to aid in thing selection." ;; programmers don't put their function braces in the first column. (var:add-and-run-hook 'java-mode-hook (lambda () (setq defun-prompt-regexp hui-java-defun-prompt-regexp))) - (var:add-and-run-hook 'c++-mode-hook (lambda () - (setq defun-prompt-regexp - "^[ \t]*\\(template\\s-*<[^>;.{}]+>\\s-*\\)?\\(\\(\\(auto\\|const\\|explicit\\|extern\\s-+\"[^\"]+\"\\|extern\\|friend\\|inline\\|mutable\\|overload\\|register\\|static\\|typedef\\|virtual\\)\\s-+\\)*\\(\\([[<a-zA-Z][]_a-zA-Z0-9]*\\(::[]_a-zA-Z0-9]+\\)?\\s-*<[_<>a-zA-Z0-9 ,]+>\\s-*[*&]*\\|[[<a-zA-Z][]_<>a-zA-Z0-9]*\\(::[[<a-zA-Z][]_<>a-zA-Z0-9]+\\)?\\s-*[*&]*\\)[*& \t\n\r]+\\)\\)?\\(\\(::\\|[[<a-zA-Z][]_a-zA-Z0-9]*\\s-*<[^>;{}]+>\\s-*[*&]*::\\|[[<a-zA-Z][]_~<>a-zA-Z0-9]*\\s-* [...] + + ;; !! TODO: defun selection regexp is disabled in C++ until regexp is + ;; rewritten as it can hang Emacs; reported in Emacs bug#61436 in + ;; 2023 and gh#rswgnu/hyperbole/issue-518 in 2024. + ;; (var:add-and-run-hook 'c++-mode-hook (lambda () + ;; (setq defun-prompt-regexp + ;; "^[ \t]*\\(template\\s-*<[^>;.{}]+>\\s-*\\)?\\(\\(\\(auto\\|const\\|explicit\\|extern\\s-+\"[^\"]+\"\\|extern\\|friend\\|inline\\|mutable\\|overload\\|register\\|static\\|typedef\\|virtual\\)\\s-+\\)*\\(\\([[<a-zA-Z][]_a-zA-Z0-9]*\\(::[]_a-zA-Z0-9]+\\)?\\s-*<[_<>a-zA-Z0-9 ,]+>\\s-*[*&]*\\|[[<a-zA-Z][]_<>a-zA-Z0-9]*\\(::[[<a-zA-Z][]_<>a-zA-Z0-9]+\\)?\\s-*[*&]*\\)[*& \t\n\r]+\\)\\)?\\(\\(::\\|[[<a-zA-Z][]_a-zA-Z0-9]*\\s-*<[^>;{}]+>\\s-*[*&]*::\\|[[<a-zA-Z][]_~<>a-zA-Z0-9]*\ [...] ;; ;; Match to Lisp symbols with : in their names, often included in help buffers. (var:add-and-run-hook 'help-mode-hook (lambda () (modify-syntax-entry ?: "_" help-mode-syntax-table))) diff --git a/hyrolo.py b/hyrolo.py index 661c8df594..09c80fc8b2 100644 --- a/hyrolo.py +++ b/hyrolo.py @@ -8,7 +8,7 @@ # Author: Bob Weiner # # Orig-Date: 1-Apr-24 at 01:45:27 -# Last-Mod: 15-Apr-24 at 00:04:58 by Bob Weiner +# Last-Mod: 16-Apr-24 at 23:12:28 by Bob Weiner # # SPDX-License-Identifier: GPL-3.0-or-later # @@ -36,11 +36,11 @@ import re # String to match at bol for file header start and end file_header_delimiter = '===' -# Header to insert before a file's first entry match when file has no header. -# Used with one argument, the file name. +# Header to insert before a file's first entry match when file has no header +# Used with one argument, the file name file_header_format = \ "===============================================================================\n" \ - "@loc> \"%s\"\n" \ + "%s" \ "===============================================================================\n" # The ANSI escape sequence for the red color @@ -55,6 +55,7 @@ def find_matching_entries(match_string, file_paths): # Remove any null items from file_paths and expand them file_paths = [os.path.abspath(os.path.expanduser(os.path.expandvars(p))) for p in file_paths if p] + org_buffer_property_regex ='#\\+[^: \t\n]+:' for file_path in file_paths: # Initialize variables @@ -62,18 +63,27 @@ def find_matching_entries(match_string, file_paths): file_header_buffer = '' inside_entry = False inside_file_header = False + inside_org_file_header = False first_line = True first_entry = True headline_match = False + org_file = False # Open the file with open(file_path, 'r') as file: + org_file = file_path.endswith('.org') for line in file: if first_line: first_line = False if line.startswith(file_header_delimiter): inside_file_header = True file_header_buffer += line + org_file = False # Prevent double file header wrapping + continue + elif org_file and line.startswith('#'): + inside_org_file_header = True + if re.match(org_buffer_property_regex, line): + file_header_buffer += line continue if inside_file_header: @@ -81,20 +91,31 @@ def find_matching_entries(match_string, file_paths): if line.startswith(file_header_delimiter): inside_file_header = False continue + elif inside_org_file_header: + if re.match(org_buffer_property_regex, line): + file_header_buffer += line + elif line.startswith('#'): + pass + else: + inside_org_file_header = False + continue headline_match = re.match(r'[\*\#]+[ \t]', line, re.IGNORECASE) - # If inside a entry and the line starts with an asterisk, check + # If inside an entry and the line starts with an asterisk, check # if the buffer contains the match string. if inside_entry and headline_match: if re.search(quoted_match_string, buffer, re.IGNORECASE): if first_entry: first_entry = False if file_header_buffer: - print(file_header_buffer, end='') + if org_file: + print(file_header_format % file_header_buffer, end='') + else: + print(file_header_buffer, end='') file_header_buffer = '' print("@loc> \"%s\"\n" % file_path) else: - print(file_header_format % file_path) + print(file_header_format % "@loc> \"" + file_path + "\"\n") highlight_matches(match_string, buffer) diff --git a/man/hyperbole.texi b/man/hyperbole.texi index fe469a6071..79f7fc2c34 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: 13-Apr-24 at 11:21:43 by Bob Weiner +@c Last-Mod: 16-Apr-24 at 22:13:33 by Bob Weiner @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -159,7 +159,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P> <PRE> Edition 9.0.2pre -Printed April 7, 2024. +Printed April 16, 2024. Published by the Free Software Foundation, Inc. Author: Bob Weiner @@ -201,7 +201,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @example Edition 9.0.2pre -April 7, 2024 +April 16, 2024 Published by the Free Software Foundation, Inc. Author: Bob Weiner @@ -3203,7 +3203,7 @@ REFERENCE is a string of one of the following forms: @table @asis @item @bullet{} one of the words: branches, commits, issues, pulls, or tags the associated items are listed -@item @bullet{} one of the words: branch, commit, issue, pull or tag followed by a '/' and item id +@item @bullet{} one of the words: branch, commit, issue, pull or tag followed by a '/', '-', or '=', and item id the item is shown @item @bullet{} an issue reference given by a positive integer, e.g. @emph{92} or prefaced with @emph{GH-}, like GH-92 the issue is displayed @@ -3242,7 +3242,7 @@ or @table @asis @item @bullet{} one of the words: activity, analytics, boards or kanban, branches, commits, contributors, groups, issues or list, jobs, labels, merge_requests, milestones, pages, pipelines, pipeline_charts, members or people or staff, projects, pulls, schedules, snippets, status or tags the associated items are listed -@item @bullet{} one of the words: branch, commit(s), issue(s), milestone(s), pull(s), snippet(s) or tag(s) followed by a '/' or '=' and an item-id +@item @bullet{} one of the words: branch, commit(s), issue(s), milestone(s), pull(s), snippet(s) or tag(s) followed by a '/', '-', or '=', and an item-id the item is shown @item @bullet{} an issue reference given by a positive integer, e.g. @emph{92} or prefaced with @emph{GL-}, like GL-92 the issue is displayed