[slime-devel] additionnal option to slime-eval-print: prefix the result with "; ; --> "

Pascal J. Bourguignon pjb at informatimago.com
Sat Nov 6 23:32:57 UTC 2010


   (progn (print "Hello World!") (values 1 2)) C-u C-x C-e 

inserts:

    "Hello World!" 1
    2


With one more C-u:

   (progn (print "Hello World!") (values 1 2)) C-u C-u C-x C-e 

I'd want to get:

"Hello World!" 
;; --> 1
;;     2


Hence this new version:

(defun slime-eval-print (string)
  "Eval STRING in Lisp; insert any output and the result at point."
  (message "current-prefix-arg = %S" current-prefix-arg)
  (let ((commentp (and (listp current-prefix-arg)
                       (integerp (first current-prefix-arg))
                       (< 4 (first current-prefix-arg)))))
    (slime-eval-async `(swank:eval-and-grab-output ,string)
      `(lambda (result)
        (destructuring-bind (output value) result
          (push-mark)
          (if ,commentp
              (progn
                (insert output)
                (let ((lines (split-string value "\n")))
                  (insert "\n;; --> " (first lines) "\n")
                  (dolist (line (rest lines))
                    (insert ";;     " line "\n"))))
              (insert output value)))))))

(The ,commentp is icky, but it's emacs lisp).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.





More information about the slime-devel mailing list