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

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

[elpa] externals/hyperbole 802a688acf 006/143: Fix hyrolo-mode-map outli


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 802a688acf 006/143: Fix hyrolo-mode-map outlining key bindings
Date: Mon, 19 Feb 2024 15:58:43 -0500 (EST)

branch: externals/hyperbole
commit 802a688acf9370fd59e9849ea8586025ec89705a
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>

    Fix hyrolo-mode-map outlining key bindings
    
    Make hyrolo cache variables buffer-local to allow multiple commands
    to have their own hyrolo display buffers.
    
    Fix hyrolo-logic.el to handle multiple file formats (not yet tested).
    
    test/hyrolo-tests.el (hyrolo-demo-move-to-beginning-and-end-of-file):
      Move to {,} and {.} tests to sep test.
---
 ChangeLog            |  30 +++++++++++
 hyrolo-logic.el      |  41 +++++++++------
 hyrolo.el            | 139 +++++++++++++++++++++++++++++----------------------
 test/hyrolo-tests.el |  18 +++++--
 4 files changed, 148 insertions(+), 80 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c16bfce06..2c3f07db09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2023-12-14  Bob Weiner  <rsw@gnu.org>
+
+* hyrolo.el (hyrolo-grep): Remove '(set-buffer display-buf)' since call to
+    'hyrolo-display-matches' does this.
+            (hyrolo-mode-map): Fix bindings of hyrolo-* overloads of
+    'outline-mode-prefix-map' (outline-minor-mode).
+
+2023-12-13  Bob Weiner  <rsw@gnu.org>
+
+* hyrolo-logic.el (hyrolo-map-logic): Add doc for last arg,
+    whole-buffer-flag.
+                  (hyrolo-logic): Add calls to 'hyrolo--cache-initialize' and
+    'hyrolo--cache-post-display-buffer'.
+    Also add temporary disabling of 'magit-auto-revert-mode-enable-in-buffers'
+    in 'after-change-major-mode-hook' to speed file processing.
+                  (hyrolo-map-entries, hyrolo-map-kotl): Add call to
+    'hyrolo--cache-major-mode'.
+  hyrolo.el (hyrolo-grep-file): Change 'delq' to 'remove' so does not
+    permanently modify the 'after-change-major-mode-hook'.
+
+* hyrolo.el (hyrolo--cache-initialize, hyrolo--cache-major-mode): Ensure
+    all settings apply to `hyrolo-display-buffer' local variables.
+            (hyrolo-find-file): Fix doc string.
+           (hyrolo-set-file-list, hyrolo-let-file-list): Remove call to
+    'hyrolo--cache-initialize'.
+
+* test/hyrolo-tests.el (hyrolo-demo-move-to-beginning-and-end-of-file):
+    Move to {,} and {.} tests to sep test,
+    'hyrolo-demo-move-to-beginning-and-end-of-entry'.
+
 2023-12-12  Bob Weiner  <rsw@gnu.org>
 
 * hyrolo.el (hyrolo-mode): Add trailing space to default `outline-regexp'.
diff --git a/hyrolo-logic.el b/hyrolo-logic.el
index efee72e800..833bb9ce32 100644
--- a/hyrolo-logic.el
+++ b/hyrolo-logic.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    13-Jun-89 at 22:57:33
-;; Last-Mod:     10-Dec-23 at 17:24:59 by Bob Weiner
+;; Last-Mod:     14-Dec-23 at 00:22:05 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -171,9 +171,13 @@ is nil and optional NO-SUB-ENTRIES-OUT flag is non-nil.  
SEXP should utilize the
 free variables `start' and `end' as the region on which to operate.
 Return the number of evaluations of SEXP that match entries."
   (let* ((display-buf (unless count-only
-                      (prog1 (hyrolo-set-display-buffer)
-                        (setq buffer-read-only nil)
-                        (erase-buffer))))
+                       (prog1 (hyrolo-set-display-buffer)
+                         (erase-buffer)
+                         (hyrolo--cache-initialize))))
+        ;; Temporarily disable magit-auto-revert-mode-enable-in-buffers for 
hyrolo
+        ;; buffers; not needed and can slow/hang file loading
+        (after-change-major-mode-hook
+         (remove 'magit-auto-revert-mode-enable-in-buffers 
after-change-major-mode-hook))
         (result
          (mapcar
           (lambda (buf-or-file)
@@ -186,8 +190,9 @@ Return the number of evaluations of SEXP that match 
entries."
                 ((list in-bufs)))))
         (total-matches (apply '+ result)))
     (unless (or count-only (= total-matches 0))
+      (hyrolo--cache-post-display-buffer)
       (hyrolo-display-matches display-buf))
-    total-matches))
+  total-matches))
 
 (defun hyrolo-map-logic (sexp hyrolo-buf &optional count-only
                         include-sub-entries _no-sub-entries-out
@@ -200,17 +205,19 @@ flag is non-nil, apply SEXP across all sub-entries at 
once.
 Default is to apply SEXP to each entry and sub-entry separately.
 Entries are displayed with all of their sub-entries unless
 INCLUDE-SUB-ENTRIES is nil and optional NO-SUB-ENTRIES-OUT flag
-is non-nil.  SEXP should utilize the free variables `start' and
-`end' as the region on which to operate.  Return the number of
-evaluations of SEXP that match entries."
+is non-nil.  With optional WHOLE-BUFFER-FLAG, map entries with
+`hyrolo-map-kotl' rather than `hyrolo-map-entries'.
+
+SEXP should utilize the free variables `start' and `end' as the
+region on which to operate.  Return the number of evaluations of
+SEXP that match entries."
   (setq hyrolo-buf (or (get-buffer hyrolo-buf) hyrolo-buf))
   (if (or (bufferp hyrolo-buf)
          (when (file-exists-p hyrolo-buf)
            (setq hyrolo-buf (find-file-noselect hyrolo-buf t))))
-      (let* ((display-buf (hyrolo-set-display-buffer))
-            (buffer-read-only)
-            (hdr-pos)
-            (num-found 0))
+      (let ((display-buf (hyrolo-set-display-buffer))
+           (hdr-pos)
+           (num-found 0))
          (set-buffer hyrolo-buf)
          (save-excursion
            (save-restriction
@@ -267,8 +274,9 @@ evaluations of SEXP that match entries."
        (if result
            (progn (goto-char end)
                   (setq num-found (1+ num-found))
-                  (or count-only
-                      (append-to-buffer display-buf start end)))
+                  (unless count-only
+                    (append-to-buffer display-buf start end)
+                    (hyrolo--cache-major-mode hyrolo-buf)))
          (goto-char end-entry-hdr))))
     num-found))
 
@@ -306,8 +314,9 @@ evaluations of SEXP that match entries."
              (if result
                  (progn (goto-char end)
                         (setq num-found (1+ num-found))
-                        (or count-only
-                            (append-to-buffer display-buf start end)))
+                        (unless count-only
+                          (append-to-buffer display-buf start end)
+                          (hyrolo--cache-major-mode (current-buffer))))
                (goto-char end-entry-hdr))))
          sexp)
     num-found))
diff --git a/hyrolo.el b/hyrolo.el
index 1f2b1d9cf5..ad54a5054a 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:     12-Dec-23 at 03:34:06 by Bob Weiner
+;; Last-Mod:     14-Dec-23 at 12:00:52 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -109,6 +109,7 @@
 (defvar hyrolo-hdr-regexp)
 (defvar hyrolo-match-regexp)
 (defvar hyrolo-mode-map)
+(defvar hyrolo-mode-prefix-map)
 (defvar hyrolo-mode-syntax-table)
 
 ;;; ************************************************************************
@@ -333,7 +334,10 @@ String search expressions are converted to regular 
expressions.")
   (setq hyrolo-mode-syntax-table (make-syntax-table text-mode-syntax-table)))
 
 (defvar hyrolo-mode-map nil
-  "Keymap for the hyrolo match buffer.")
+  "Keymap for the hyrolo display match buffer.")
+
+(defvar hyrolo-mode-prefix-map nil
+  "Keymap for hyrolo display match buffer bindings with a prefix, typically 
C-c.")
 
 ;;; ************************************************************************
 ;;; Commands
@@ -623,8 +627,11 @@ the logical sexpression matching."
 
 ;;;###autoload
 (defun hyrolo-find-file (&optional file find-function &rest args)
-  "Find an optional FILE in `hyrolo-file-list' with FIND-FUNCTION.
-Default to the first listed file when not given a prefix arg.
+  "Find an optional FILE with FIND-FUNCTION and rest of ARGS.
+When called interactively, select from the list of files referenced
+by `hyrolo-file-list' unless given a prefix argument, in which case
+use the first file generated by the list.
+
 FIND-FUNCTION must return the buffer of the file found but need not
 select it."
   (interactive "P")
@@ -657,11 +664,13 @@ select it."
 It uses the setting of `hyrolo-find-file-noselect-function'."
   (let (enable-local-variables)
     (if (string-match "\\.org$" file)
-       (let ((find-file-literally t))
-         (prog1 (hyrolo-find-file file hyrolo-find-file-noselect-function nil 
t)
-           ;; Disable all Org mode initializations that slow down
-           ;; file loading and simply set needed outline variables.
-           (hyrolo-org-mode)))
+       (let* ((find-file-literally t)
+              (org-buf (hyrolo-find-file file 
hyrolo-find-file-noselect-function nil t)))
+         ;; Disable all Org mode initializations that slow down
+         ;; file loading and simply set needed outline variables.
+         (with-current-buffer org-buf
+           (hyrolo-org-mode))
+         org-buf)
       (hyrolo-find-file file hyrolo-find-file-noselect-function))))
 
 ;; This wraps forward-visible-line, making its ARG optional, making
@@ -678,7 +687,7 @@ If ARG is zero, move to the beginning of the current line."
   (forward-visible-line arg))
 
 (defun hyrolo-get-file-list ()
-  "Return the current expanded list of hyrolo search files."
+  "Return the current expanded list of HyRolo search files."
   (if (equal hyrolo-file-list (symbol-value 'hyrolo-file-list))
       (or hyrolo--expanded-file-list hyrolo-file-list)
     ;; lexical-binding is enabled and there is a local binding of
@@ -687,7 +696,7 @@ If ARG is zero, move to the beginning of the current line."
 
 ;;;###autoload
 (defun hyrolo-grep (regexp &optional max-matches hyrolo-file-or-bufs 
count-only headline-only no-display)
-  "Display rolo entries matching REGEXP and return count of matches.
+  "Display HyRolo entries matching REGEXP and return count of matches.
 To a maximum of prefix arg MAX-MATCHES, in buffer(s) from
 optional HYROLO-FILE-OR-BUFS or `hyrolo-get-file-list'.  Default
 is to find all matching entries.  Each entry is displayed with
@@ -742,7 +751,6 @@ Return number of entries matched.  See also documentation 
for the variable
     (unless (or count-only (= total-matches 0))
       (hyrolo--cache-post-display-buffer)
       (unless (or no-display inserting)
-       (set-buffer display-buf)
        (hyrolo-display-matches display-buf)))
     (when (called-interactively-p 'interactive)
       (message "%s matching entr%s found in HyRolo."
@@ -954,8 +962,7 @@ Raise an error if a match is not found."
 ;;;###autoload
 (defun hyrolo-let-file-list (symbol value)
   (set symbol value)
-  (setq hyrolo--expanded-file-list (hyrolo-expand-path-list value))
-  (hyrolo--cache-initialize))
+  (setq hyrolo--expanded-file-list (hyrolo-expand-path-list value)))
 
 ;;;###autoload
 (defun hyrolo-set-file-list (symbol value)
@@ -963,7 +970,6 @@ Raise an error if a match is not found."
   (setq hyrolo--expanded-file-list (hyrolo-expand-path-list value))
   (unless (symbol-value symbol)
     (set-default symbol hyrolo--expanded-file-list))
-  (hyrolo--cache-initialize)
   ;; Prompt user to rename old personal rolo file to new name, if necessary.
   (unless (or noninteractive (hyperb:stack-frame '(hyrolo-rename)))
     (call-interactively 'hyrolo-rename)))
@@ -1598,10 +1604,10 @@ Return number of matching entries found."
   (setq hyrolo-match-regexp pattern)
   ;;
   (let ((new-buf-flag) (actual-buf)
-       ;; Disable magit-auto-revert-mode-enable-in-buffers for hyrolo
+       ;; Temporarily disable magit-auto-revert-mode-enable-in-buffers for 
hyrolo
        ;; buffers; not needed and can slow/hang file loading
        (after-change-major-mode-hook
-        (delq 'magit-auto-revert-mode-enable-in-buffers 
after-change-major-mode-hook)))
+        (remove 'magit-auto-revert-mode-enable-in-buffers 
after-change-major-mode-hook)))
     (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)
@@ -1828,7 +1834,7 @@ A heading line is one that starts with a `*' (or that
 
 ;;; In `hyrolo-mode' replace `outline-minor-mode' bindings with hyrolo-* 
overrides.
 ;;; Wrap outline movement commands with a `hyrolo-funcall-match' call
-;;; Wrap outline whole buffer commands with a `hyrolo-map-matches' call
+;;; Wrap outline whole buffer commands with a `hyrolo-map-matches' call.
 (defun hyrolo-outline-back-to-heading (&optional invisible-ok)
   "Move to previous heading line, or beg of this line if it's a heading.
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
@@ -2352,7 +2358,9 @@ a default of MM/DD/YYYY."
   "Return the minimum HyRolo level within a single file of matches."
   (save-excursion
     (goto-char (point-min))
-    (let ((min-level (funcall outline-level)))
+    (let ((min-level 1))
+      (when (looking-at outline-regexp)
+       (funcall outline-level))
       (while (outline-next-heading)
        (setq min-level (min min-level (funcall outline-level))))
       min-level)))
@@ -2454,33 +2462,34 @@ Return final point."
 
 (defun hyrolo-outline-level ()
   "Return the depth to which an entry is nested in the outline.
-Point must be at the beginning of a header line.
 This is actually either the level specified in `outline-heading-alist'
 or else the number of characters matched by `outline-regexp' minus
-trailing periods and whitespace."
-  (or (cdr (assoc (match-string 0) outline-heading-alist))
+trailing periods and whitespace.
+
+Point must be at the beginning of a heading line."
+  (or (cdr (assoc (match-string-no-properties 0) outline-heading-alist))
       (1- (- (match-end 0) (match-beginning 0)))))
 
 ;;; ************************************************************************
 ;;; Caching of buffer major-modes for use in HyRolo display match buffer
 ;;; ************************************************************************
 
-(defvar hyrolo--cache-loc-match-bounds '(1)
+(defvar-local hyrolo--cache-loc-match-bounds '(1)
   "Ordered list of the bounds of each matched buffer in Hyrolo display buffer.
 First entry represents the start of the first matched buffer and the
 remaining entries are the end points of each matched buffer with the
 HyRolo display matches buffer.")
 
-(defvar hyrolo--cache-major-mode-indexes '(0)
+(defvar-local hyrolo--cache-major-mode-indexes '(0)
   "Ordered list of major-mode-indexes `hyrolo--cache-loc-match-bounds' 
positions.")
 
-(defvar hyrolo--cache-major-mode-index 1
+(defvar-local hyrolo--cache-major-mode-index 1
   "Next index value to use when caching buffer-local values.")
 
-(defvar hyrolo--cache-major-mode-to-index-hasht nil
+(defvar-local hyrolo--cache-major-mode-to-index-hasht nil
   "Hash table with `major-mode' name keys and integer major-mode index 
values.")
 
-(defvar hyrolo--cache-index-to-major-mode-hasht nil
+(defvar-local hyrolo--cache-index-to-major-mode-hasht nil
   "Hash table with integer major-mode index keys and `major-mode' values.")
 
 (defun hyrolo-map-matches (func)
@@ -2493,8 +2502,7 @@ its source location."
   (let ((display-buf (get-buffer hyrolo-display-buffer)))
     (if (eq (current-buffer) display-buf)
        (progn
-         (when (or (< (length hyrolo--cache-loc-match-bounds) 1)
-                   (not (get-buffer hyrolo-display-buffer)))
+         (when (< (length hyrolo--cache-loc-match-bounds) 1)
            (error "(hryolo-map-matches): No HyRolo matches in display buffer"))
          (let ((bounds hyrolo--cache-loc-match-bounds)
                (ofont-lock font-lock-mode)
@@ -2534,14 +2542,12 @@ its source location."
   (let ((display-buf (get-buffer hyrolo-display-buffer)))
     (if (eq (current-buffer) display-buf)
        (progn
-         (when (or (< (length hyrolo--cache-loc-match-bounds) 1)
-                   (not (get-buffer hyrolo-display-buffer)))
+         (when (< (length hyrolo--cache-loc-match-bounds) 1)
            (error "(hryolo-funcall-match): No HyRolo matches in display 
buffer"))
          (let ((ofont-lock font-lock-mode)
                (omode major-mode))
            (unwind-protect
                (save-restriction
-                 (set-buffer display-buf)
                  (cl-destructuring-bind (start end)
                      (hyrolo-cache-location-start-and-end)
                    (when end
@@ -2573,11 +2579,13 @@ Both positions may be nil if there are no matches yet 
found."
       (list nil nil))))
 
 (defun hyrolo-cache-set-major-mode (pos)
-  "Set the `major-mode' for POS in the HyRolo display buffer.
+  "Set the `major-mode' for POS in the current HyRolo display buffer.
 Add `hyrolo-hdr-regexp' to `hyrolo-entry-regexp' and `outline-regexp'."
   (funcall
    (hyrolo--cache-get-major-mode-from-index
-    (nth (seq-position hyrolo--cache-loc-match-bounds pos (lambda (e pos) (< 
pos e)))
+    (nth (or (seq-position hyrolo--cache-loc-match-bounds pos (lambda (e pos) 
(< pos e)))
+            (error "(hyrolo-cache-set-major-mode): pos=%d > max display buffer 
pos=%d"
+                   pos (car hyrolo--cache-loc-match-bounds)))
         hyrolo--cache-major-mode-indexes)))
   (let ((source-prefix (if (boundp 'hbut:source-prefix) hbut:source-prefix 
"@loc> ")))
     (unless (or (string-prefix-p hyrolo-hdr-regexp hyrolo-entry-regexp)
@@ -2599,17 +2607,22 @@ Add `hyrolo-hdr-regexp' to `hyrolo-entry-regexp' and 
`outline-regexp'."
 
 (defun hyrolo--cache-initialize ()
   "Init cache hash table of (major-mode-name . loc-seq-number) key value pairs.
-Call whenever `hyrolo--expanded-file-list' is changed."
-  (setq hyrolo--cache-major-mode-to-index-hasht (if (hash-table-p 
hyrolo--cache-major-mode-to-index-hasht)
-                                                   (clrhash 
hyrolo--cache-major-mode-to-index-hasht)
-                                                 (make-hash-table))
-       hyrolo--cache-index-to-major-mode-hasht (if (hash-table-p 
hyrolo--cache-index-to-major-mode-hasht)
-                                                   (clrhash 
hyrolo--cache-index-to-major-mode-hasht)
-                                                 (make-hash-table))
-       ;; Don't use '(1) on the next line or the code will not initialize 
properly
-       hyrolo--cache-loc-match-bounds (list 1)
-       hyrolo--cache-major-mode-indexes (list 0)
-       hyrolo--cache-major-mode-index 1))
+Call whenever `hyrolo-display-buffer' is changed."
+  (with-current-buffer hyrolo-display-buffer
+    (setq-local hyrolo--cache-major-mode-to-index-hasht
+               (if (hash-table-p hyrolo--cache-major-mode-to-index-hasht)
+                   (clrhash hyrolo--cache-major-mode-to-index-hasht)
+                 (make-hash-table))
+
+               hyrolo--cache-index-to-major-mode-hasht
+               (if (hash-table-p hyrolo--cache-index-to-major-mode-hasht)
+                   (clrhash hyrolo--cache-index-to-major-mode-hasht)
+                 (make-hash-table))
+
+               ;; Don't use '(1) on the next line or the code will not 
initialize properly
+               hyrolo--cache-loc-match-bounds (list 1)
+               hyrolo--cache-major-mode-indexes (list 0)
+               hyrolo--cache-major-mode-index 1)))
 
 ;; TODO: !! Lookup hyrolo-entry-regexp like outline-regexp.
 
@@ -2620,20 +2633,23 @@ MATCHED-BUF must be a live buffer, not a buffer name.
 Push (point-max) of `hyrolo-display-buffer' onto 
`hyrolo--cache-loc-match-bounds'.
 Push hash table's index key to `hyrolo--cache-major-mode-indexes'.
 Ensure MATCHED-BUF's `major-mode' is stored in the hash table."
-  (push (with-current-buffer hyrolo-display-buffer (point-max))
-       hyrolo--cache-loc-match-bounds)
-  (push hyrolo--cache-major-mode-index hyrolo--cache-major-mode-indexes)
-  (with-current-buffer matched-buf
-    (unless (gethash (symbol-name major-mode) 
hyrolo--cache-major-mode-to-index-hasht)
-      (puthash (symbol-name major-mode) hyrolo--cache-major-mode-index 
hyrolo--cache-major-mode-to-index-hasht)
-      (puthash hyrolo--cache-major-mode-index major-mode 
hyrolo--cache-index-to-major-mode-hasht)))
-  (setq hyrolo--cache-major-mode-index (1+ hyrolo--cache-major-mode-index)))
+  (with-current-buffer hyrolo-display-buffer
+    (push (point-max) hyrolo--cache-loc-match-bounds)
+    (push hyrolo--cache-major-mode-index hyrolo--cache-major-mode-indexes)
+    (let ((matched-buf-major-mode-name (symbol-name (buffer-local-value 
'major-mode matched-buf))))
+
+      (unless (gethash matched-buf-major-mode-name 
hyrolo--cache-major-mode-to-index-hasht)
+       (puthash matched-buf-major-mode-name
+                hyrolo--cache-major-mode-index 
hyrolo--cache-major-mode-to-index-hasht)
+       (puthash hyrolo--cache-major-mode-index major-mode 
hyrolo--cache-index-to-major-mode-hasht)))
+    (setq-local hyrolo--cache-major-mode-index (1+ 
hyrolo--cache-major-mode-index))))
 
 (defun hyrolo--cache-post-display-buffer ()
   "Cache updates to make after display buffer modifications are finished."
   ;; Reverse both of the above lists to order them properly.
-  (setq hyrolo--cache-loc-match-bounds   (nreverse 
hyrolo--cache-loc-match-bounds)
-       hyrolo--cache-major-mode-indexes (nreverse 
hyrolo--cache-major-mode-indexes)))
+  (with-current-buffer hyrolo-display-buffer
+    (setq-local hyrolo--cache-loc-match-bounds   (nreverse 
hyrolo--cache-loc-match-bounds)
+               hyrolo--cache-major-mode-indexes (nreverse 
hyrolo--cache-major-mode-indexes))))
 
 ;;; ************************************************************************
 ;;; hyrolo-mode key bindings - set after all library functions have
@@ -2642,9 +2658,11 @@ Ensure MATCHED-BUF's `major-mode' is stored in the hash 
table."
 
 (if hyrolo-mode-map
     nil
-  (setq hyrolo-mode-map (make-sparse-keymap "HyRolo"))
-  (set-keymap-parent hyrolo-mode-map (copy-keymap outline-mode-prefix-map))
+  (setq hyrolo-mode-map (make-sparse-keymap "HyRolo")
+       hyrolo-mode-prefix-map (copy-keymap outline-mode-prefix-map))
   (suppress-keymap hyrolo-mode-map)
+
+  (define-key hyrolo-mode-map "\C-c"     hyrolo-mode-prefix-map)
   (define-key hyrolo-mode-map ","        'hyrolo-to-entry-beginning)
   (define-key hyrolo-mode-map "."        'hyrolo-to-entry-end)
   (define-key hyrolo-mode-map "<"        'beginning-of-buffer)
@@ -2671,6 +2689,7 @@ Ensure MATCHED-BUF's `major-mode' is stored in the hash 
table."
   (define-key hyrolo-mode-map "\M-\C-i"  'hyrolo-previous-match)  ;; {M-TAB}
   (define-key hyrolo-mode-map [backtab]  'hyrolo-previous-match)  ;; 
{Shift-TAB}
   (define-key hyrolo-mode-map "u"        'hyrolo-up-heading)
+
   (let (otl-cmd-name
        hyrolo-cmd-name
        hyrolo-cmd)
@@ -2678,9 +2697,9 @@ Ensure MATCHED-BUF's `major-mode' is stored in the hash 
table."
      (lambda (event otl-cmd)
        (when (and (event-basic-type event) ;; key or mouse event
                  (symbolp otl-cmd) (setq otl-cmd-name (symbol-name otl-cmd))
-                 (setq hyrolo-cmd-name (intern-soft (concat "hyrolo-" 
otl-cmd-name)))
-                 (setq hyrolo-cmd (intern-soft hyrolo-cmd-name)))
-        (define-key hyrolo-mode-map (vector 'remap otl-cmd) hyrolo-cmd)))
+                 (setq hyrolo-cmd-name (concat "hyrolo-" otl-cmd-name)
+                       hyrolo-cmd (intern-soft hyrolo-cmd-name)))
+        (substitute-key-definition otl-cmd hyrolo-cmd hyrolo-mode-map)))
      outline-mode-prefix-map)))
 
 (provide 'hyrolo)
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index cf125e6e28..04f8c90f5f 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:      1-Dec-23 at 23:20:39 by Mats Lidell
+;; Last-Mod:     13-Dec-23 at 00:53:18 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -124,8 +124,7 @@
     (hyrolo-demo-quit)))
 
 (ert-deftest hyrolo-demo-move-to-beginning-and-end-of-file ()
-  "*HyRolo* keys {<} and {>} move to beginning and end of file, respectively.
-{,} and {.} move to beginning and end of current entry, respectively."
+  "*HyRolo* keys {<} and {>} move to begin and end of file, respectively."
   (skip-unless (not noninteractive))
   (unwind-protect
       (progn
@@ -139,7 +138,18 @@
         (should (equal (point) (point-min)))
 
         (should (hact 'kbd-key ">"))
-        (should (equal (point) (point-max)))
+        (should (equal (point) (point-max))))
+    (hyrolo-demo-quit)))
+
+(ert-deftest hyrolo-demo-move-to-beginning-and-end-of-entry ()
+  "*HyRolo* keys {,} and {.} move to begin and end of an entry, respectively."
+  (skip-unless (not noninteractive))
+  (unwind-protect
+      (progn
+        (load "../hyrolo-demo")
+        (should (hact 'kbd-key "C-x 4r work RET TAB"))
+        (hy-test-helpers:consume-input-events)
+        (should (string= (buffer-name) hyrolo-display-buffer))
 
         (should (hact 'kbd-key "\C-u,n"))
         (hy-test-helpers:consume-input-events)



reply via email to

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