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

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

[elpa] externals/hyperbole 09421efa8a 1/2: Fixes for hyrolo multiple fil


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 09421efa8a 1/2: Fixes for hyrolo multiple file format searches and klink activation
Date: Mon, 29 Aug 2022 16:57:45 -0400 (EDT)

branch: externals/hyperbole
commit 09421efa8aff63e27dcc9113129a99281b6dd78e
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Fixes for hyrolo multiple file format searches and klink activation
    
    Improve HyRolo handling of koutlines.
    Remove obsolete functions.
---
 ChangeLog            |  73 ++++++++++++++
 hact.el              |   8 +-
 hargs.el             |   4 +-
 hbut.el              | 100 ++++++++++---------
 hibtypes.el          |  11 +--
 hui-mini.el          |   5 +-
 hui-mouse.el         |   4 +-
 hypb.el              |  26 +++--
 hyrolo-demo.el       |   8 +-
 hyrolo.el            | 272 +++++++++++++++++++++++++++++++++------------------
 kotl/kimport.el      |   3 +-
 kotl/klink.el        |  16 +--
 kotl/kotl-mode.el    |   3 +-
 kotl/kview.el        |  36 +++----
 test/hyrolo-tests.el |  30 +++---
 15 files changed, 384 insertions(+), 215 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ff46361c1e..7338519a78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,76 @@
+2022-08-28  Bob Weiner  <rsw@gnu.org>
+
+* kotl/klink.el (klink:act): Ensure 'hact' value is returned, not
+    the result of the 'klink:update-label' call.
+  hbut.el (hbut:get-key-src): Add to get source of button without
+    setting as current buffer.
+  kotl/klink.el (klink:at-p): Use 'hbut:get-key-src' to resolve
+    relative klink paths properly.
+
+* kotl/kotl-mode.el (kotl-mode:to-start-of-line):
+    Remove and use 'kotl-mode:beginning-of-line' instead.
+
+* hact.el (action:commandp, action:params, actype:eval):
+  hargs.el (hargs:action-get):
+  hypb.el (hypb:debug, hypb:map-vector):
+    Replace use of 'hypb:emacs-byte-code-p' with builtin
+    'byte-code-function-p.
+
+* hibtypes.el (elisp-compiler-msg):
+    Replace 'hypb:replace-match-string' with 'replace-regexp-in-string'.
+
+* hbut.el (ibut:at-p): Fix to returns nil if name and lbl-key are both nil.
+    Also add support for <> and {} ibut delimiters.
+
+* hui-mouse.el (hkey-alist): In HyRolo match buffer, test major-mode
+    rather than buffer name.
+
+* hyrolo.el (hyrolo-mode): Don't reinitialize local variables to default
+    values when already in hyrolo-mode and mode is invoked again.
+
+* kotl/kview.el (kcell-view:to-label-end): Remove check if in a buffer
+    with a kview so can be used in HyRolo match buffer as well.
+                (kcell-view:to-label-end): Handle no kview in in HyRolo
+    match buffer.
+
+* hyrolo.el (hyrolo-kill, hyrolo-toggle-narrow-to-entry,
+             hyrolo-google-contacts-grep, hyrolo-grep-file,
+             hyrolo-display-to-entry-end, hyrolo-name-at):
+  kotl/kimport.el (kimport:star-entries): Don't fold case when searching
+    for 'hyrolo-entry-regexp'.
+    (hyrolo-isearch-for-regexp): Add 2nd parameter, 'fold-search-flag'
+  used to set 'case-fold-search'.
+
+* hyrolo.el (hyrolo-find-file-noselect-function): Add so can customize
+    low-level function used by HyRolo to read in each file searched by
+    HyRolo.
+            (hyrolo-find-file): Add second optional parameter, 'find-function',
+    used to find the file.
+            (hyrolo-find-file-noselect): Add and use 
'hyrolo-find-file-noselect-function'.
+           (hyrolo-add, hyrolo-edit, hyrolo-grep, hyrolo-helm-org-rifle,
+             hyrolo-grep-file, hyrolo-map-level, hyrolo-to): Update to call
+    'hyrolo-find-file-noselect'.
+            (hyrolo-add-match): Retain entry properties in match buffer.
+           (hyrolo-mode): Make 'outline-regexp' local in match buffer.
+
+2022-08-27  Bob Weiner  <rsw@gnu.org>
+
+* hyrolo.el (hyrolo-file-suffix-regexp): Match only to these
+    file suffixes when searching for HyRolo files in directories.
+            (hyrolo-search-directories, hyrolo-fgrep-directories,
+             hyrolo-grep-directories, hyrolo-helm-org-rifle-directories):
+    Add these functions to do HyRolo searches over filtered filenames
+    in directories.
+            (hyrolo-org): Separate helm-org-rifle behavior into a new
+    command, 'hyrolo-helm-org-directory-rifle'.
+            (hyrolo-helm-org-rifle, hyrolo-helm-org-directory-rifle):
+    Let 'helm-org-rifle-show-full-contents' be true.
+
+* hyrolo.el (hyrolo-helm-org-rifle): Limit to .org and .otl files.
+
+* hypb.el (hypb:filter-directories, hypb:readable-directories):
+    Add and use in "hyrolo.el".
+
 2022-08-21  Bob Weiner  <rsw@gnu.org>
 
 * hyrolo.el (hyrolo-set-date): Don't add a date if in a Koutline
diff --git a/hact.el b/hact.el
index 5a8ecd3963..d6cf0310cf 100644
--- a/hact.el
+++ b/hact.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    18-Sep-91 at 02:57:09
-;; Last-Mod:     24-Jul-22 at 10:58:30 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:21:24 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2021  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -288,7 +288,7 @@ TYPE and TYPE-CATEGORY are both symbols.  TYPE-CATEGORY 
must be one of
               (t function))))
     (cond ((and action (fboundp 'interactive-form))
           (interactive-form action))
-         ((hypb:emacs-byte-code-p action)
+         ((byte-code-function-p action)
           (cond ((fboundp 'compiled-function-interactive)
                  (compiled-function-interactive action))
                 ((commandp action)
@@ -334,7 +334,7 @@ Autoloads action function if need be to get the parameter 
list."
               ((eq (car action) 'autoload)
                (error "(action:params): Autoload not supported: %s" action))
               (t (car (cdr action)))))
-       ((hypb:emacs-byte-code-p action)
+       ((byte-code-function-p action)
         (if (fboundp 'compiled-function-arglist)
             (compiled-function-arglist action)
           (action:params-emacs action)))
@@ -418,7 +418,7 @@ performing ACTION."
       (let ((hist-elt (hhist:element)))
        (run-hooks 'action-act-hook)
        (prog1 (if (or (symbolp action) (listp action)
-                      (hypb:emacs-byte-code-p action)
+                      (byte-code-function-p action)
                       (subrp action)
                       (and (stringp action) (not (integerp action))
                            (setq action (key-binding action))))
diff --git a/hargs.el b/hargs.el
index effd499b99..cb37e4db3e 100644
--- a/hargs.el
+++ b/hargs.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    31-Oct-91 at 23:17:35
-;; Last-Mod:     20-Jul-22 at 19:17:13 by Mats Lidell
+;; Last-Mod:     29-Aug-22 at 00:21:40 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -56,7 +56,7 @@ Current button is being edited when EDITING-FLAG is t.
 Return nil if ACTION is not a list or `byte-code' object, has no
 interactive form or takes no arguments."
   (save-excursion
-    (and (or (subrp action) (hypb:emacs-byte-code-p action) (listp action))
+    (and (or (subrp action) (byte-code-function-p action) (listp action))
         (let ((interactive-form (action:commandp action)))
           (when interactive-form
             (hpath:relative-arguments
diff --git a/hbut.el b/hbut.el
index 723ef2bee3..97537bafb8 100644
--- a/hbut.el
+++ b/hbut.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    18-Sep-91 at 02:57:09
-;; Last-Mod:     24-Jul-22 at 11:29:49 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 01:35:59 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -1094,6 +1094,52 @@ symbol for the button or button label that point is 
within or
 nil.  BUFFER defaults to the current buffer."
   (or (ebut:get lbl-key buffer key-src) (ibut:get lbl-key buffer key-src)))
 
+(defun    hbut:get-key-src (&optional full)
+  "Return key source (usually unqualified) for current Hyperbole button.
+With optional FULL when source is a pathname, return the full pathname."
+  (cond ((hmail:mode-is-p) (current-buffer))
+       ;; If buffer represents the output of a document
+       ;; formatter, e.g. an Info document produced from a
+       ;; Texinfo source, then return the Texinfo source
+       ;; file, for example.
+       ((hbut:key-src-fmt))
+       ;; Handle directory movement within `make' output.
+       ((save-excursion
+          (and (re-search-backward
+                "^[a-z]*make[^a-z]+\\(Entering\\|Leaving\\) directory 
`\\([^']+\\)'" nil t)
+               (string-equal "Entering" (match-string 1))))
+        (let ((limit (match-end 2))
+              ;; Latest working directory that `make' reported
+              (wd (match-string 2))
+              cd)
+          ;; But another cd or pushd command may have been issued.
+          ;; Return the closest directory from the make output.
+          (if (re-search-backward
+               "\\<\\(cd\\|pushd\\)\\s +[\"\']?\\([^;\"\'\n\r\^L\\]+\\)"
+               limit t)
+              (progn (setq cd (match-string 2))
+                     ;; Eliminate any trailing whitespace.
+                     (setq cd (substring
+                               cd 0 (string-match "\\s +\\'" cd)))
+                     (expand-file-name cd wd))
+            wd)))
+       (buffer-file-name
+        (if full
+            buffer-file-name
+          (file-name-nondirectory buffer-file-name)))
+       ;; Handle any preceding @loc hyp-source implicit button location 
references.
+       ;; This is used in report buffers of explicit buttons, i.e. 
hui:hbut-report
+       ;; and the *Hyperbole Rolo* output buffer.
+       ((save-excursion
+          (save-restriction
+            (widen)
+            (end-of-visible-line)
+            (when (and (search-backward hbut:source-prefix nil t)
+                       (or (memq (preceding-char) '(?\n ?\r))
+                           (= (point) (point-min))))
+              (hbut:source full)))))
+       (t (current-buffer))))
+
 (defun    hbut:is-p (object)
   "Return non-nil if OBJECT is a symbol representing a Hyperbole button."
  (when (symbolp object)
@@ -1108,50 +1154,9 @@ nil.  BUFFER defaults to the current buffer."
 
 (defun    hbut:key-src (&optional full)
   "Return key source (usually unqualified) for current Hyperbole button.
-Also sets current buffer to key source.
+Also set current buffer to key source.
 With optional FULL when source is a pathname, return the full pathname."
-  (let ((src (cond ((hmail:mode-is-p) (current-buffer))
-                  ;; If buffer represents the output of a document
-                  ;; formatter, e.g. an Info document produced from a
-                  ;; Texinfo source, then return the Texinfo source
-                  ;; file, for example.
-                  ((hbut:key-src-fmt))
-                  ;; Handle directory movement within `make' output.
-                  ((save-excursion
-                     (and (re-search-backward
-                           "^[a-z]*make[^a-z]+\\(Entering\\|Leaving\\) 
directory `\\([^']+\\)'" nil t)
-                          (string-equal "Entering" (match-string 1))))
-                   (let ((limit (match-end 2))
-                         ;; Latest working directory that `make' reported
-                         (wd (match-string 2))
-                         cd)
-                     ;; But another cd or pushd command may have been issued.
-                     ;; Return the closest directory from the make output.
-                     (if (re-search-backward
-                          "\\<\\(cd\\|pushd\\)\\s 
+[\"\']?\\([^;\"\'\n\r\^L\\]+\\)"
-                          limit t)
-                         (progn (setq cd (match-string 2))
-                                ;; Eliminate any trailing whitespace.
-                                (setq cd (substring
-                                          cd 0 (string-match "\\s +\\'" cd)))
-                                (expand-file-name cd wd))
-                       wd)))
-                  (buffer-file-name
-                   (if full
-                       buffer-file-name
-                     (file-name-nondirectory buffer-file-name)))
-                  ;; Handle any preceding @loc hyp-source implicit button 
location references.
-                  ;; This is used in report buffers of explicit buttons, i.e. 
hui:hbut-report
-                  ;; and the *Hyperbole Rolo* output buffer.
-                  ((save-excursion
-                     (save-restriction
-                       (widen)
-                       (end-of-visible-line)
-                       (when (and (search-backward hbut:source-prefix nil t)
-                                  (or (memq (preceding-char) '(?\n ?\r))
-                                      (= (point) (point-min))))
-                         (hbut:source full)))))
-                  (t (current-buffer)))))
+  (let ((src (hbut:get-key-src full)))
     (hbut:key-src-set-buffer src)))
 
 (defun    hbut:key-src-fmt ()
@@ -1523,7 +1528,9 @@ excluding delimiters, not just one."
           (name       (nth 0 name-start-end))
           (name-end   (nth 2 name-start-end))
           (lbl-key (or (ibut:label-to-key name)
-                       (ibut:label-p nil "\"" "\"" nil t))))
+                       (ibut:label-p nil "\"" "\"" nil t)
+                       (ibut:label-p nil "<" ">" nil t)
+                       (ibut:label-p nil "{" "}" nil t))))
       (unwind-protect
          (progn
            (when (not (hbut:outside-comment-p))
@@ -1596,7 +1603,8 @@ Return nil if no implicit button at point."
            ;; Any implicit button type check should leave point
            ;; unchanged.  Trigger an error if not.
            (unless (equal (point-marker) ibpoint)
-             (hypb:error "(Hyperbole): `ibtypes::%s' implicit button type test 
failed to restore point to %s" is-type ibpoint)))
+             (hypb:error "(Hyperbole): `%s' at-p test improperly moved point 
from %s to %s"
+                         is-type ibpoint (point-marker))))
          (setq types (cdr types))))
 
       (set-marker ibpoint nil)
diff --git a/hibtypes.el b/hibtypes.el
index fe0a409052..5768b5ac25 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:     24-Jul-22 at 09:46:12 by Bob Weiner
+;; Last-Mod:     28-Aug-22 at 23:45:34 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -1104,7 +1104,7 @@ This works when activated anywhere within file line 
references."
         (if (hpath:is-p label)
             (hact 'link-to-file label)
            ;; Remove prefix generated by actype and ibtype definitions.
-           (setq label (hypb:replace-match-string "[^:]+::" label "" t))
+           (setq label (replace-regexp-in-string "[^:]+::" "" label nil t))
            (hact 'smart-tags-display label nil)))
        ;; GNU Emacs Byte Compiler
        (and (save-excursion
@@ -1121,7 +1121,7 @@ This works when activated anywhere within file line 
references."
               (setq label (match-string-no-properties 1))
               (ibut:label-set label (match-beginning 1) (match-end 1))
               ;; Remove prefix generated by actype and ibtype definitions.
-              (setq label (hypb:replace-match-string "[^:]+::" label "" t))
+              (setq label (replace-regexp-in-string "[^:]+::" "" label nil t))
               (hact 'link-to-regexp-match
                     (concat "^\(def[a-z \t]+" (regexp-quote label)
                             "[ \t\n\r\(]")
@@ -1138,7 +1138,7 @@ This works when activated anywhere within file line 
references."
               (setq label (match-string-no-properties 1))
               (ibut:label-set label (match-beginning 1) (match-end 1))
               ;; Remove prefix generated by actype and ibtype definitions.
-              (setq label (hypb:replace-match-string "[^:]+::" label "" t))
+              (setq label (replace-regexp-in-string "[^:]+::" "" label nil t))
               (hact 'link-to-regexp-match
                     (concat "^\(def[a-z \t]+" (regexp-quote label)
                             "[ \t\n\r\(]")
@@ -1158,7 +1158,7 @@ This works when activated anywhere within file line 
references."
               (setq label (match-string-no-properties 1))
               (ibut:label-set label (match-beginning 1) (match-end 1))
               ;; Remove prefix generated by actype and ibtype definitions.
-              (setq label (hypb:replace-match-string "[^:]+::" label "" t))
+              (setq label (replace-regexp-in-string "[^:]+::" "" label nil t))
               (hact 'link-to-regexp-match
                     (concat "^\(def[a-z \t]+" (regexp-quote label)
                             "[ \t\n\r\(]")
@@ -1419,7 +1419,6 @@ arg1 ... argN '>'.  For example, <mail nil 
\"user@somewhere.org\">."
               args (cdr action))
        ;; Ensure action uses an fboundp symbol if executing a
        ;; Hyperbole actype.
-       (setq a action)
        (when (and (car action) (symbolp (car action)))
          (setcar action
                  (or (intern-soft (concat "actypes::" (symbol-name (car 
action))))
diff --git a/hui-mini.el b/hui-mini.el
index dce8d1852a..1d01e720b9 100644
--- a/hui-mini.el
+++ b/hui-mini.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    15-Oct-91 at 20:13:17
-;; Last-Mod:     23-Jul-22 at 23:04:56 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:19:54 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -491,7 +491,7 @@ constructs.  If not given, the top level Hyperbole menu is 
used."
       (error "(hui:menu-multi-line): Invalid menu specified, '%s'." 
menu-alist))
     (with-temp-buffer
       (let (indent-tabs-mode)
-       (mapcar
+       (mapc
         (lambda (s)
           (setq item-start (* max-item-len items-in-line))
           (if (or (>= item-start (frame-width))
@@ -534,7 +534,6 @@ constructs.  If not given, the top level Hyperbole menu is 
used."
                           (called-interactively-p 'interactive)
                           (equal (this-single-command-keys) key)
                           (lookup-key org-mode-map key))))
-    (setq a org-key-cmd)
     (if org-key-cmd
        ;; Prevent a conflict with {C-c /} binding in Org mode; use
        ;; more flexible, filtering Hyperbole version of this Org command
diff --git a/hui-mouse.el b/hui-mouse.el
index 9d78077fdf..d71b6c37c5 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Feb-89
-;; Last-Mod:     21-Aug-22 at 10:59:08 by Bob Weiner
+;; Last-Mod:     28-Aug-22 at 23:15:16 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -450,7 +450,7 @@ Its default value is #'smart-scroll-down.  To disable it, 
set it to
     ((eq major-mode 'w3-mode) .
      ((w3-follow-link) . (w3-goto-last-buffer)))
     ;;
-    ((and (boundp 'hyrolo-display-buffer) (equal (buffer-name) 
hyrolo-display-buffer)) .
+    ((eq major-mode 'hyrolo-mode) .
      ((smart-hyrolo) . (smart-hyrolo-assist)))
     ;;
     ((eq major-mode 'image-dired-thumbnail-mode) .
diff --git a/hypb.el b/hypb.el
index e3e60ad3ae..9400590f49 100644
--- a/hypb.el
+++ b/hypb.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     6-Oct-91 at 03:42:38
-;; Last-Mod:     24-Jul-22 at 11:41:00 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:30:34 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -224,7 +224,7 @@ If no matching installation type is found, return a list of 
(\"unknown\" hyperb:
   (or (and (featurep 'hbut)
           (let ((func (hypb:indirect-function 'ebut:create)))
             (not (or (subrp func)
-                     (hypb:emacs-byte-code-p func)
+                     (byte-code-function-p func)
                      (eq 'byte-code
                          (car (car (nthcdr 3 (hypb:indirect-function
                                               'ebut:create)))))))))
@@ -310,10 +310,6 @@ will this install the Emacs devdocs package when needed."
                       dname))))
       (concat "@" dname))))
 
-;;;###autoload
-(define-obsolete-function-alias 'hypb:emacs-byte-code-p
-  #'byte-code-function-p "2022")
-
 (defun hypb:error (&rest args)
   "Signal an error typically to be caught by `hyperbole'."
   (let ((msg (if (< (length args) 2)
@@ -351,6 +347,13 @@ FILE is temporarily read into a buffer to determine the 
major mode if necessary.
       (unless (or existing-flag (null buf))
        (kill-buffer buf)))))
 
+(defun hypb:filter-directories (file-regexp &rest dirs)
+  "Filter files to those matching FILE-REGEXP from rest of DIRS (recursively).
+Return a flattened list of all matching files."
+  (setq dirs (hypb:readable-directories dirs))
+  (apply #'nconc (mapcar (lambda (dir) (directory-files-recursively dir 
file-regexp))
+                        dirs)))
+
 (defun hypb:format-quote (arg)
   "Replace all single % with %% in any string ARG so that a call to `format' 
or `message' ignores them.
 Return either the modified string or the original ARG when not modified."
@@ -531,7 +534,7 @@ then `locate-post-command-hook'."
 (defun hypb:map-vector (func object)
   "Return list of results of application of FUNC to each element of OBJECT.
 OBJECT should be a vector or `byte-code' object."
-  (unless (or (vectorp object) (hypb:emacs-byte-code-p object))
+  (unless (or (vectorp object) (byte-code-function-p object))
     (error "(hypb:map-vector): Second argument must be a vector or byte-code 
object"))
   (let ((end (length object))
        (i 0)
@@ -572,6 +575,15 @@ WINDOW pixelwise."
 
 (make-obsolete 'hypb:replace-match-string 'replace-regexp-in-string "8.0.1")
 
+(defun hypb:readable-directories (&rest dirs)
+  "Flatten rest of DIRS and return or error if any of DIRS are unreadable."
+  (setq dirs (flatten-list dirs))
+  (let ((unreadable-dirs (delq nil (mapcar (lambda (dir) (unless 
(file-readable-p dir) dir)) dirs))))
+    (when unreadable-dirs
+      (error "(hypb:readable-directories): These directories are not 
readable:\n%s"
+            (string-join unreadable-dirs "\n"))))
+  dirs)
+
 (defun hypb:replace-match-string (regexp str new &optional literal fixedcase)
   "Replace all matches for REGEXP in STR with NEW string and return the result.
 If NEW is nil, return STR unchanged.
diff --git a/hyrolo-demo.el b/hyrolo-demo.el
index 6b6bd9caa5..67e600e31c 100644
--- a/hyrolo-demo.el
+++ b/hyrolo-demo.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     4-Nov-17 at 13:56:47
-;; Last-Mod:      6-Aug-22 at 21:33:05 by Mats Lidell
+;; Last-Mod:     27-Aug-22 at 15:35:52 by Bob Weiner
 ;;
 ;; Copyright (C) 2017-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -32,7 +32,7 @@
 
 ;;;###autoload
 (defun hyrolo-demo-fgrep (string &optional max-matches)
-  "Display rolo entries in \"DEMO-ROLO.otl\" matching STRING or a logic 
expression.
+  "Display rolo entries in \"DEMO-ROLO.otl\" matching STRING or a logical 
sexpression.
 Display to a maximum of optional prefix arg MAX-MATCHES.
 Each entry is displayed with all of its sub-entries.
 
@@ -42,8 +42,8 @@ that number of entries and omit file headers.
 
 Returns number of entries matched.  See also documentation for
 the function `hyrolo-demo-fgrep-logical' for documentation on the
-logical expression matching."
-  (interactive "sFind rolo string (or logical expression): \nP")
+logical sexpression matching."
+  (interactive "sFind rolo string (or logical sexpression): \nP")
   (let ((hyrolo-file-list (list (expand-file-name "DEMO-ROLO.otl" 
hyperb:dir))))
     (hyrolo-fgrep string max-matches)))
 
diff --git a/hyrolo.el b/hyrolo.el
index 74faaaff21..c3fb974bd0 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:     21-Aug-22 at 14:47:29 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:38:15 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -69,12 +69,22 @@ It must contain a %s indicating where to put the entry name 
and a second
 (defvar hyrolo-entry-name-regexp "[-_a-zA-Z0-9@.]+\\( ?, ?[-_a-zA-Z0-9@.]+\\)?"
   "*Regexp matching a hyrolo entry name after matching to 
`hyrolo-entry-regexp'.")
 
+(defcustom hyrolo-file-suffix-regexp "\\.\\(kotl\\|md\\|org\\|otl\\)$"
+  "File suffix regexp used to select files to search with HyRolo."
+  :type 'string
+  :group 'hyperbole-rolo)
+
 (defcustom hyrolo-find-file-function #'find-file
   "*Function to interactively display a `hyrolo-file-list' file for editing.
 Use the `hyrolo-edit' function instead to edit a new or existing entry."
   :type 'function
   :group 'hyperbole-rolo)
 
+(defcustom hyrolo-find-file-noselect-function #'find-file-noselect
+  "*Function used by HyRolo to read `hyrolo-file-list' files into Emacs."
+  :type 'function
+  :group 'hyperbole-rolo)
+
 (defcustom hyrolo-google-contacts-flag t
   "*Non-nil means search Google Contacts on each hyrolo query.
 The google-contact package must be loaded and a gpg encryption
@@ -207,7 +217,8 @@ entry which begins with the parent string."
         (error "(hyrolo-add): File not readable: `%s'" file))
        ((not (file-writable-p file))
         (error "(hyrolo-add): File not writable: `%s'" file)))
-  (set-buffer (or (get-file-buffer file) (find-file-noselect file)))
+  (set-buffer (or (get-file-buffer file)
+                 (hyrolo-find-file-noselect file)))
   (when (called-interactively-p 'interactive)
     (message "Locating insertion point for `%s'..." name))
   (let ((parent "")
@@ -335,10 +346,11 @@ Second arg RETURN-TO-BUFFER is the buffer to leave point 
within after the displa
 ;;;###autoload
 (defun hyrolo-edit (&optional name file)
   "Edit a rolo entry given by optional NAME within `hyrolo-file-list'.
-With prefix argument, prompts for optional FILE to locate entry within.
-With no NAME arg, simply displays FILE or first entry in `hyrolo-file-list' in 
an
-editable mode.  NAME may be of the form: parent/child to edit child below a
-parent entry which begins with the parent string."
+With prefix argument, prompt for optional FILE within which to
+locate entry.  With no NAME arg, simply displays FILE or first
+entry in `hyrolo-file-list' in an editable mode.  NAME may be of
+the form: parent/child to edit child below a parent entry which
+begins with the parent string."
   (interactive "sEdit rolo entry named: \nP")
   (when (string-equal name "")
     (setq name nil))
@@ -367,7 +379,7 @@ parent entry which begins with the parent string."
        (message "(hyrolo-edit): `%s' not found." name)
        (beep)
        (hyrolo-to-buffer (or (get-file-buffer (car file-list))
-                             (find-file-noselect (car file-list))))
+                             (hyrolo-find-file-noselect (car file-list))))
        (setq buffer-read-only nil))
       (hyrolo-widen)
       ;; hyrolo-to-buffer may have moved point from its desired location, so
@@ -398,7 +410,7 @@ Return entry name if found, else nil."
 
 ;;;###autoload
 (defun hyrolo-fgrep (string &optional max-matches hyrolo-file count-only 
no-display)
-  "Display rolo entries matching STRING (or a logical match expression) and 
return count of matches.
+  "Display rolo entries matching STRING (or a logical sexpression) and return 
count of matches.
 To a maximum of optional prefix arg MAX-MATCHES, in file(s) from optional
 HYROLO-FILE or `hyrolo-file-list'.  Default is to find all matching entries.
 Each entry is displayed with all of its sub-entries.  Optional COUNT-ONLY
@@ -411,13 +423,13 @@ that number of entries and omit file headers.
 
 Return number of entries matched.  See also documentation for the variable
 `hyrolo-file-list' and the function `hyrolo-fgrep-logical' for documentation on
-the logical expression matching."
-  (interactive "sFind rolo string (or logical expression): \nP")
+the logical sexpression matching."
+  (interactive "sFind rolo string (or logical sexpression): \nP")
   (let ((total-matches 0))
     (if (string-match "\(\\(and\\|or\\|xor\\|not\\)\\>" string)
        (progn
          ;; Search string contains embedded logic operators.
-         ;; First try to match logical expression within a single
+         ;; First try to match logical sexpression within a single
          ;; subentry to minimize entries displayed.  If no match,
          ;; then match across ancestors and descendants.
          (when (zerop (setq total-matches (hyrolo-fgrep-logical string 
count-only nil t)))
@@ -431,8 +443,9 @@ the logical expression matching."
     total-matches))
 
 ;;;###autoload
-(defun hyrolo-find-file (&optional file)
-  "Select and edit a file in `hyrolo-file-list', defaulting to the first 
listed file when not given a prefix arg."
+(defun hyrolo-find-file (&optional file find-function &rest args)
+  "Select and edit a FILE in `hyrolo-file-list' with FIND-FUNCTION.
+Default to the first listed file when not given a prefix arg."
   (interactive "P")
   (when (or (called-interactively-p 'interactive)
            (null file))
@@ -442,8 +455,17 @@ the logical expression matching."
       (setq file (completing-read "Edit HyRolo file: "
                                  (mapcar #'list hyrolo-file-list)))))
   (when (stringp file)
-    (funcall hyrolo-find-file-function file)
-    (setq buffer-read-only nil)))
+    (prog1 (apply (or find-function hyrolo-find-file-function) file args)
+      (setq buffer-read-only nil))))
+
+;;;###autoload
+(defun hyrolo-find-file-noselect (&optional file)
+  "HyRolo function to read a FILE in literally.
+It uses the setting of `hyrolo-find-file-noselect-function'."
+  (if (string-match "\\.org$" file)
+      (let ((find-file-literally t))
+       (hyrolo-find-file file hyrolo-find-file-noselect-function nil t))
+    (hyrolo-find-file file hyrolo-find-file-noselect-function)))
 
 (defun hyrolo-forward-visible-line (&optional arg)
   "Move forward by optional ARG lines (default = 1), ignoring currently 
invisible newlines only.
@@ -492,7 +514,7 @@ Return number of entries matched.  See also documentation 
for the variable
     (while (and (setq file (car hyrolo-file-list))
                (or (not (integerp max-matches))
                    (< total-matches (max max-matches (- max-matches)))))
-      (setq hyrolo-buf (find-file-noselect file t)
+      (setq hyrolo-buf (hyrolo-find-file-noselect file)
            hyrolo-entry-regexps (set:add (buffer-local-value 
'hyrolo-entry-regexp hyrolo-buf)
                                          hyrolo-entry-regexps)
            outline-regexps (set:add (buffer-local-value 'outline-regexp 
hyrolo-buf)
@@ -568,7 +590,7 @@ search for the current match string rather than regular 
expression."
   (interactive "P")
   (if arg
       (hyrolo-isearch)
-    (hyrolo-isearch-for-regexp hyrolo-match-regexp)))
+    (hyrolo-isearch-for-regexp hyrolo-match-regexp t)))
 
 (defun hyrolo-verify ()
   "Verify point is in a rolo match buffer."
@@ -603,6 +625,7 @@ Return t if entry is killed, nil otherwise."
                       (setq killed t)
                       (hyrolo-save-buffer)
                       (hyrolo-kill-buffer)))
+                   (case-fold-search)
                    start end level-len)
                (setq buffer-read-only nil)
                (re-search-backward hyrolo-entry-regexp nil t)
@@ -632,7 +655,7 @@ Return t if entry is killed, nil otherwise."
 (defun hyrolo-locate ()
   "Interactively search for an entry beginning with a set of search 
characters."
   (interactive)
-  (hyrolo-isearch-for-regexp hyrolo-entry-regexp))
+  (hyrolo-isearch-for-regexp hyrolo-entry-regexp nil))
 
 (defun hyrolo-mail-to ()
   "Start composing mail addressed to the first e-mail address at or after 
point."
@@ -840,10 +863,11 @@ Useful when bound to a mouse key."
   (interactive)
   (if (buffer-narrowed-p)
       (hyrolo-widen)
-    (when (or (looking-at hyrolo-entry-regexp)
-             (re-search-backward hyrolo-entry-regexp nil t))
-      (forward-char)
-      (narrow-to-region (1- (point)) (hyrolo-display-to-entry-end))))
+    (let (case-fold-search)
+      (when (or (looking-at hyrolo-entry-regexp)
+               (re-search-backward hyrolo-entry-regexp nil t))
+       (forward-char)
+       (narrow-to-region (1- (point)) (hyrolo-display-to-entry-end)))))
   (hyrolo-shrink-window)
   (goto-char (point-min)))
 
@@ -993,7 +1017,8 @@ Output looks like so:
        (current-prefix-arg))
     (call-interactively (if arg 'hyrolo-fgrep 'hyrolo-grep))
     (read-only-mode 0)
-    (re-search-forward hyrolo-entry-regexp nil t)
+    (let (case-fold-search)
+      (re-search-forward hyrolo-entry-regexp nil t))
     (beginning-of-line)
     (set-buffer-modified-p nil)
     (read-only-mode 1)))
@@ -1144,42 +1169,73 @@ otherwise just use the cdr of the item."
 ;;; ************************************************************************
 
 ;;;###autoload
-(defun hyrolo-helm-org-rifle ()
-  "Prompt for a search pattern with helm and interactively show all matches 
from `hyrolo-file-list'."
-  (interactive)
+(defun hyrolo-helm-org-rifle (&optional context-only-flag)
+  "Prompt for a helm search pattern and show all matches from 
`hyrolo-file-list'.
+Only readable .org and .otl files are searched.  With optional
+prefix arg CONTEXT-ONLY-FLAG, show only an extra line of context
+around a matching line rather than entire entries."
+  (interactive "P")
   (unless (package-installed-p 'helm-org-rifle)
     (package-install 'helm-org-rifle))
   (require 'helm-org-rifle)
-  (let ((files (seq-filter #'file-readable-p hyrolo-file-list)))
+  (let ((files (seq-filter (lambda (f) (string-match "\\.\\(org\\|otl\\)$" f))
+                          (seq-filter #'file-readable-p hyrolo-file-list)))
+       (helm-org-rifle-show-full-contents (not context-only-flag)))
     (save-excursion
       (mapc (lambda (file)
-             (set-buffer (find-file-noselect file))
+             (set-buffer (hyrolo-find-file-noselect file))
              (org-mode))
            files))
     (helm-org-rifle-files files)))
 
+;;;###autoload
+(defun hyrolo-helm-org-directory-rifle (&optional context-only-flag)
+  "Interactively search over `org-directory'.
+With optional prefix arg CONTEXT-ONLY-FLAG, show only an extra
+line of context around a matching line rather than entire
+entries."
+  (interactive)
+  (unless (package-installed-p 'helm-org-rifle)
+    (package-install 'helm-org-rifle))
+  (require 'helm-org-rifle)
+  (require 'org)
+  (unless (file-readable-p org-directory)
+    (make-directory org-directory))
+  (if (file-readable-p org-directory)
+      (let ((helm-org-rifle-show-full-contents (not context-only-flag)))
+       (helm-org-rifle-org-directory))
+    (error "(hyrolo-helm-org-directory-rifle): `org-directory', \"%s\", does 
not exist" org-directory)))
+
+;;;###autoload
+(defun hyrolo-helm-org-rifle-directories (&optional context-only-flag &rest 
dirs)
+  "Interactively search over Emacs outline format files in rest of DIRS.
+Only readable .org and .otl files are searched.  With optional
+prefix arg CONTEXT-ONLY-FLAG, show only an extra line of context
+around a matching line rather than entire entries."
+  (interactive "P")
+  (let ((hyrolo-file-list (hypb:filter-directories "\\.\\(org\\|otl\\)$" 
dirs)))
+    (hyrolo-helm-org-rifle context-only-flag)))
+
 ;;;###autoload
 (defun hyrolo-org (string &optional max-matches)
-  "Prompt for patterns and search Org directory files for STRING or 
logic-based matches.
+  "Search `org-directory' files for STRING or logic-based matches.
 OPTIONAL prefix arg, MAX-MATCHES, limits the number of matches
 returned to the number given."
-  (interactive "sFind Org directory string (or logical expression): \nP")
+  (interactive "sFind Org directory string (or logical sexpression): \nP")
   (require 'org)
   (unless (file-readable-p org-directory)
     (make-directory org-directory))
   (if (file-readable-p org-directory)
-      (if (fboundp #'helm-org-rifle-org-directory)
-         (helm-org-rifle-org-directory)
-       (let ((hyrolo-file-list (directory-files org-directory t "\\.org$")))
-         (hyrolo-fgrep string max-matches)))
+      (let ((hyrolo-file-list (directory-files org-directory t "\\.org$")))
+       (hyrolo-fgrep string max-matches))
     (error "(hyrolo-org): `org-directory', \"%s\", does not exist" 
org-directory)))
 
 ;;;###autoload
 (defun hyrolo-org-roam (string &optional max-matches)
-  "Search Org Roam directory files for STRING or logic-based matches.
+  "Search Org Roam directory files for STRING or logical sexpression.
 OPTIONAL prefix arg, MAX-MATCHES, limits the number of matches
 returned to the number given."
-  (interactive "sFind Org Roam directory string (or logical expression): \nP")
+  (interactive "sFind Org Roam directory string (or logical sexpression): \nP")
   (unless (package-installed-p 'org-roam)
     (package-install #'org-roam))
   (require 'org-roam)
@@ -1196,21 +1252,33 @@ returned to the number given."
 ;;; Public functions
 ;;; ************************************************************************
 
+;;;###autoload
+(defun hyrolo-fgrep-directories (file-regexp &rest dirs)
+  "String/logical HyRolo search over files matching FILE-REGEXP in rest of 
DIRS."
+  (hyrolo-search-directories #'hyrolo-fgrep file-regexp dirs))
+
 (defun hyrolo-fgrep-file (hyrolo-file-or-buf string &optional max-matches 
count-only)
   "Retrieve entries in HYROLO-FILE-OR-BUF matching STRING to a maximum of 
optional MAX-MATCHES.
 Nil value of MAX-MATCHES means find all matches, t value means find all matches
 but omit file headers, negative values mean find up to the inverse of that
 number of entries and omit file headers.  Optional COUNT-ONLY non-nil
 means don't retrieve matching entries.
+
 Return number of matching entries found."
   (hyrolo-grep-file hyrolo-file-or-buf (regexp-quote string) max-matches 
count-only))
 
+;;;###autoload
+(defun hyrolo-grep-directories (file-regexp &rest dirs)
+  "Regexp HyRolo search over files matching FILE-REGEXP in rest of DIRS."
+  (hyrolo-search-directories #'hyrolo-grep file-regexp dirs))
+
 (defun hyrolo-grep-file (hyrolo-file-or-buf regexp &optional max-matches 
count-only)
   "Retrieve entries in HYROLO-FILE-OR-BUF matching REGEXP to a maximum of 
optional MAX-MATCHES.
 Nil value of MAX-MATCHES means find all matches, t value means find all matches
 but omit file headers, negative values mean find up to the inverse of that
 number of entries and omit file headers.  Optional COUNT-ONLY non-nil
 means don't retrieve matching entries.
+
 Return number of matching entries found."
   ;;
   ;; Save regexp as last rolo search expression.
@@ -1224,7 +1292,7 @@ Return number of matching entries found."
     (if (and (or (null max-matches) (eq max-matches t) (integerp max-matches))
             (or (setq actual-buf (hyrolo-buffer-exists-p hyrolo-file-or-buf))
                 (when (file-exists-p hyrolo-file-or-buf)
-                  (setq actual-buf (find-file-noselect hyrolo-file-or-buf t)
+                  (setq actual-buf (hyrolo-find-file-noselect 
hyrolo-file-or-buf)
                         new-buf-p t))))
        (let ((hdr-pos) (num-found 0) (curr-entry-level-len)
              (incl-hdr t) start next-entry-exists)
@@ -1246,38 +1314,39 @@ Return number of matching entries found."
              (when (re-search-forward hyrolo-hdr-regexp nil t 2)
                (forward-line)
                (setq hdr-pos (cons (point-min) (point))))
-             (re-search-forward hyrolo-entry-regexp nil t)
-             (while (and (or (null max-matches) (< num-found max-matches))
-                         (re-search-forward regexp nil t))
-               (re-search-backward hyrolo-entry-regexp nil t)
-               (setq start (point)
-                     next-entry-exists nil)
+             (let (case-fold-search)
                (re-search-forward hyrolo-entry-regexp nil t)
-               (setq curr-entry-level-len (length 
(buffer-substring-no-properties start (point))))
-               (hyrolo-to-entry-end t curr-entry-level-len)
-               (or count-only
-                   (if (and (zerop num-found) incl-hdr)
-                       (let* ((src (or (buffer-file-name actual-buf)
-                                       actual-buf))
-                              (src-line
-                               (format
-                                (concat (if (boundp 'hbut:source-prefix)
-                                            hbut:source-prefix
-                                          "@loc> ")
-                                        "%s")
-                                (prin1-to-string src))))
-                         (set-buffer hyrolo-display-buffer)
-                         (goto-char (point-max))
-                         (if hdr-pos
-                             (progn
-                               (insert-buffer-substring-no-properties
-                                actual-buf (car hdr-pos) (cdr hdr-pos))
-                               (insert src-line "\n\n"))
-                           (insert (format hyrolo-hdr-format src-line)))
-                         (set-buffer actual-buf))))
-               (setq num-found (1+ num-found))
-               (or count-only
-                   (hyrolo-add-match hyrolo-display-buffer regexp start 
(point))))))
+               (while (and (or (null max-matches) (< num-found max-matches))
+                           (re-search-forward regexp nil t))
+                 (re-search-backward hyrolo-entry-regexp nil t)
+                 (setq start (point)
+                       next-entry-exists nil)
+                 (re-search-forward hyrolo-entry-regexp nil t)
+                 (setq curr-entry-level-len (length 
(buffer-substring-no-properties start (point))))
+                 (hyrolo-to-entry-end t curr-entry-level-len)
+                 (or count-only
+                     (if (and (zerop num-found) incl-hdr)
+                         (let* ((src (or (buffer-file-name actual-buf)
+                                         actual-buf))
+                                (src-line
+                                 (format
+                                  (concat (if (boundp 'hbut:source-prefix)
+                                              hbut:source-prefix
+                                            "@loc> ")
+                                          "%s")
+                                  (prin1-to-string src))))
+                           (set-buffer hyrolo-display-buffer)
+                           (goto-char (point-max))
+                           (if hdr-pos
+                               (progn
+                                 (insert-buffer-substring-no-properties
+                                  actual-buf (car hdr-pos) (cdr hdr-pos))
+                                 (insert src-line "\n\n"))
+                             (insert (format hyrolo-hdr-format src-line)))
+                           (set-buffer actual-buf))))
+                 (setq num-found (1+ num-found))
+                 (or count-only
+                     (hyrolo-add-match hyrolo-display-buffer regexp start 
(point)))))))
          (hyrolo-kill-buffer actual-buf)
          num-found)
       0)))
@@ -1290,12 +1359,13 @@ start and the end of the region that it should 
manipulate.  LEVEL-REGEXP
 should match the prefix text of any rolo entry of the given level, not the
 beginning of a line (^); an example, might be (regexp-quote \"**\") to match
 level two.
+
 Return number of groupings matched."
   (let ((actual-buf))
     (if (not (and (or (null max-groupings) (< 0 max-groupings))
                  (or (setq actual-buf (hyrolo-buffer-exists-p 
hyrolo-file-or-buf))
                      (when (file-readable-p hyrolo-file-or-buf)
-                       (setq actual-buf (find-file-noselect hyrolo-file-or-buf 
t))
+                       (setq actual-buf (hyrolo-find-file-noselect 
hyrolo-file-or-buf))
                        t))))
        0
       (set-buffer actual-buf)
@@ -1354,7 +1424,7 @@ Return number of groupings matched."
 (defun hyrolo-add-match (hyrolo-matches-buffer regexp start end)
   "Insert before point in HYROLO-MATCHES-BUFFER an entry matching REGEXP from 
the current region between START to END."
   (let ((hyrolo-buf (current-buffer))
-       (hyrolo-entry (buffer-substring-no-properties start end))
+       (hyrolo-entry (buffer-substring start end))
        opoint)
     (set-buffer (get-buffer-create hyrolo-matches-buffer))
     (setq opoint (point))
@@ -1376,10 +1446,11 @@ HYROLO-BUF may be a file-name, `buffer-name', or 
buffer."
 
 (defun hyrolo-display-to-entry-end ()
   "Go to end of current entry, ignoring sub-entries."
-  (if (re-search-forward (concat hyrolo-hdr-regexp "\\|"
-                                hyrolo-entry-regexp) nil t)
-      (progn (beginning-of-line) (point))
-    (goto-char (point-max))))
+  (let (case-fold-search)
+    (if (re-search-forward (concat hyrolo-hdr-regexp "\\|"
+                                  hyrolo-entry-regexp) nil t)
+       (progn (beginning-of-line) (point))
+      (goto-char (point-max)))))
 
 
 (defun hyrolo-format-name (name-str first last)
@@ -1400,14 +1471,14 @@ HYROLO-BUF may be a file-name, `buffer-name', or 
buffer."
                             (or hyrolo-highlight-face
                                 hproperty:highlight-face)))))))
 
-(defun hyrolo-isearch-for-regexp (regexp)
-  "Interactively search forward for the next occurrence of current match 
REGEXP.
+(defun hyrolo-isearch-for-regexp (regexp fold-search-flag)
+  "Interactively search forward for the next occurrence of REGEXP.
 Then add characters to further narrow the search."
   (hyrolo-verify)
   (if (stringp regexp)
       (setq unread-command-events
            (append unread-command-events (string-to-list regexp))))
-  (let ((case-fold-search t))
+  (let ((case-fold-search fold-search-flag))
     (isearch-forward-regexp)))
 
 (defun hyrolo-kill-buffer (&optional hyrolo-buf)
@@ -1457,12 +1528,13 @@ Name is returned as `last, first-and-middle'."
   (when (string-equal (buffer-name) hyrolo-display-buffer)
     (save-excursion
       (beginning-of-line)
-      (when (looking-at hyrolo-entry-regexp)
-       (goto-char (match-end 0))
-       (skip-chars-forward " \t")
-       (when (or (looking-at "[^ \t\n\r]+ ?, ?[^ \t\n\r]+")
-                 (looking-at "\\( ?[^ \t\n\r]+\\)+"))
-         (match-string-no-properties 0))))))
+      (let (case-fold-search)
+       (when (looking-at hyrolo-entry-regexp)
+         (goto-char (match-end 0))
+         (skip-chars-forward " \t")
+         (when (or (looking-at "[^ \t\n\r]+ ?, ?[^ \t\n\r]+")
+                   (looking-at "\\( ?[^ \t\n\r]+\\)+"))
+           (match-string-no-properties 0)))))))
 
 (defun hyrolo-save-buffer (&optional hyrolo-buf)
   "Save optional HYROLO-BUF if changed and `hyrolo-save-buffers-after-use' is 
t.
@@ -1507,6 +1579,13 @@ a default of MM/DD/YYYY."
     ;; (goto-char (previous-single-char-property-change (point) 'invisible))))
     (goto-char (1- (point)))))
 
+(defun hyrolo-search-directories (search-cmd file-regexp &rest dirs)
+  "Search HyRolo over files matching FILE-REGEXP in rest of DIRS."
+  (when (or (null file-regexp) (string-empty-p file-regexp))
+    (setq file-regexp hyrolo-file-suffix-regexp))
+  (let ((hyrolo-file-list (hypb:filter-directories file-regexp dirs)))
+    (call-interactively search-cmd)))
+
 (defun hyrolo-show-levels (num-levels)
   "Show only the first line of up to NUM-LEVELS of rolo matches.  NUM-LEVELS 
must be 1 or greater.
 NUM-LEVELS is relative to the first level of matches, so if NUM-LEVELS
@@ -1571,7 +1650,7 @@ Return point where matching entry begins or nil if not 
found."
             (error "(hyrolo-to): Invalid file: `%s'" file))
            ((and (file-exists-p file) (not (file-readable-p file)))
             (error "(hyrolo-to): File not readable: `%s'" file)))
-      (set-buffer (or (get-file-buffer file) (find-file-noselect file)))
+      (set-buffer (or (get-file-buffer file) (hyrolo-find-file-noselect file)))
       (let ((case-fold-search t) (real-name name) (parent "") (level) end)
        (hyrolo-widen) (goto-char 1)
        (while (string-match "\\`[^\]\[<>{}\"]*/" name)
@@ -1637,13 +1716,13 @@ Return current point."
         (funcall (default-value #'outline-level)))
        ((looking-at hyrolo-hdr-regexp)
         0)
-       ((featurep 'kview)
-        ;; assume on an entry from an alpha or legal Koutline
+       ((and (featurep 'kview)
+             (looking-at kview:outline-regexp))
+        ;; Assume on an entry from an alpha or legal Koutline
         ;; with default outline settings
-        (kcell-view:level)
-        (setq lbl-sep-len (length kview:default-label-separator))
-        (floor (/ (- (or (kcell-view:indent nil lbl-sep-len)) lbl-sep-len)
-                  kview:default-level-indent)))
+        (let ((lbl-sep-len (length kview:default-label-separator)))
+          (floor (/ (- (or (kcell-view:indent nil lbl-sep-len)) lbl-sep-len)
+                    kview:default-level-indent))))
        ;; Just default to top-level if no other outline type is found
        (t 1)))
 
@@ -1652,6 +1731,14 @@ Return current point."
 Calls the functions given by `hyrolo-mode-hook'.
 \\{hyrolo-mode-map}"
   (interactive)
+  (unless (eq major-mode 'hyrolo-mode)
+    (make-local-variable 'outline-regexp)
+    (setq outline-regexp (default-value 'outline-regexp))
+    (make-local-variable 'hyrolo-entry-regexp)
+    (setq hyrolo-entry-regexp (default-value 'hyrolo-entry-regexp))
+    (make-local-variable 'outline-level)
+    (setq outline-level #'hyrolo-mode-outline-level)
+    (reveal-mode 1)) ;; Expose hidden text as move into it.
   (setq major-mode 'hyrolo-mode
        mode-name "HyRolo")
   (use-local-map hyrolo-mode-map)
@@ -1660,11 +1747,6 @@ Calls the functions given by `hyrolo-mode-hook'.
   ;;
   (when (fboundp 'outline-minor-mode)
     (outline-minor-mode 1))
-  (make-local-variable 'hyrolo-entry-regexp)
-  (setq hyrolo-entry-regexp (default-value 'hyrolo-entry-regexp))
-  (make-local-variable 'outline-level)
-  (setq outline-level #'hyrolo-mode-outline-level)
-  (reveal-mode 1) ;; Expose hidden text as move into it.
   (run-hooks 'hyrolo-mode-hook))
 
 ;;; ************************************************************************
diff --git a/kotl/kimport.el b/kotl/kimport.el
index bb1600d63a..6ec9b06497 100644
--- a/kotl/kimport.el
+++ b/kotl/kimport.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    15-Nov-93 at 11:57:05
-;; Last-Mod:     18-Jul-22 at 21:50:27 by Mats Lidell
+;; Last-Mod:     28-Aug-22 at 14:07:09 by Bob Weiner
 ;;
 ;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
@@ -630,6 +630,7 @@ in IMPORT-FROM, used to show a running tally of the 
imported entries."
   (set-buffer import-from)
   (let ((start (point))
        (hyrolo-entry-regexp kimport:star-heading)
+       (case-fold-search)
        subtree-p end contents node-level child-label)
     ;; While find cells at import-level or deeper ...
     (while (and (re-search-forward hyrolo-entry-regexp nil t)
diff --git a/kotl/klink.el b/kotl/klink.el
index 8ef29cfeb3..f716d39989 100644
--- a/kotl/klink.el
+++ b/kotl/klink.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    15-Nov-93 at 12:15:16
-;; Last-Mod:     18-Jul-22 at 21:50:46 by Mats Lidell
+;; Last-Mod:     29-Aug-22 at 01:12:26 by Bob Weiner
 ;;
 ;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
@@ -188,8 +188,8 @@ link-end-position, (including delimiters)."
           (or (string-match "^ *[-@|!&]" referent)
               (if (string-match "\\s-*," referent)
                   (progn (setq path (substring referent 0 (match-beginning 0)))
-                         (hpath:is-p path))
-                (hpath:is-p referent)))
+                         (hpath:is-p (expand-file-name path 
(file-name-directory (hbut:get-key-src)))))
+                (hpath:is-p (expand-file-name referent (file-name-directory 
(hbut:get-key-src))))))
           ;; Eliminate matches to e-mail addresses like, <user@domain>
           (not (string-match "[^<> \t\n\r\f][!&@]" referent))
           ;; Eliminate matches to URLs
@@ -265,11 +265,11 @@ See documentation for `kcell:ref-to-id' for valid 
cell-ref formats."
 (defun klink:act (link start-pos)
   (let ((obuf (current-buffer)))
     ;; Perform klink's action which is to jump to link referent.
-    (hact 'link-to-kotl link)
-    (save-excursion
-      ;; Update klink label if need be, which might be in a different buffer
-      ;; than the current one.
-      (klink:update-label link start-pos obuf))))
+    (prog1 (hact 'link-to-kotl link)
+      (save-excursion
+       ;; Update klink label if need be, which might be in a different buffer
+       ;; than the current one.
+       (klink:update-label link start-pos obuf)))))
 
 (defun klink:parse (reference)
   "Return (file-ref cell-ref) list parsed from REFERENCE string.
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index 675283367b..a325db1625 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    6/30/93
-;; Last-Mod:     20-Aug-22 at 18:29:51 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:15:34 by Bob Weiner
 ;;
 ;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
@@ -1553,7 +1553,6 @@ See `forward-paragraph' for more information."
   (point))
 
 ;;; This ensures that the key bound to `beginning-of-line' is replaced in 
kotl-mode.
-(define-obsolete-function-alias 'kotl-mode:to-start-of-line 
#'kotl-mode:beginning-of-line "8.0.1")
 (defalias 'kotl-mode:beginning-of-visual-line 'kotl-mode:beginning-of-line)
 (defalias 'kotl-mode:move-beginning-of-line 'kotl-mode:beginning-of-line)
 
diff --git a/kotl/kview.el b/kotl/kview.el
index 5c0258c4b6..127917bd2c 100644
--- a/kotl/kview.el
+++ b/kotl/kview.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    6/30/93
-;; Last-Mod:     11-Aug-22 at 00:31:40 by Bob Weiner
+;; Last-Mod:     29-Aug-22 at 00:15:19 by Bob Weiner
 ;;
 ;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
@@ -362,7 +362,8 @@ cell's label and the start of its contents."
   (+ (save-excursion
        (kcell-view:to-label-end pos)
        (current-column))
-     (or lbl-sep-len (kview:label-separator-length kview))))
+     (or lbl-sep-len (kview:label-separator-length kview)
+        (length kview:default-label-separator))))
 
 (defun kcell-view:label (&optional pos)
   "Return displayed label string of cell at optional POS or point.
@@ -470,21 +471,21 @@ Return t unless no previous cell."
   "Move point from optional POS to the end of the current cell's label (before 
the label separator) and return point.
 If between kcells, move to the previous one.  The current cell may be hidden."
   (when pos (goto-char pos))
-  (kview:end-of-actual-line)
-  (cond ((null kview)
-        (error "(kcell-view:to-label-end): Invalid kview in %s; try {M-x 
kotl-mode RET} to fix it"
-               (current-buffer)))
-       (t
-        (let (found)
-          (unless (setq found (kproperty:get (1- (point)) 'kcell))
-            ;; If not at beginning of cell contents, move there.
-            (goto-char (kproperty:previous-single-change (point) 'kcell)))
-          ;; Then move to the end of the label (prior to label
-          ;; separator) via embedded kcell property.
-          (goto-char (setq found (kproperty:previous-single-change (point) 
'kcell)))
-          (if found
-              (point)
-            (error "(kcell-view:to-label-end): Can't find end of current 
cell's label"))))))
+  (if (save-excursion
+       (goto-char (line-beginning-position))
+       (looking-at kview:outline-regexp))
+      (setq found (goto-char (- (match-end 0) 2)))
+    (kview:end-of-actual-line)
+    (let (found)
+      (unless (setq found (kproperty:get (1- (point)) 'kcell))
+       ;; If not at beginning of cell contents, move there.
+       (goto-char (kproperty:previous-single-change (point) 'kcell)))
+      ;; Then move to the end of the label (prior to label
+      ;; separator) via embedded kcell property.
+      (goto-char (setq found (kproperty:previous-single-change (point) 
'kcell)))
+      (if found
+         (point)
+       (error "(kcell-view:to-label-end): Can't find end of current cell's 
label")))))
 
 (defun kcell-view:absolute-reference (&optional pos)
   "Return a klink to the kcell at optional POS or point; return nil if not in 
a kcell.
@@ -1075,7 +1076,6 @@ See also `kview:map-region', `kview:map-branch' and 
`kview:map-siblings'."
            ;; Next line ensures point is in the root of the current tree if
            ;; the tree is at all hidden.
            (kotl-mode:beginning-of-line)
-           (kotl-mode:to-start-of-line)
            (setq cell-indent (kcell-view:indent nil lbl-sep-len))
            ;; Terminate when no further cells or when reach a cell at an equal
            ;; or higher level in the kotl than the first cell that we 
processed.
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index 280743a083..7f532feb18 100644
--- a/test/hyrolo-tests.el
+++ b/test/hyrolo-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    19-Jun-21 at 22:42:00
-;; Last-Mod:      9-Apr-22 at 22:52:56 by Mats Lidell
+;; Last-Mod:     29-Aug-22 at 02:05:34 by Bob Weiner
 ;;
 ;; Copyright (C) 2021-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -56,7 +56,7 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-tab-jump-to-first-match ()
-  "Tab shall jump to first match."
+  "{TAB} shall jump to first match."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -68,7 +68,7 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-toggle-visibility ()
-  "Keys h and a shall toggle visibility."
+  "Keys {h} and {a} shall toggle visibility."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -94,7 +94,7 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-show-overview ()
-  "Keys o shall show overview."
+  "Key {o} shall show overview."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -102,30 +102,25 @@
         (should (hact 'kbd-key "C-x 4r work RET TAB"))
         (hy-test-helpers:consume-input-events)
         (should (string= (buffer-name) "*Hyperbole Rolo*"))
-        (should (looking-at "Work"))
+        (should (looking-at "work"))
 
         (should (hact 'kbd-key "o"))
         (hy-test-helpers:consume-input-events)
         (end-of-line)
-        (should-not (get-char-property (point) 'invisible))
-
-        ;; Check second line is an outline
-        (should (hact 'kbd-key "n"))
-        (end-of-line)
         (should (get-char-property (point) 'invisible))
 
-        ;; Check third line is an outline
-        (should (hact 'kbd-key "n"))
+        ;; Check next match is an outline
+        (should (hact 'kbd-key "TAB"))
         (end-of-line)
         (should (get-char-property (point) 'invisible))
 
-        ;; Check fourth line is end of buffer
+        ;; Check next line is end of buffer
         (should (hact 'kbd-key "n"))
         (should (equal (point) (point-max))))
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-move-to-beginning-and-end-of-file ()
-  "Keys '<', '.' and '>', ',' shall move to beginning and end of file 
respectively."
+  "Keys {<} or {.} and {>} or {,} shall move to beginning and end of file, 
respectively."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -149,7 +144,8 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-move-between-entries-on-same-level ()
-  "Keys '<', '.' and '>', ',' shall move to beginning and end of file 
respectively."
+  "Key {n} shall move to the next cell, {f} the next same level cell,
+and {b} the previous same level cell."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -200,7 +196,7 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-sort-test ()
-  "Rolo files can be sorted."
+  "HyRolo files can be sorted."
   (let ((hyrolo-file (make-temp-file "hypb" nil ".otl")))
     (unwind-protect
         (let ((hyrolo-file-list (list hyrolo-file)))
@@ -231,7 +227,7 @@
       (delete-file hyrolo-file))))
 
 (ert-deftest hyrolo-sort-records-at-different-levels ()
-  "Rolo can sort records at different levels."
+  "HyRolo can sort records at different levels."
   (let ((hyrolo-file (make-temp-file "hypb" nil ".otl"
                                      (concat "* 2\n\t2022-03-20\n"
                                              "** 2\n\t2022-03-20\n"



reply via email to

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