Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ensure pprint is after load-file #432

Merged
merged 1 commit into from
Aug 17, 2017

Conversation

SevereOverfl0w
Copy link
Contributor

@SevereOverfl0w SevereOverfl0w commented Jul 26, 2017

load-file can produce an eval message. Non-deterministically load-file
was before/after pprint middleware. This would mean that pprint would
sometimes work for load-file, and not other times, dependent upon a JVM
restart.

This makes tpope/vim-fireplace#301 work

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing
  • The new code is not generating reflection warnings
  • You've updated the readme (if adding/changing middleware)

As an aside: I can't get the tests to pass locally even on master, so I'm depending on the CI

@SevereOverfl0w SevereOverfl0w force-pushed the pprintloadfile branch 6 times, most recently from 6b356fa to 9c12799 Compare July 30, 2017 17:57
@SevereOverfl0w
Copy link
Contributor Author

I rewrote the implementation because of some strange bug.

I've got the test running in almost all platforms, for some reason one in the matrix is failing. I have no idea why.

Works fine locally with the same command. Worked fine with a debug commit added. I have no idea.

@bbatsov
Copy link
Member

bbatsov commented Jul 30, 2017

What was wrong with the old implementation?

@bbatsov
Copy link
Member

bbatsov commented Jul 31, 2017

In particular - why aren't we using the standard dep mechanisms of nREPL?

@@ -120,7 +120,7 @@
false, or string representations of the above)."
[handler]
(fn [{:keys [op pprint] :as msg}]
(handler (if (and pprint (= op "eval"))
(handler (if (and pprint (#{"eval" "load-file"} op))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what this is supposed to do. The op is one of the two?

@SevereOverfl0w
Copy link
Contributor Author

SevereOverfl0w commented Jul 31, 2017 via email

@bbatsov
Copy link
Member

bbatsov commented Aug 10, 2017

Sorry for the slow turnaround here, but I've been beyond busy at work lately.

As I want to cut a new bugfix release soon I see two options.

  1. You add some explanation to the current workaround so we would not forget to address it
  2. We find someone to help shed light on the original problem //cc @vspinu @Malabarba @cemerick

@vspinu
Copy link
Contributor

vspinu commented Aug 10, 2017

Out of curiosity I have tried locally

modified   src/cider/nrepl/middleware/pprint.clj
@@ -127,7 +127,7 @@
 (set-descriptor!
  #'wrap-pprint
  (cljs/expects-piggieback
-  {:requires #{"clone" #'pr-values #'wrap-pprint-fn}
+  {:requires #{"clone" "load-file" #'pr-values #'wrap-pprint-fn}
    :expects #{"eval"}
    :handles
    {"pprint-middleware"

and it does not trigger any eval errors or test errors.

But I am missing the motivation for this. How is exactly pprint related to load-file? @SevereOverfl0w, is there a specific use case what you have in mind and haven't described in the OP?

As to the "one test failing" is travis choking on cider's env matrix. That happens more often than not recently.

@SevereOverfl0w
Copy link
Contributor Author

@vspinu Here is the failure build for using that change: https://travis-ci.org/clojure-emacs/cider-nrepl/builds/257670955 If you think that is okay to pass, I can revert to that.

The use-case is that vim-fireplace sends a load-file op for some evaluation contexts. This allows that context to have pprint as a result of that evaluation.

Currently it works 50% of the time depending on the random ordering. I have a PR open here to add pprint to vim: tpope/vim-fireplace#301

@vspinu
Copy link
Contributor

vspinu commented Aug 10, 2017

Here is the failure build for using that change

I see, only cljs tests are failing. I missed that part.

vim-fireplace sends a load-file op for some evaluation contexts.

But then your current PR is the right thing and the previous version was not that meaningful.

If my understanding is correct, you want the pprint to expect load-file down the pipeline just like it expects eval op, then check if either eval or load-file is requited and alter the transport. Right?

If so, then your current PR is the right step, but you then have to add "load-file" to :expects set. Otherwise it still could happen that load-file appears earlier in the pipeline, not solving your original issue.

modified   src/cider/nrepl/middleware/pprint.clj
@@ -120,7 +120,7 @@
   false, or string representations of the above)."
   [handler]
   (fn [{:keys [op pprint] :as msg}]
-    (handler (if (and pprint (= op "eval"))
+    (handler (if (and pprint (#{"eval" "load-file"} op))
                (assoc msg :transport (pprint-transport msg))
                msg))))
 
@@ -128,7 +128,7 @@
  #'wrap-pprint
  (cljs/expects-piggieback
   {:requires #{"clone" #'pr-values #'wrap-pprint-fn}
-   :expects #{"eval"}
+   :expects #{"eval" "load-file"}
    :handles
    {"pprint-middleware"
     {:doc "Enhances the `eval` op by adding pretty-printing. Not an op in itself."

@SevereOverfl0w
Copy link
Contributor Author

SevereOverfl0w commented Aug 10, 2017 via email

Without this, pprint works non-deterministically for load-file, as
load-file generates an eval operation.
@SevereOverfl0w
Copy link
Contributor Author

SevereOverfl0w commented Aug 11, 2017 via email

@vspinu
Copy link
Contributor

vspinu commented Aug 11, 2017

It's a irrelevant failure. Works locally for me. One of the project members could re-run the job.

@bbatsov bbatsov merged commit d7e0c3c into clojure-emacs:master Aug 17, 2017
bbatsov added a commit to clojure-emacs/cider that referenced this pull request Aug 17, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants