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

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

[nongnu] elpa/racket-mode b7e4d62672 4/4: racket-{fold unfold}-tests: La


From: ELPA Syncer
Subject: [nongnu] elpa/racket-mode b7e4d62672 4/4: racket-{fold unfold}-tests: Lazy load hs-minor-mode
Date: Sat, 18 Nov 2023 16:00:02 -0500 (EST)

branch: elpa/racket-mode
commit b7e4d62672a8df3495f6125fdf34b5e3b972d36a
Author: Greg Hendershott <git@greghendershott.com>
Commit: Greg Hendershott <git@greghendershott.com>

    racket-{fold unfold}-tests: Lazy load hs-minor-mode
    
    No longer eagerly enable hs-minor-mode in racket-mode -- just on first
    use of racket-{fold unfold}-tests.
    
    Allow racket-{fold unfold}-tests to work from racket-hash-lang-mode
    when sexp lang, as well as racket-mode.
---
 racket-edit.el | 19 ++++++++++---------
 racket-mode.el |  1 -
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/racket-edit.el b/racket-edit.el
index dd82ac33a8..29b92477f3 100644
--- a/racket-edit.el
+++ b/racket-edit.el
@@ -22,9 +22,9 @@
 (require 'hideshow)
 (require 'xref)
 
-;;; code folding
+;;; Show/hide test submodules
 
-(defun racket--for-all-tests (verb f)
+(defun racket--fold-tests (fold-p)
   ;; For this to work in `racket-hash-lang-mode' for all hash-langs,
   ;; (a) we'd need to learn the test submodule spans from analysis of
   ;; fully-expanded code (as we can do on the `pdb` branch with a
@@ -34,27 +34,28 @@
   ;; regexp flavor, which AFAIK we'd need to implement ourselves.
   ;;
   ;; TL;DR: For now require `racket-sexp-edit-mode'.
-  (racket--assert-sexp-edit-mode)
-  (unless (bound-and-true-p hs-minor-mode)
-    (user-error "hs-minor-mode is not enabled"))
+  (unless hs-minor-mode
+    (hs-minor-mode))
   (save-excursion
     (goto-char (point-min))
     (let ((n 0))
       (while (re-search-forward "^(module[+*]? test" (point-max) t)
-        (funcall f)
+        (if fold-p (hs-hide-block) (hs-show-block))
         (cl-incf n)
         (goto-char (match-end 0)))
-      (message "%s %d test submodules" verb n))))
+      (message "%s %d test submodules" (if fold-p "Folded" "Unfolded") n))))
 
 (defun racket-fold-all-tests ()
   "Fold (hide) all test submodules."
   (interactive)
-  (racket--for-all-tests "Folded" #'hs-hide-block))
+  (racket--assert-sexp-edit-mode)
+  (racket--fold-tests t))
 
 (defun racket-unfold-all-tests ()
   "Unfold (show) all test submodules."
   (interactive)
-  (racket--for-all-tests "Unfolded" #'hs-show-block))
+  (racket--assert-sexp-edit-mode)
+  (racket--fold-tests nil))
 
 ;;; requires
 
diff --git a/racket-mode.el b/racket-mode.el
index e594d18192..05ec57c034 100644
--- a/racket-mode.el
+++ b/racket-mode.el
@@ -178,7 +178,6 @@
   ;; Code folding
   (add-to-list 'hs-special-modes-alist
                '(racket-mode "(" ")" ";" nil nil))
-  (hs-minor-mode 1)
   ;; -----------------------------------------------------------------
   ;;; Misc
   (setq-local local-abbrev-table racket-mode-abbrev-table)



reply via email to

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