diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | elisp/geiser-edit.el | 6 | ||||
-rw-r--r-- | elisp/geiser-racket.el | 50 |
3 files changed, 39 insertions, 21 deletions
@@ -2,8 +2,8 @@ New features: - - Racket: new commands geiser-racket-{show, hide, toggle}-tests, - for hiding test modules in code buffers. + - Racket: new commands geiser-racket-{show, hide, toggle}-submodules, + for folding submodule forms in code buffers. - Racket: interaction with submodules (entering them and evaluation within their scope). - New commands geiser-eval-buffer (C-c C-b) and diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el index f75e303..d43cf9b 100644 --- a/elisp/geiser-edit.el +++ b/elisp/geiser-edit.el @@ -191,7 +191,7 @@ or following links in error buffers.") (let ((cloak (geiser-edit--cloak form))) (save-excursion (goto-char (point-min)) - (while (re-search-forward (format "(%s\\b" (regexp-quote form)) nil t) + (while (re-search-forward (format "(%s\\b" form) nil t) (let* ((beg (match-beginning 0)) (end (progn (ignore-errors (goto-char beg) (forward-sexp)) (point)))) @@ -204,6 +204,10 @@ or following links in error buffers.") (remove-overlays nil nil 'invisible cloak) (remove-from-invisibility-spec (cons cloak t)))) +(defun geiser-edit--show-all () + (remove-overlays) + (setq buffer-invisibility-spec '(t))) + (defun geiser-edit--toggle-visibility (form) (if (and (listp buffer-invisibility-spec) (assoc (geiser-edit--cloak form) buffer-invisibility-spec)) diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el index 9e00c4d..435fb39 100644 --- a/elisp/geiser-racket.el +++ b/elisp/geiser-racket.el @@ -373,24 +373,38 @@ using start-geiser, a procedure in the geiser/server module." ;;; Additional commands -(defconst geiser-racket--test-module "module+ test") - -(defun geiser-racket-toggle-tests () - "Toggle visibility of test module fragments of the form (module+ test). - -When hidden, the test module forms are shown as an ellipsis." - (interactive) - (geiser-edit--toggle-visibility geiser-racket--test-module)) - -(defun geiser-racket-show-tests () - "Unconditionally shows all test modules." - (interactive) - (geiser-edit--show geiser-racket--test-module)) - -(defun geiser-racket-hide-tests () - "Unconditionally hides all visible test modules." - (interactive) - (geiser-edit--hide geiser-racket--test-module)) +(defvar geiser-racket--submodule-history ()) + +(defun geiser-racket--submodule-form (name) + (format "module[+*]? %s" + (cond ((eq 1 name) "") + ((numberp name) + (read-string "Submodule name: " nil + 'geiser-racket--submodule-history)) + ((stringp name) name) + t ""))) + +(defun geiser-racket-toggle-submodules (&optional name) + "Toggle visibility of submodule forms. + +Use a prefix to be asked for a submodule name." + (interactive "p") + (geiser-edit--toggle-visibility (geiser-racket--submodule-form name))) + +(defun geiser-racket-show-submodules (&optional name) + "Unconditionally shows all submodule forms. + +Use a prefix to be asked for a submodule name." + (interactive "p") + (cond ((eq 1 name) (geiser-edit--show-all)) + (t (geiser-edit--show (geiser-racket--submodule-form name))))) + +(defun geiser-racket-hide-submodules (&optional name) + "Unconditionally hides all visible submodules. + +Use a prefix to be asked for a submodule name." + (interactive "p") + (geiser-edit--hide (geiser-racket--submodule-form name))) ;;; Implementation definition: |