emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 55dea2bb1e 4/4: Merge pull request #509 from


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 55dea2bb1e 4/4: Merge pull request #509 from rswgnu/rsw
Date: Sun, 7 Apr 2024 15:58:04 -0400 (EDT)

branch: externals/hyperbole
commit 55dea2bb1ec4bfdb3fd2ed17e7df3468b3aa4889
Merge: c87bb410ef 5ccde4476f
Author: Robert Weiner <rsw@gnu.org>
Commit: GitHub <noreply@github.com>

    Merge pull request #509 from rswgnu/rsw
    
    hyrolo-consult-grep - speed up; grep generates file list from dirs; remove 
man/version.texi
---
 ChangeLog                |  18 ++++++
 Makefile                 |   8 +--
 hyrolo.el                | 162 ++++++++++++++++++++++++++++++++++++-----------
 man/hyperbole.texi       |  11 ++--
 man/version.texi         |   4 --
 test/hpath-tests.el      |   4 +-
 test/hy-test-coverage.el |  12 ++--
 7 files changed, 161 insertions(+), 58 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1bdb2145b3..d962762e1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-07  Bob Weiner  <rsw@gnu.org>
+
+* Makefile (version, HYPERBOLE_FILES, TEXINFO_SRC):
+  test/hpath-tests.el (hpath:prepend-shell-directory-test):
+  man/hyperbole.texi: Remove "version.texi" file and include here to simplify
+    doc build recipes.
+
 2024-04-05  Mats Lidell  <matsl@gnu.org>
 
 * test/hmouse-drv-tests.el (hbut-defil-verbatim): Add test for reported
@@ -9,8 +16,19 @@
 * test/demo-tests.el (demo-manifest-test): Replace COPYING with DEMO since
     it is not exported in all installations, i.e. MELPA.
 
+2024-04-01  Bob Weiner  <rsw@gnu.org>
+
+* hyrolo.el (hyrolo-consult-grep-paths): Add this support function for
+    hyrolo-consult commands.
+            (hyrolo-consult-grep): Rewrote to select files to search within
+    the grep command itself for greatly increased speed.
+            (hyrolo-consult-org-roam-grep, hyrolo-consult-org-roam-title): Add.
+
 2024-03-31  Bob Weiner  <rsw@gnu.org>
 
+* hyrolo.el (hyrolo-consult-grep): Convert any non-nil prefix arg
+    'max-matches' to a number so it is utilized.
+
 * test/hbut-tests.el (hbut-tests--ibut-at-p-identifies-a-remote-pathname):
     Code now fixed so this test passes; remove expected failure clause.
 
diff --git a/Makefile b/Makefile
index 24d5f0d632..bff095a1c1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # Author:       Bob Weiner
 #
 # Orig-Date:    15-Jun-94 at 03:42:38
-# Last-Mod:     31-Mar-24 at 23:05:09 by Mats Lidell
+# Last-Mod:      7-Apr-24 at 10:40:38 by Bob Weiner
 #
 # Copyright (C) 1994-2023  Free Software Foundation, Inc.
 # See the file HY-COPY for license information.
@@ -210,7 +210,7 @@ HYPERBOLE_FILES = dir info html $(EL_SRC) $(EL_KOTL) \
         HY-CONCEPTS.kotl HY-NEWS \
        HY-WHY.kotl INSTALL DEMO DEMO-ROLO.otl FAST-DEMO MANIFEST README.md 
TAGS _hypb \
         .hypb smart-clib-sym topwin.py hyperbole-banner.png 
$(man_dir)/hkey-help.txt \
-       $(man_dir)/hyperbole.texi $(man_dir)/hyperbole.css 
$(man_dir)/version.texi
+       $(man_dir)/hyperbole.texi $(man_dir)/hyperbole.css
 
 TEST_ERT_FILES = $(wildcard test/*tests.el) $(wildcard test/hy-test-*.el)
 
@@ -343,7 +343,7 @@ clean:
 
 version:
        @echo ""
-       @fgrep -L $(HYPB_VERSION) Makefile HY-ABOUT HY-ANNOUNCE HY-NEWS 
README.md hversion.el hyperbole.el man/hyperbole.texi man/version.texi > 
WRONG-VERSIONS
+       @fgrep -L $(HYPB_VERSION) Makefile HY-ABOUT HY-ANNOUNCE HY-NEWS 
README.md hversion.el hyperbole.el man/hyperbole.texi > WRONG-VERSIONS
        @# If any file(s) have wrong version number, print them and exit with 
code 1
        @if [ -s WRONG-VERSIONS ]; then \
          echo "The following files do not have the proper Hyperbole version 
number, $(HYPB_VERSION):"; \
@@ -358,7 +358,7 @@ doc: version README.md.html manual
 # Build the Info, HTML and Postscript versions of the user manual
 manual: info html pdf
 
-TEXINFO_SRC = $(man_dir)/hyperbole.texi $(man_dir)/version.texi 
$(man_dir)/hkey-help.txt $(man_dir)/im/*.png
+TEXINFO_SRC = $(man_dir)/hyperbole.texi $(man_dir)/hkey-help.txt 
$(man_dir)/im/*.png
 
 info: $(man_dir)/hyperbole.info
 $(man_dir)/hyperbole.info: $(TEXINFO_SRC)
diff --git a/hyrolo.el b/hyrolo.el
index 4ec23435d7..a7e65530f7 100644
--- a/hyrolo.el
+++ b/hyrolo.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     7-Jun-89 at 22:08:29
-;; Last-Mod:     31-Mar-24 at 11:51:46 by Bob Weiner
+;; Last-Mod:      4-Apr-24 at 21:47:39 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -520,6 +520,82 @@ entry which begins with the parent string."
       (when (called-interactively-p 'interactive)
        (message "Edit entry at point.")))))
 
+;;;###autoload
+(defun hyrolo-consult-grep (&optional regexp max-matches)
+  "Interactively search `hyrolo-file-list' with a consult package grep command.
+Use ripgrep (rg) if found, otherwise, plain grep.  Interactively
+show all matches from `hyrolo-file-list'.  Initialize search with
+optional REGEXP and interactively prompt for changes.  Limit matches
+per file to the absolute value of MAX-MATCHES, if given and not 0.  If
+0, match to headlines only (lines that start with a '^[*#]+ ' regexp)."
+  (interactive "i\nP")
+  (unless (package-installed-p 'consult)
+    (package-install 'consult))
+  (require 'consult)
+  (let ((consult-version (hyrolo-get-consult-version)))
+    ;; Multi-file support added after consult version "0.32"
+    (when (not (and consult-version (string-greaterp consult-version "0.32")))
+      (error "(hyrolo-consult-grep): consult package version is %s; update 
required"
+            consult-version)))
+  (let* ((grep-includes (concat "--include *.kot --include *.kotl"
+                               " --include *.md --include *.markdown --include 
*.mkd --include *.mdown --include *.mkdn --include *.mdwn"
+                               " --include *.org --include *.otl --include 
*.outl"))
+        (ripgrep-globs "--glob 
*.{kot,kotl,md,markdown,mkd,mdown,mkdn,mdwn,org,otl,outl}")
+        (consult-grep-args
+         (if (listp consult-grep-args)
+             (append consult-grep-args (list grep-includes))
+           (concat consult-grep-args " " grep-includes)))
+        (consult-ripgrep-args
+         (if (listp consult-ripgrep-args)
+             (append consult-ripgrep-args (list ripgrep-globs))
+            (concat consult-ripgrep-args " " ripgrep-globs)))
+        (paths (if find-file-wildcards
+                   ;; Use only the directory of paths with wildcards
+                   ;; since the grep command filters to desired file
+                   ;; types much more efficiently.
+                   (mapcar (lambda (path)
+                             (if (string-match 
"[\\/]?\\([^*?\\/]*[*?][^\\/]+\\'\\)" path)
+                                 (substring path 0 (match-beginning 1))
+                               path))
+                           hyrolo-file-list)
+                 hyrolo-file-list)))
+    (hyrolo-consult-grep-paths paths regexp max-matches)))
+
+;;;###autoload
+(defun hyrolo-consult-org-roam-grep (&optional regexp max-matches)
+  "Interactively narrow and select Org Roam nodes by line.
+Use ripgrep (rg) if found, otherwise, plain grep to search Org
+files within `org-roam-directory'.  Initialize search with
+optional REGEXP and interactively prompt for changes.  Limit
+matches per file to the absolute value of MAX-MATCHES, if given
+and not 0.  If 0, match to headlines only (lines that start with
+a '^[*#]+ ' regexp)."
+  (interactive "i\nP")
+  (unless (package-installed-p 'org-roam)
+    (package-install 'org-roam))
+  (require 'org-roam)
+  (unless (file-readable-p org-roam-directory)
+    (make-directory org-roam-directory))
+  (unless org-roam-db-autosync-mode
+    (org-roam-db-autosync-mode))
+  (if (file-readable-p org-roam-directory)
+      (let ((consult-grep-args
+            (if (listp consult-grep-args)
+                (append consult-grep-args (list "--include *.org"))
+              (concat consult-grep-args " --include *.org")))
+           (consult-ripgrep-args
+            (if (listp consult-ripgrep-args)
+                (append consult-ripgrep-args (list "--glob *.org"))
+               (concat consult-ripgrep-args " --glob *.org"))))
+       (hyrolo-consult-grep-paths (list org-roam-directory) regexp 
max-matches))
+    (error "(hyrolo-consult-org-roam-grep): `org-roam-directory', \"%s\", does 
not exist" org-roam-directory)))
+
+;;;###autoload
+(defun hyrolo-consult-org-roam-title ()
+  "Interactively narrow and select Org Roam nodes by title."
+  (interactive)
+  (org-roam-node-find nil nil (lambda (node) (zerop (org-roam-node-level 
node)))))
+
 ;;;###autoload
 (defun hyrolo-display-matches (&optional display-buf return-to-buffer)
   "Display optional DISPLAY-BUF buffer of previously found rolo matches.
@@ -1813,42 +1889,6 @@ returned to the number given."
     ;; (goto-char (previous-single-char-property-change (point) 'invisible))))
     (goto-char (1- (point)))))
 
-;;;###autoload
-(defun hyrolo-consult-grep (&optional regexp max-matches)
-  "Interactively search `hyrolo-file-list' with a consult package grep command.
-Use ripgrep (rg) if found, otherwise, plain grep.  Interactively
-show all matches from `hyrolo-file-list'.  Initialize search with
-optional REGEXP and interactively prompt for changes.  Limit matches
-per file to the absolute value of MAX-MATCHES if given."
-  (interactive "i\nP")
-  (unless (package-installed-p 'consult)
-    (package-install 'consult))
-  (require 'consult)
-  (let ((consult-version (hyrolo-get-consult-version)))
-    ;; Multi-file support added after consult version "0.32"
-    (when (not (and consult-version (string-greaterp consult-version "0.32")))
-      (error "(hyrolo-consult-grep): consult package version is %s; update 
required"
-            consult-version)))
-  (let ((files (seq-filter #'file-readable-p (hyrolo-get-file-list)))
-       (consult-grep-args (if (integerp max-matches)
-                              (if (listp consult-grep-args)
-                                  (append consult-grep-args
-                                          (list (format "-m %d" (abs 
max-matches))))
-                                (concat consult-grep-args
-                                        (format " -m %d" (abs max-matches))))
-                            consult-grep-args))
-       (consult-ripgrep-args (if (integerp max-matches)
-                                 (if (listp consult-ripgrep-args)
-                                     (append consult-ripgrep-args
-                                             (list (format "-m %d" (abs 
max-matches))))
-                                   (concat consult-ripgrep-args
-                                           (format " -m %d" (abs 
max-matches))))
-                               consult-ripgrep-args))
-       (grep-func (cond ((executable-find "rg")
-                         #'consult-ripgrep)
-                        (t #'consult-grep))))
-    (funcall grep-func files regexp)))
-
 ;;;###autoload
 (defun hyrolo-fgrep-directories (file-regexp &rest dirs)
   "String/logical HyRolo search over files matching FILE-REGEXP in rest of 
DIRS."
@@ -2006,7 +2046,7 @@ Return number of matching entries found."
                                    (funcall hyrolo-next-match-function 
search-pattern))
                          (setq match-end (point))
                          ;; If no entry delimiters found, just return
-                         ;; the line of the match alone.
+                         ;; the single line of the match alone.
                          (unless (re-search-backward 
hyrolo-hdr-and-entry-regexp nil t)
                            (goto-char (line-beginning-position)))
                          (setq entry-start (point))
@@ -2874,6 +2914,52 @@ HYROLO-BUF may be a file-name, `buffer-name', or buffer."
                             hyrolo-buf))
             (buffer-list))))
 
+(defun hyrolo-consult-grep-paths (paths &optional regexp max-matches)
+  "Interactively search PATHS with a consult package grep command.
+Use ripgrep (rg) if found, otherwise, plain grep.  Interactively
+show all matches from PATHS; see the documentation for the `dir'
+argument in `consult-grep' for valid values of PATHS. 
+
+Initialize search with optional REGEXP and interactively prompt
+for changes.  Limit matches per file to the absolute value of
+MAX-MATCHES, if given and not 0.  If 0, match to headlines
+only (lines that start with a '^[*#]+ ' regexp)."
+  (unless (package-installed-p 'consult)
+    (package-install 'consult))
+  (require 'consult)
+  (let ((consult-version (hyrolo-get-consult-version)))
+    ;; Multi-file support added after consult version "0.32"
+    (when (not (and consult-version (string-greaterp consult-version "0.32")))
+      (error "(hyrolo-consult-grep): consult package version is %s; update 
required"
+            consult-version)))
+  (when max-matches
+    (setq max-matches (prefix-numeric-value max-matches)))
+  (when (and (integerp max-matches) (zerop max-matches))
+    (setq regexp (concat "^[*#]+ " (or regexp ""))))
+  (let ((consult-grep-args (if (integerp max-matches)
+                              (if (listp consult-grep-args)
+                                  (append consult-grep-args
+                                          (list (format "-m %d" (abs 
max-matches))))
+                                (concat consult-grep-args
+                                        (format " -m %d" (abs max-matches))))
+                            consult-grep-args))
+       (consult-ripgrep-args (if (integerp max-matches)
+                                 (if (listp consult-ripgrep-args)
+                                     (append consult-ripgrep-args
+                                             (list (format "-m %d" (abs 
max-matches))))
+                                   (concat consult-ripgrep-args
+                                           (format " -m %d" (abs 
max-matches))))
+                               consult-ripgrep-args))
+       (grep-func (cond ((executable-find "rg")
+                         #'consult-ripgrep)
+                        (t #'consult-grep))))
+    ;; Consult split style usually uses '#' as a separator char but
+    ;; that interferes with matching to Markdown # chars at the start
+    ;; of a line in the regexp, so disable the separator char as it is
+    ;; not needed for simple regexp searches.
+    (let ((consult-async-split-style nil))
+      (funcall grep-func paths regexp))))
+
 (defun hyrolo-current-date ()
   "Return the current date (a string) in a form used for rolo entry insertion."
   (format-time-string hyrolo-date-format))
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 0561bd77c7..dc681e8b82 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:     31-Mar-24 at 16:08:15 by Bob Weiner
+@c Last-Mod:      7-Apr-24 at 10:27:10 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -25,7 +25,10 @@
 @set txicodequoteundirected
 @set txicodequotebacktick
 
-@include version.texi
+@set UPDATED April, 2024
+@set UPDATED-MONTH April 2024
+@set EDITION 9.0.2pre
+@set VERSION 9.0.2pre
 
 @ifnotinfo
 @macro bkbd {arg}
@@ -156,7 +159,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P>
 
 <PRE>
 Edition 9.0.2pre
-Printed March 31, 2024.
+Printed April 7, 2024.
 
   Published by the Free Software Foundation, Inc.
   Author:    Bob Weiner
@@ -198,7 +201,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 @example
 Edition 9.0.2pre
-March 31, 2024
+April 7, 2024
 
   Published by the Free Software Foundation, Inc.
   Author:    Bob Weiner
diff --git a/man/version.texi b/man/version.texi
deleted file mode 100644
index b7c4183bb9..0000000000
--- a/man/version.texi
+++ /dev/null
@@ -1,4 +0,0 @@
-@set UPDATED March, 2024
-@set UPDATED-MONTH March 2024
-@set EDITION 9.0.2pre
-@set VERSION 9.0.2pre
diff --git a/test/hpath-tests.el b/test/hpath-tests.el
index 4036f707a8..5cb7dc7085 100644
--- a/test/hpath-tests.el
+++ b/test/hpath-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    28-Feb-21 at 23:26:00
-;; Last-Mod:      1-Apr-24 at 17:45:41 by Mats Lidell
+;; Last-Mod:      7-Apr-24 at 10:40:03 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -207,7 +207,7 @@
                (default-directory hyperb:dir))
          (should explicit-shell-file-name)
           (hypb-run-shell-test-command shell-cmd shell-buffer)
-          (dolist (file '("DEMO" "man/hkey-help.txt" "man/version.texi" 
"man/im/demo.png"))
+          (dolist (file '("COPYING" "man/hkey-help.txt" "man/im/demo.png"))
             (goto-char (point-min))
             (should (search-forward (car (last (split-string file "/"))) nil 
t))
             (backward-char (/ (length file) 2))
diff --git a/test/hy-test-coverage.el b/test/hy-test-coverage.el
index 28a970bdae..9ed2f40650 100644
--- a/test/hy-test-coverage.el
+++ b/test/hy-test-coverage.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    21-Mar-24 at 13:22:27
-;; Last-Mod:     31-Mar-24 at 23:00:30 by Mats Lidell
+;; Last-Mod:      7-Apr-24 at 10:43:42 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -14,12 +14,12 @@
 
 ;;; Commentary:
 ;;
-;; Uses the testcover functionality and runs the a specified test
+;; Uses the testcover functionality and runs a specified test
 ;; suite for a file that is monitored for coverage.  See
 ;; "testcover.el" for how to interpret the "splotches", the color code
 ;; characters in the monitored filed.
 ;;
-;; See also "../Makefile#coverage", a make target for running from the
+;; See also "../Makefile#coverage:", a make target for running from the
 ;; command line.
 
 ;;; Code:
@@ -35,11 +35,11 @@
    (car (overlay-lists))))
 
 (defun hy-test-coverage-file (filename &optional testspec)
-  "Run TESTSPEC and produce coverage data for FILENAME.
-With no TESTSPEC all tests are used."
+  "In FILENAME, run TESTSPEC and produce coverage data.
+With no TESTSPEC all tests are run."
   (interactive "fFilename: \nsTestspec: ")
   (unless (file-exists-p filename)
-    (error "(hy-test-coverage-file) - File %s does not exist" filename))
+    (error "(hy-test-coverage-file): File %s does not exist" filename))
   (unless testspec
     (setq testspec t))
   (let ((buff (find-file filename)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]