[slime-devel] Inserting eval results in the current buffer

Nikodemus Siivola nikodemus at random-state.net
Fri Apr 27 08:48:36 UTC 2007


I submit that the current behaviour of <prefix> C-x C-e is not very useful. It 
is probably almost ideal for <prefix> C-c : -- eg. for creating constants
with one-liners.

This is what I use in lieu of it, and what might be good for Slime proper
too.

(defun ns:scan-forward (stop-after stop-before)
   (do ()
       ((or (eql (char-after) stop-before)
            (eql (char-before) stop-after)))
     (forward-char)))

(defun ns:comment-at-eol ()
   (let ((newline (string-to-char "\n"))
         (comment (string-to-char ";")))
     (ns:scan-forward comment newline)
     (unless (eql newline (char-after))
       (kill-line))
     (unless (eql comment (char-before))
       (insert "   ;")))
   (insert " "))

(defun ns:eval-in-lisp-insert-comment ()
   (interactive)
   (lexical-let ((current-buffer (current-buffer)))
     (slime-eval-with-transcript
      `(swank:interactive-eval ,(slime-last-expression))
      `(lambda (value)
         (with-current-buffer ,current-buffer
           (ns:comment-at-eol)
           (insert (format "%s" value)))))))

Cheers,

  -- Nikodemus




More information about the slime-devel mailing list