summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-25 07:12:07 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-25 07:12:07 +0200
commit3a1dbf4e37f44e853cb649805a1f8777d0ba7501 (patch)
tree9bc66cfe6a9efd1040fa3793a004d7fc610d81fe
parent79d3a9a2f332f71711734ee5dd1b7fb2c45ca797 (diff)
downloadgeiser-guile-3a1dbf4e37f44e853cb649805a1f8777d0ba7501.tar.gz
geiser-guile-3a1dbf4e37f44e853cb649805a1f8777d0ba7501.tar.bz2
Let's make it *any* submodule
So the new functions are named geiser-racket-*-submodules, and by default all submodule forms are hidden. Now that we have the helpers in geiser-edit, we could have a generic command in geiser-mode to change the visibility of form at point.
-rw-r--r--NEWS4
-rw-r--r--elisp/geiser-edit.el6
-rw-r--r--elisp/geiser-racket.el50
3 files changed, 39 insertions, 21 deletions
diff --git a/NEWS b/NEWS
index 5f3b250..b3770fe 100644
--- a/NEWS
+++ b/NEWS
@@ -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: