diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2020-01-28 02:50:24 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2020-01-28 02:50:24 +0000 |
commit | 63ff73d1f5ec572bbd73b6c37d3f8ba83dc085f8 (patch) | |
tree | 2355fc01c819a466f54a6284a6a14c5367675686 /elisp | |
parent | 1ad752e4b4735e65c30acfc5fed8c663fa93181d (diff) | |
download | geiser-63ff73d1f5ec572bbd73b6c37d3f8ba83dc085f8.tar.gz geiser-63ff73d1f5ec572bbd73b6c37d3f8ba83dc085f8.tar.bz2 |
C-c \ and C-c [ in geiser-repl too
With a hat tip to Mikhail Kryshen, who was wondering in guile-user why
oh why, and rightly so.
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-edit.el | 41 | ||||
-rw-r--r-- | elisp/geiser-mode.el | 40 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 6 |
3 files changed, 45 insertions, 42 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el index c374c92..bca57a3 100644 --- a/elisp/geiser-edit.el +++ b/elisp/geiser-edit.el @@ -1,6 +1,6 @@ ;;; geiser-edit.el -- scheme edit locations -;; Copyright (C) 2009, 2010, 2012, 2013, 2019 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2012, 2013, 2019, 2020 Jose Antonio Ortega Ruiz ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the Modified BSD License. You should @@ -259,7 +259,6 @@ With prefix, asks for the symbol to edit." (let ((cmd `(:eval (:ge module-location '(:module ,module))))) (geiser-edit--try-edit module (geiser-eval--send/wait cmd) method))) - (defun geiser-edit-module-at-point () "Opens a new window visiting the module at point." (interactive) @@ -268,6 +267,44 @@ With prefix, asks for the symbol to edit." (geiser-completion--read-module))) (when marker (xref-push-marker-stack)))) +(defun geiser-insert-lambda (&optional full) + "Insert λ at point. With prefix, inserts (λ ())." + (interactive "P") + (if (not full) + (insert (make-char 'greek-iso8859-7 107)) + (insert "(" (make-char 'greek-iso8859-7 107) " ())") + (backward-char 2))) + +(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))))) + (provide 'geiser-edit) diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el index 9a28b02..c8d28ad 100644 --- a/elisp/geiser-mode.el +++ b/elisp/geiser-mode.el @@ -1,6 +1,6 @@ ;; geiser-mode.el -- minor mode for scheme buffers -;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020 Jose Antonio Ortega Ruiz ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the Modified BSD License. You should @@ -272,44 +272,6 @@ With prefix, try to enter the current buffer's 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))))) - -(defun geiser-insert-lambda (&optional full) - "Insert λ at point. With prefix, inserts (λ ())." - (interactive "P") - (if (not full) - (insert (make-char 'greek-iso8859-7 107)) - (insert "(" (make-char 'greek-iso8859-7 107) " ())") - (backward-char 2))) - ;;; Geiser mode: diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 9f400a3..18da072 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -1,6 +1,6 @@ ;;; geiser-repl.el --- Geiser's REPL -;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2018, 2019 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2018, 2019, 2020 Jose Antonio Ortega Ruiz ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the Modified BSD License. You should @@ -824,6 +824,7 @@ buffer." (define-key geiser-repl-mode-map "\C-a" 'geiser-repl--bol) (define-key geiser-repl-mode-map (kbd "<home>") 'geiser-repl--bol) +(define-key geiser-repl-mode-map "\C-c" 'geiser-repl--bol) (geiser-menu--defmenu repl geiser-repl-mode-map ("Complete symbol" ((kbd "M-TAB")) @@ -862,6 +863,9 @@ buffer." -- ("Clear buffer" "\C-c\M-o" geiser-repl-clear-buffer "Clean up REPL buffer, leaving just a lonely prompt") + ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify) + ("Insert λ" ("\C-c\\" "\C-c\C-\\") geiser-insert-lambda) + -- ("Kill Scheme interpreter" "\C-c\C-q" geiser-repl-exit :enable (geiser-repl--live-p)) ("Restart" "\C-c\C-z" switch-to-geiser :enable (not (geiser-repl--live-p))) |