summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-25 06:22:05 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-25 06:22:05 +0200
commitf417431b8b72fbc6e98c1310b99cba50882b13d2 (patch)
treead1566cfeabc31a8135dcfc3fecb3c7651519a98 /elisp
parent600ef3a419f61c738f0e054bad4c02925cb964f0 (diff)
downloadgeiser-f417431b8b72fbc6e98c1310b99cba50882b13d2.tar.gz
geiser-f417431b8b72fbc6e98c1310b99cba50882b13d2.tar.bz2
Racket: new commands to show and hide test submodules
The new commands, being racket-specific, are called geiser-racket-{show,hide,toggle}-tests, and have no default binding in geiser-mode (since they don't have any meaning in Guile). The implementation is based on more generic functions in geiser-edit that allow hiding of any top-level form, given its name, so we will probably find new forms to hide in the future. Hiding is limited to top-level forms, which i think is fine for the only use case we have in mind right now.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-edit.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el
index 5d5cd1b..f75e303 100644
--- a/elisp/geiser-edit.el
+++ b/elisp/geiser-edit.el
@@ -181,6 +181,34 @@ or following links in error buffers.")
(goto-char p)
(error "No %s error" msg))))
+
+;;; Visibility
+(defun geiser-edit--cloak (form)
+ (intern (format "geiser-edit-cloak-%s" form)))
+
+(defun geiser-edit--hide (form)
+ (geiser-edit--show form)
+ (let ((cloak (geiser-edit--cloak form)))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward (format "(%s\\b" (regexp-quote form)) nil t)
+ (let* ((beg (match-beginning 0))
+ (end (progn (ignore-errors (goto-char beg) (forward-sexp))
+ (point))))
+ (when (> end beg)
+ (overlay-put (make-overlay beg end) 'invisible cloak)))))
+ (add-to-invisibility-spec (cons cloak t))))
+
+(defun geiser-edit--show (form)
+ (let ((cloak (geiser-edit--cloak form)))
+ (remove-overlays nil nil 'invisible cloak)
+ (remove-from-invisibility-spec (cons cloak t))))
+
+(defun geiser-edit--toggle-visibility (form)
+ (if (and (listp buffer-invisibility-spec)
+ (assoc (geiser-edit--cloak form) buffer-invisibility-spec))
+ (geiser-edit--show form)
+ (geiser-edit--hide form)))
;;; Commands: