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 | e2910bf4f12e15dfa89ba3870d95389672dc5825 (patch) | |
tree | f4dcdf262338c286b9422d0ab68e6a60c7b61fba | |
parent | 645e4775420c59bb10ef0693ed2631a8df8c0e29 (diff) | |
download | geiser-guile-e2910bf4f12e15dfa89ba3870d95389672dc5825.tar.gz geiser-guile-e2910bf4f12e15dfa89ba3870d95389672dc5825.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.
-rw-r--r-- | README.org | 7 | ||||
-rw-r--r-- | doc/cheat.texi | 6 | ||||
-rw-r--r-- | elisp/geiser-edit.el | 41 | ||||
-rw-r--r-- | elisp/geiser-mode.el | 40 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 6 |
5 files changed, 57 insertions, 43 deletions
@@ -79,7 +79,7 @@ ** Gambit Addendum These steps are necessary to fully support Gambit Scheme. - + 1 - clone the last version of gambit 2 - configure gambit using --enable-rtlib-debug-source to activate autodoc #+BEGIN_EXAMPLE @@ -145,6 +145,7 @@ | C-c C-e m | Ask for a module and open its file | | C-c C-e C-l | Add a given directory to Scheme's load path | | C-c C-e [ | Toggle between () and [] for current form | + | c-c C-e \ | Insert λ | | | | |-------------+--------------------------------------------------| | C-M-x | Eval definition around point | @@ -200,6 +201,10 @@ | M-p, M-n | Prompt history, matching current prefix | | | | |-------------+----------------------------------------------------| + | C-c \ | Insert λ | + | C-c [ | Toggle between () and [] for current form | + | | | + |-------------+----------------------------------------------------| | C-c C-m | Set current module | | C-c C-i | Import module into current namespace | | C-c C-r | Add a given directory to scheme's load path | diff --git a/doc/cheat.texi b/doc/cheat.texi index cbfe08d..f1ef04f 100644 --- a/doc/cheat.texi +++ b/doc/cheat.texi @@ -163,6 +163,12 @@ third key not modified by @key{Control}; e.g., @item M-`, C-. @tab @code{geiser-completion--complete-module} @tab Complete module name at point +@item C-c [, C-c C-[ +@tab @code{geiser-squarify} +@tab Toggle between () and [] for current form +@item C-c \, C-c C-\ +@tab @code{geiser-insert-lambda} +@tab Insert greek lambda or, with prefix, a lambda form @item C-c C-r @tab @code{geiser-add-to-load-path} @tab Ask for a directory and add to Scheme load path 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))) |