sanel / monroe

Clojure nREPL client for Emacs
161 stars 21 forks source link

Change monroe-eval-defun in order to change ns before send to eval #32

Closed bbuccianti closed 5 years ago

bbuccianti commented 5 years ago

Hi, Sanel!

Hope this makes sense, I was having the trouble to eval-buffer because eval-defun complains about not finding aliases included on the ns :require.

Let me know if anything can be improved, I'm only a student but I think that with a little help can be able to understand.

Thanks!

sanel commented 5 years ago

Thanks for the patch! Small proposal: (monroe-eval-namespace) can be refactored to use (monroe-get-clojure-ns). Idea:

(defun monroe-get-clojure-ns ()
  "If available, get the correct clojure namespace."
  (and (eq major-mode 'clojure-mode)
       (fboundp 'clojure-find-ns)
       (funcall 'clojure-find-ns)))

(defun monroe-eval-namespace ()
  "Tries to evaluate Clojure ns form. It does this by matching first
expression at the beginning of the file and evaluating it. Not something
that is 100% accurate, but Clojure practice is to keep ns forms always
at the top of the file."
  (interactive)
  (when (monroe-get-clojure-ns)
    (save-excursion
      (goto-char (match-beginning 0))
      (monroe-eval-defun))))
bbuccianti commented 5 years ago

I'm learning this workflow of making a fork in order to pull request. Hope this last commit was correct.

Thank you very much!

sanel commented 5 years ago

All good. I'll fix in case of any issue. Thanks and good work!