1 min read

cider eval customization

cider eval customization
Photo by Nik / Unsplash

emacs customization for clojure에, 코드에 eval 결과를 삽입하여 lighttable의 instarepl과 같은 효과를 주는 함수가 있는데 지금 사용해보니 그 사이에 cider에서 삭제된 함수 때문에 사용할 수 없었다. 다음과 같은 오류 메시지가 발생한다.

Symbol's function definition is void: cider-eval-and-get-value

다음은 수정한 함수이다.

;; new version
(defun cider-eval-last-sexp-and-append ()
  "Evaluate the expression preceding point and append result."
  (interactive)
  (let ((last-sexp (cider-last-sexp)))
    ;; we have to be sure the evaluation won't result in an error
    (cider-eval-last-sexp)
    (with-current-buffer (current-buffer)
                         (insert ";;=> "))
    (cider-interactive-eval last-sexp
                            (cider-eval-print-handler))))

참고용으로 원 소스도 같이 올려둔다.

;; original version
(defun cider-eval-last-sexp-and-append ()
  "Evaluate the expression preceding point and append result."
  (interactive)
  (let ((last-sexp (cider-last-sexp)))
    ;; we have to be sure the evaluation won't result in an error
    (cider-eval-and-get-value last-sexp)
    (with-current-buffer (current-buffer)
                         (insert ";;=> "))
    (cider-interactive-eval-print last-sexp)))
— END OF POST.