[slime-devel] slime-pprint-eval-region

Cyrus Harmon ch-slime at bobobeach.com
Sat May 5 23:36:15 UTC 2012


I had a desire for a slime-pprint-eval-region and cobbled together the following patch. It's bound to C-c C-f and allows one to highlight a region and then evaluate it. This is helpful in particular when dealing with forms with reader macros in them that aren't properly read by emacs' backward-sexp function.

Any interest in seeing something like this in the canonical slime.el?

thanks,

Cryus

diff --git a/slime.el b/slime.el
index 3ef2b41..bfb4242 100644
--- a/slime.el
+++ b/slime.el
@@ -531,6 +531,7 @@ information."
 
 (defvar slime-prefix-bindings
   '(("\C-r"  slime-eval-region)
+    ("\C-f"  slime-pprint-eval-region)
     (":"     slime-interactive-eval)
     ("\C-e"  slime-interactive-eval)
     ("E"     slime-edit-value)
@@ -4297,6 +4298,13 @@ Use `slime-re-evaluate-defvar' if the from starts with '(defvar'"
    `(swank:interactive-eval-region 
      ,(buffer-substring-no-properties start end))))
 
+(defun slime-pprint-eval-region (start end)
+  "Evaluate region; pprint the value in a buffer."
+  (interactive "r")
+  (slime-eval-describe
+   `(swank:pprint-eval
+     ,(buffer-substring-no-properties start end))))
+
 (defun slime-eval-buffer ()
   "Evaluate the current buffer.
 The value is printed in the echo area."
@@ -7149,6 +7157,7 @@ is setup, unless the user already set one explicitly."
        [ "Eval Last Expression"    slime-eval-last-expression ,C ]
        [ "Eval And Pretty-Print"   slime-pprint-eval-last-expression ,C ]
        [ "Eval Region"             slime-eval-region ,C ]
+       [ "Eval Region And Pretty-Print" slime-pprint-eval-region ,C ]
        [ "Interactive Eval..."     slime-interactive-eval ,C ]
        [ "Edit Lisp Value..."      slime-edit-value ,C ]
        [ "Call Defun"              slime-call-defun ,C ])





More information about the slime-devel mailing list