aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trident-mode.el107
1 files changed, 41 insertions, 66 deletions
diff --git a/trident-mode.el b/trident-mode.el
index ff915f8..d2da9c4 100644
--- a/trident-mode.el
+++ b/trident-mode.el
@@ -6,12 +6,12 @@
;; URL: https://github.com/johnmastro/trident-mode.el
;; Version: 0.9.1
;; Keywords: languages, lisp, processes, tools
-;; Package-Requires: ((emacs "24") (slime "20130526") (skewer-mode "1.5.0") (dash "1.0.3"))
+;; Package-Requires: ((emacs "25.1") (sly "1.0.43") (skewer-mode "1.8.0") (dash "2.19.1"))
;;; Commentary:
;; This is an Emacs minor mode and collection of commands for working with
-;; Parenscript code in SLIME and sending it to the browser via Skewer. The goal
+;; Parenscript code in SLY and sending it to the browser via Skewer. The goal
;; is to create an environment for hacking Parenscript which fits as naturally
;; as possible into the Lisp style of interactive development.
@@ -29,7 +29,7 @@
;; (package-initialize)
;; The dependencies that will be installed are:
-;; - SLIME
+;; - SLY
;; - Skewer
;; - dash.el
@@ -38,9 +38,9 @@
;; ** Setup
-;; To enable trident-mode in a SLIME buffer: M-x trident-mode.
+;; To enable trident-mode in a SLY buffer: M-x trident-mode.
-;; To have lisp-mode, slime-mode, and trident-mode all enable automatically for
+;; To have lisp-mode, sly-mode, and trident-mode all enable automatically for
;; any file with an extension of ".paren":
;; (add-to-list 'auto-mode-alist (cons "\\.paren\\'" 'lisp-mode))
@@ -48,8 +48,8 @@
;; #'(lambda ()
;; (when (and buffer-file-name
;; (string-match-p "\\.paren\\>" buffer-file-name))
-;; (unless (slime-connected-p)
-;; (save-excursion (slime)))
+;; (unless (sly-connected-p)
+;; (save-excursion (sly)))
;; (trident-mode +1))))
;; Parenscript must be loaded in your Common Lisp image, and you'll probably
@@ -105,7 +105,7 @@
;; ** Key bindings
;; The traditional set of code evaluation key bindings is a poor fit for
-;; Trident,since they would shadow SLIME's equivalent commands and that's
+;; Trident,since they would shadow SLY's equivalent commands and that's
;; probably not what you want. That leaves us without a clear convention to
;; follow, so by default we don't establish any key bindings at all. However,
;; the function trident-add-keys-with-prefix will add two-key key bindings for
@@ -132,19 +132,19 @@
;; Evaluation commands begin with an "e", expansion commands with "x". The
;; second letter is generally mnemonic but not always. The -sexp commands use
-;; RET in correspondence to slime-expand-1, and the -dwim commands use the
+;; RET in correspondence to sly-expand-1, and the -dwim commands use the
;; space bar because it's easy and comfortable to hit.
;; Please consider these keys provisional, and let me know if you have any
;; ideas for improving the arrangement.
-;; If you really want to shadow SLIME's key bindings in buffers where
+;; If you really want to shadow SLY's key bindings in buffers where
;; trident-mode is active you could do something like this:
-;; (defun steal-slime-keys-for-trident! ()
-;; ;; Don't affect all SLIME buffers, just where invoked
-;; (make-local-variable 'slime-mode-map)
-;; (let ((map slime-mode-map))
+;; (defun steal-sly-keys-for-trident! ()
+;; ;; Don't affect all SLY buffers, just where invoked
+;; (make-local-variable 'sly-mode-map)
+;; (let ((map sly-mode-map))
;; (define-key map (kbd "C-x C-e") nil)
;; (define-key map (kbd "C-c C-r") nil)
;; (define-key map (kbd "C-M-x") nil)
@@ -157,26 +157,14 @@
;; (define-key map (kbd "C-c C-k") 'trident-eval-buffer)
;; (define-key map (kbd "C-c C-m") 'trident-expand-sexp)))
;;
-;; (add-hook 'trident-mode-hook 'steal-slime-keys-for-trident!)
-
-;; ** Other amenities
-
-;; slime-selector is a great feature and Trident can optionally integrate with
-;; it. If you call trident-add-slime-selector-methods, two entries related to
-;; trident-mode will be added. One, invoked with p, will take you to the most
-;; recently visited buffer where trident-mode is active (excluding buffers
-;; which are already visible). The other, on P, will take you to a scratch
-;; buffer with trident-mode enabled, creating the buffer if necessary.
-
-;; Speaking of the scratch buffer, the trident-scratch command will take you
-;; straight there.
+;; (add-hook 'trident-mode-hook 'steal-sly-keys-for-trident!)
;; ** Still do be done
;; - Add some tests.
;; - Better documentation.
;; - Look into adding a REPL.
-;; - See if more integration with SLIME is possible.
+;; - See if more integration with SLY is possible.
;; - Command(s) for compiling to a file.
;; - Similar support for CL-WHO and/or CSS-LITE?
;; - Add support for Customize.
@@ -189,7 +177,7 @@
;;; Code:
-(require 'slime)
+(require 'sly)
(require 'skewer-mode)
(require 'dash)
@@ -232,10 +220,10 @@ discarded; it must work through side effects alone.
See also `trident-with-expansion'."
(let ((string (trident-wrap-in-ps-form string)))
- (slime-eval-async `(swank:eval-and-grab-output ,string)
+ (sly-eval-async `(swank:eval-and-grab-output ,string)
#'(lambda (result)
(funcall fn (read (cadr result))))
- (slime-current-package))))
+ (sly-current-package))))
(defmacro trident-with-expansion (name-and-string &rest body)
"Expand a Parenscript string and execute BODY.
@@ -250,12 +238,12 @@ See also `trident-call-with-expansion'."
(let ((name (car name-and-string))
(string (cadr name-and-string))
(rv (make-symbol "rv")))
- `(slime-eval-async
+ `(sly-eval-async
`(swank:eval-and-grab-output ,(trident-wrap-in-ps-form ,string))
#'(lambda (,rv)
(let ((,name (read (cadr ,rv))))
,@body))
- (slime-current-package))))
+ (sly-current-package))))
(put 'trident-with-expansion 'lisp-indent-function 1)
@@ -267,13 +255,13 @@ buffer's major mode is determined by the variable
`trident-expansion-major-mode' (`javascript-mode' by default).
`trident-expansion-mode' is enabled as an additional minor mode."
(trident-with-expansion (code string)
- (slime-with-popup-buffer ("*Parenscript generated JavaScript*")
+ (sly-with-popup-buffer ("*Parenscript generated JavaScript*")
(setq buffer-read-only nil)
(erase-buffer)
(insert code)
(funcall trident-expansion-major-mode)
(trident-expansion-mode 1)
- (font-lock-fontify-buffer)
+ (font-lock-ensure)
(goto-char (point-min))
(setq buffer-read-only t)
(pop-to-buffer (current-buffer)))))
@@ -300,20 +288,21 @@ destination it's overwritten."
(defun trident-expand-sexp ()
"Display the expansion of the form at point."
(interactive)
- (trident-expand (slime-sexp-at-point)))
+ (trident-expand (sly-sexp-at-point)))
(defun trident-expand-last-expression ()
"Display the expansion of the expression preceding point."
(interactive)
- (trident-expand (slime-last-expression)))
+ (trident-expand (sly-last-expression)))
(defun trident-expand-defun ()
"Display the expansion of the current toplevel form."
(interactive)
- (trident-expand (slime-defun-at-point)))
+ (trident-expand (sly-region-for-defun-at-point)))
(defun trident-expand-region (beg end)
- "Display the expansion of the currently active region."
+ "Display the expansion of the currently active region.
+BEG and END are character positions delimiting active region."
(interactive "r")
(trident-expand (buffer-substring-no-properties beg end)))
@@ -345,23 +334,23 @@ sent to the browser via `skewer-eval'."
(defun trident-eval-sexp ()
"Evaluate the expression at point as Parenscript."
(interactive)
- (trident-eval (slime-sexp-at-point)))
+ (trident-eval (sly-sexp-at-point)))
(defun trident-eval-last-expression (&optional prefix)
- "Evaluate the expression preceding point as Parenscript. If
-invoked with a prefix argument, insert the result into the
+ "Evaluate the expression preceding point as Parenscript.
+If invoked with a PREFIX argument, insert the result into the
current buffer."
(interactive "P")
(if prefix
(trident-eval-print-last-expression)
- (trident-eval (slime-last-expression))))
+ (trident-eval (sly-last-expression))))
(defun trident-eval-print-last-expression ()
- "Evaluate sexp before point as Parenscript; print value into
-the current buffer."
+ "Evaluate sexp before point as Parenscript.
+Print value into the current buffer."
(interactive)
(cl-destructuring-bind (start end)
- (slime-region-for-defun-at-point)
+ (sly-region-for-defun-at-point)
(let ((string (buffer-substring-no-properties start end)))
(skewer-flash-region start end)
(unless (zerop (current-column))
@@ -375,20 +364,18 @@ the current buffer."
(defun trident-eval-defun ()
"Evaluate the current toplevel form as Parenscript."
(interactive)
- (trident-eval (slime-defun-at-point)))
+ (trident-eval (sly-region-for-defun-at-point)))
(defun trident-eval-region (beg end)
- "Evaluate the currently active region as Parenscript."
+ "Evaluate the currently active region as Parenscript.
+BEG and END are character positions delimiting active region."
(interactive "r")
(trident-eval (buffer-substring-no-properties beg end)))
(defun trident-eval-buffer ()
"Evaluate the current buffer as Parenscript."
(interactive)
- (prog1
- (trident-eval-region (point-min) (point-max))
- (when slime-highlight-edits-mode
- (slime-remove-edits (point-min) (point-max)))))
+ (trident-eval-region (point-min) (point-max)))
(defun trident-eval-dwim ()
"Evaluate the active region or toplevel form.
@@ -448,7 +435,7 @@ buffer."
(or (get-buffer name)
(with-current-buffer (get-buffer-create name)
(lisp-mode)
- (slime-mode t)
+ (sly-mode t)
(trident-mode 1)
(trident-scratch-mode 1)
(current-buffer)))))
@@ -464,7 +451,7 @@ buffer."
(interactive)
(trident-switch-to-scratch-buffer))
-;;;; A little extra SLIME integration
+;;;; A little extra SLY integration
(defun trident-mode-buffer-p (buffer)
"Return t if `trident-mode' is active in BUFFER."
@@ -479,18 +466,6 @@ Only considers buffers that are not already visible."
(buffer-list))
(error "Can't find unshown buffer in trident-mode")))
-(defun trident-add-slime-selector-methods ()
- "Add methods to `slime-selector' for `trident-mode' buffers.
-Allows access to the most recently visited buffer with
-trident-mode active via \"p\" and to the *trident-scratch* buffer
-via \"P\"."
- (interactive)
- (def-slime-selector-method ?p
- "most recently visited buffer using trident-mode."
- (trident-recently-visited-trident-buffer))
- (def-slime-selector-method ?P
- "*trident-scratch* buffer."
- (trident-scratch-buffer)))
;;;; The minor modes