summaryrefslogtreecommitdiff
path: root/elisp/geiser-mode.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-09 21:52:56 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-09 21:52:56 +0100
commitfb5f7a2a797183e5b2350ae76ea8ca09689f4a12 (patch)
treedb177f6a69f8682141ddbb22aa6988f23bd66f8b /elisp/geiser-mode.el
parent70b6d7a95f3c4e706b72568e2a29de2391fe09e2 (diff)
parenta7ad5704722b7fab966ac8fb4e6b62fe2e424756 (diff)
downloadgeiser-fb5f7a2a797183e5b2350ae76ea8ca09689f4a12.tar.gz
geiser-fb5f7a2a797183e5b2350ae76ea8ca09689f4a12.tar.bz2
Merge branch 'master' into guile-meta
Conflicts: elisp/geiser-guile.el
Diffstat (limited to 'elisp/geiser-mode.el')
-rw-r--r--elisp/geiser-mode.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index e9e5563..719176d 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -176,6 +176,35 @@ With prefix, try to enter the current's buffer module."
(goto-char (point-max))
(pop-to-buffer b)))
+(defun geiser-squarify (n)
+ "Toggle between () and [] for current form.
+With numeric prefix, perform that many toggles, forward for
+positive values and backward for negative."
+ (interactive "p")
+ (let ((pared (and (boundp 'paredit-mode) paredit-mode))
+ (fwd (> n 0))
+ (steps (abs n)))
+ (when (and pared (fboundp 'paredit-mode)) (paredit-mode -1))
+ (unwind-protect
+ (save-excursion
+ (unless (looking-at-p "\\s(") (backward-up-list))
+ (while (> steps 0)
+ (let ((p (point))
+ (round (looking-at-p "(")))
+ (forward-sexp)
+ (backward-delete-char 1)
+ (insert (if round "]" ")"))
+ (goto-char p)
+ (delete-char 1)
+ (insert (if round "[" "("))
+ (setq steps (1- steps))
+ (backward-char)
+ (condition-case nil
+ (progn (when fwd (forward-sexp 2))
+ (backward-sexp))
+ (error (setq steps 0))))))
+ (when (and pared (fboundp 'paredit-mode)) (paredit-mode 1)))))
+
;;; Geiser mode:
@@ -258,6 +287,7 @@ interacting with the Geiser REPL is at your disposal.
("Complete module name" ((kbd "M-`") (kbd "C-."))
geiser-completion--complete-module)
("Edit module" ("\C-c\C-e\C-m" "\C-c\C-em") geiser-edit-module)
+ ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify)
--
("Callers" ((kbd "C-c <")) geiser-xref-callers
:enable (and (geiser-eval--supported-p 'callers) (symbol-at-point)))