Skip to content

Instantly share code, notes, and snippets.

@mkhattab
Last active August 29, 2015 13:56
Show Gist options
  • Save mkhattab/8970287 to your computer and use it in GitHub Desktop.
Save mkhattab/8970287 to your computer and use it in GitHub Desktop.
Evaluate last sexp as inline comment
;;; my-scheme configuration
(defun my-scm-preoutput-filter (string)
(with-current-buffer (window-buffer (frame-selected-window))
(save-restriction
(save-excursion
(backward-sexp)
(forward-sexp)
(paredit-comment-dwim)
(save-excursion
(unless (looking-at "=> ")
(insert "=> ")))
(let ((beg (+ (point) 3)))
(move-end-of-line 1)
(delete-region beg (point))
(string-match "^;Value: \\(.*\\)$" string)
(insert (substring string (match-beginning 1) (match-end 1)))))))
(with-current-buffer (process-buffer (scheme-proc))
(set (make-local-variable 'comint-preoutput-filter-functions) nil))
string)
(defun my-scm-eval-last-sexp-inline-comment ()
(interactive)
(let ((proc (scheme-proc)))
(with-current-buffer (process-buffer proc)
(set (make-local-variable 'comint-preoutput-filter-functions) '(my-scm-preoutput-filter)))
(scheme-send-last-sexp)))
(provide 'my-scheme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment