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

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

[elpa] externals/hyperbole 84fe259016 064/143: hyrolo.el - Fix *HyRolo*


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 84fe259016 064/143: hyrolo.el - Fix *HyRolo* {n} and {p} movement commands
Date: Mon, 19 Feb 2024 15:59:00 -0500 (EST)

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

    hyrolo.el - Fix *HyRolo* {n} and {p} movement commands
    
    Add backtrace to `hyrolo-file-list' error buffer when within a 'let'.
---
 ChangeLog            |  8 ++++++
 hyrolo.el            | 79 +++++++++++++++++++++++++++++++---------------------
 test/hyrolo-tests.el | 22 ++++++---------
 3 files changed, 65 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 82e0c02ec3..1f4c750361 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
+* hyrolo.el (hyrolo-any-file-type-problem-p): If problem occurs within a 'let',
+    then show backtrace so know where the let-binding was set.
+
 2024-01-04  Bob Weiner  <rsw@gnu.org>
 
 * hyrolo.el (hyrolo-org-mode): Force font-lock-mode off in this major mode for 
speed.
+            (hyrolo-funcall-match): Add optional arg 'backward-flag' to select
+    proper major mode for a *HyRolo* match file when moving backwards.
+  test/hyrolo-tests.el (hyrolo-tests--outline-next-visible-heading,
+                        
hyrolo-tests--outline-next-visible-heading-two-sections):
+    Fix tests to work with fixed {n} and {p} commands.
 
 * hui-mouse.el (hsys-flymake): Move loading of this library here from 
"hibtypes.el".
   hsys-flymake.el (hsys-flymake-issue-at-point, 
hsys-flymake-issue-at-point:help):
diff --git a/hyrolo.el b/hyrolo.el
index 37d78dd560..26edea9cd6 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:      4-Jan-24 at 22:51:55 by Bob Weiner
+;; Last-Mod:      5-Jan-24 at 01:29:50 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -2074,7 +2074,8 @@ A match buffer header is one that starts with 
`hyrolo-hdr-regexp'."
                                  (setq found-heading-p
                                        (re-search-backward
                                         (concat "^\\(?:" outline-regexp "\\)")
-                                        nil 'move)))))
+                                        nil 'move)))
+                               nil t))
                        (progn (hyrolo-hdr-to-first-line-p)
                               (outline-invisible-p))))
            (setq arg (1+ arg)))
@@ -2427,7 +2428,15 @@ package is not installed."
                files-no-mode-list)
          (terpri)
          (princ "Please add appropriate entries for the above files to 
`auto-mode-alist'.\n")
-         (terpri)))
+         (terpri))
+
+       (when (hyperb:stack-frame '(hyrolo-file-list-changed))
+         ;; Errors occurred with a let of `hyrolo-file-list' so
+         ;; include backtrace of where this occurred.
+         (princ "Stack trace of where invalid files were referenced:\n")
+         (terpri)
+          ;; (setq backtrace-view (plist-put backtrace-view :show-locals t))
+         (backtrace)))
       t)))
 
 (defun hyrolo-buffer-exists-p (hyrolo-buf)
@@ -2846,14 +2855,18 @@ prior to applying FUNC."
       (save-excursion
        (funcall func)))))
 
-(defun hyrolo-funcall-match (func &optional narrow-flag)
+(defun hyrolo-funcall-match (func &optional narrow-flag backward-flag)
   "Apply FUNC with no arguments to the entry at point.
 If on a display match entry or file header, set the appropriate
 major mode based on its source location prior to applying FUNC.
 
 With point in the HyRolo display matches buffer and optional
 NARROW-FLAG non-nil, narrow to the current file of matches
-prior to applying FUNC."
+prior to applying FUNC.
+
+With optional BACKWARD-FLAG, FUNC is moving point backwards; when
+on a file boundary, move point back a character to select the
+proper major mode."
   (let ((display-buf (get-buffer hyrolo-display-buffer)))
     (if (eq (current-buffer) display-buf)
        (progn
@@ -2870,7 +2883,11 @@ prior to applying FUNC."
                  (when narrow-flag
                    (narrow-to-region start end))
                  (let ((font-lock-mode))
-                   (hyrolo-cache-set-major-mode (1+ start))
+                   ;; (message "%s" (hyrolo-cache-get-major-mode-from-pos
+                   ;;             (funcall (if backward-flag '1- '1+) start)))
+                   (if (and backward-flag (looking-at hyrolo-hdr-regexp))
+                       (hyrolo-cache-set-major-mode (1- start))
+                     (hyrolo-cache-set-major-mode (1+ start)))
                    ;; Prevent Org and Outline minor modes from font-locking
                    (setq font-lock-mode nil)
                    (funcall func)))
@@ -2887,7 +2904,7 @@ prior to applying FUNC."
                  (orgtbl-mode 0))
                ;; This pause forces a window redisplay that maximizes the
                ;; entries displayed for any final location of point.
-               (sit-for 0.001)
+               (sit-for 0.0001)
                ;; Need to leave point on a visible character or since
                ;; hyrolo uses reveal-mode, redisplay will rexpand
                ;; hidden entries to make point visible.
@@ -3052,30 +3069,30 @@ Add `hyrolo-hdr-regexp' to 
`hyrolo-hdr-and-entry-regexp' and `outline-regexp'."
   ;; FIXME: do we actually know that (current-buffer) = (window-buffer) ?
   (with-local-quit
     (with-demoted-errors "Reveal: %s"
-      (let ((old-ols
-             (delq nil
-                   (mapcar
-                    (lambda (x)
-                      ;; We refresh any spot in the current window as well
-                      ;; as any spots associated with a dead window or
-                      ;; a window which does not show this buffer any more.
-                      (cond
-                       ((eq (car x) (selected-window)) (cdr x))
-                       ((not (and (window-live-p (car x))
-                                  (eq (window-buffer (car x))
-                                      (current-buffer))))
-                        ;; Adopt this since it's owned by a window that's
-                        ;; either not live or at least not showing this
-                        ;; buffer any more.
-                        (setcar x (selected-window))
-                        (cdr x))))
-                    reveal-open-spots))))
-       (hyrolo-funcall-match
-        (lambda ()
-           (setq old-ols (reveal-open-new-overlays old-ols))
-           (when reveal-auto-hide
-             (reveal-close-old-overlays old-ols)))
-        t)))))
+        (let ((old-ols
+               (delq nil
+                      (mapcar
+                       (lambda (x)
+                        ;; We refresh any spot in the current window as well
+                        ;; as any spots associated with a dead window or
+                        ;; a window which does not show this buffer any more.
+                        (cond
+                         ((eq (car x) (selected-window)) (cdr x))
+                         ((not (and (window-live-p (car x))
+                                     (eq (window-buffer (car x))
+                                        (current-buffer))))
+                           ;; Adopt this since it's owned by a window that's
+                           ;; either not live or at least not showing this
+                           ;; buffer any more.
+                           (setcar x (selected-window))
+                           (cdr x))))
+                       reveal-open-spots))))
+          (hyrolo-funcall-match
+           (lambda ()
+              (setq old-ols (reveal-open-new-overlays old-ols))
+              (when reveal-auto-hide
+               (reveal-close-old-overlays old-ols)))
+           t)))))
 
 ;;; ************************************************************************
 ;;; hyrolo-file-list - initialize cache if this is already set when loading
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index f35e9405ad..5a4879627b 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:      4-Jan-24 at 13:19:35 by Bob Weiner
+;; Last-Mod:      5-Jan-24 at 01:51:50 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -460,7 +460,7 @@ Match a string in the second cell."
           (should (string= (car hl) tmp-file)))
       (hy-delete-file-and-buffer tmp-file))))
 
-(ert-deftest hyrolo-tests--get-file-list-wrong-suffice ()
+(ert-deftest hyrolo-tests--get-file-list-wrong-suffix ()
   "Verify files need to have the proper suffix in hyrolo-file-list."
   (let ((tmp-file (make-temp-file "hypb" nil)))
     (unwind-protect
@@ -557,14 +557,8 @@ Example:
           (should (hact 'kbd-key "p"))
           (should (looking-at-p "^\\* heading 1"))
           (should (hact 'kbd-key "p"))
-
-          ;; BUG: This fails in Emacs 29 and 30
-          ;; This is the expected behavior that works in Emacs 27 and 28.
-          ;; (should (looking-at-p "==="))
-          ;; (should (bobp))
-          ;; This is what we get
-          (should (looking-at-p "@loc>"))
-          (should (= 2 (line-number-at-pos))))
+          (should (looking-at-p "==="))
+          (should (bobp)))
       (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
@@ -608,7 +602,8 @@ Example:
           (should (looking-at-p "^\\* heading-a 1$"))
           (should (hact 'kbd-key "n"))
           (should (looking-at-p "^\\*\\* heading-a 1\\.2$"))
-          (should (hact 'kbd-key "nn"))
+          (should (hact 'kbd-key "n"))
+          (should (hact 'kbd-key "n"))
           (should (looking-at-p "^# heading-b 1$"))
           (should (hact 'kbd-key "n"))
           (should (looking-at-p "^## heading-b 1\\.2$"))
@@ -620,7 +615,8 @@ Example:
           (should (looking-at-p "^## heading-b 1\\.2$"))
           (should (hact 'kbd-key "p"))
           (should (looking-at-p "^# heading-b 1$"))
-          (should (hact 'kbd-key "pp"))
+          (should (hact 'kbd-key "p"))
+          (should (hact 'kbd-key "p"))
           (should (looking-at-p "^\\*\\* heading-a 1\\.2$"))
           (should (hact 'kbd-key "p"))
           (should (looking-at-p "^\\* heading-a 1$"))
@@ -654,7 +650,7 @@ Example:
           (should (looking-at-p "^* heading 1$"))
           ;; BUG: This gives an unexpected error when trying to hide
           ;; org-fold-region: Calling ‘org-fold-core-region’ with missing SPEC
-          (should-error (hact 'kbd-key "h"))
+          (should (hact 'kbd-key "h"))
           ;; Expected is not to fail on hiding the heading.
           ;; Seems to be version dependent for 29 and 30!?
 



reply via email to

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