{"action":"created","issue":{"url":"https://api.github.com/repos/greghendershott/racket-mode/issues/171","labels_url":"https://api.github.com/repos/greghendershott/racket-mode/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/greghendershott/racket-mode/issues/171/comments","events_url":"https://api.github.com/repos/greghendershott/racket-mode/issues/171/events","html_url":"https://github.com/greghendershott/racket-mode/issues/171","id":114232671,"number":171,"title":"result of racket-send-last-sexp in repl buffer is confusing","user":{"login":"cosmicexplorer","id":1305167,"avatar_url":"https://avatars.githubusercontent.com/u/1305167?v=3","gravatar_id":"","url":"https://api.github.com/users/cosmicexplorer","html_url":"https://github.com/cosmicexplorer","followers_url":"https://api.github.com/users/cosmicexplorer/followers","following_url":"https://api.github.com/users/cosmicexplorer/following{/other_user}","gists_url":"https://api.github.com/users/cosmicexplorer/gists{/gist_id}","starred_url":"https://api.github.com/users/cosmicexplorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cosmicexplorer/subscriptions","organizations_url":"https://api.github.com/users/cosmicexplorer/orgs","repos_url":"https://api.github.com/users/cosmicexplorer/repos","events_url":"https://api.github.com/users/cosmicexplorer/events{/privacy}","received_events_url":"https://api.github.com/users/cosmicexplorer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/greghendershott/racket-mode/labels/enhancement","name":"enhancement","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-30T09:32:56Z","updated_at":"2015-10-31T04:10:00Z","closed_at":null,"body":"Evaluating a form before point with `racket-send-last-sexp` sends the form to the `*Racket REPL*` buffer and evaluates it, and leaves it in the repl buffer as if it was an expression the user entered. This leads to confusing behavior, as below:\r\n`test.rkt`:\r\n```\r\n(print \"hey\")\r\n(closure 1 2)\r\n```\r\n`*Racket REPL*`:\r\n```\r\nhw5.rkt﻿> \"hey\"\r\nhw5.rkt﻿> (+ 1 2)\r\n3\r\nhw5.rkt﻿> (closure 1 2)\r\nhw5.rkt﻿> \r\n```\r\n\r\nCan you tell what happened here? In this case, the user evaluated the form `(print \"hey\")` in `test.rkt`, then switched to the repl buffer, then evaluated `(+ 1 2)` there, then evaluated `(closure 1 2)` in `test.rkt` (where `closure` is some random struct, sorry for the confusing name). This sequence of events is not immediately obvious from looking at the repl buffer, and normal keybindings like `M-p` or `M-n` don't traverse the history of `racket-send-last-sexp` results. So the current behavior leads to a confusing, inconsistent log of evaluation order in the repl buffer.\r\n\r\nIs there a reason it's written this way? Other lispy interaction modes like [cider](https://github.com/clojure-emacs/cider) just display the result of `C-x C-e` in the minibuffer just like native emacs lisp expressions; if they log the results at all, they log them as \"results;\" i.e. not at the same line as the prompt. If the above were to be translated to cider's style, it would likely look like the below, with minibuffer display as well when the user evaluates each line:\r\n\r\n```\r\n\"hey\"\r\nhw5.rkt﻿> (+ 1 2)\r\n3\r\n(closure 1 2)\r\nhw5.rkt﻿> \r\n```\r\n\r\nIn this case, it's obvious that `\"hey\"` is the result of some evaluation run elsewhere, *not* in the repl buffer, as is the `(closure 1 2)` message. In addition, because of the minibuffer echoing as the expression is evaluated, it's not required that the user even have the repl buffer open for quick and dirty evaluations like `C-x C-e` is usually used for.\r\n\r\nSo is there a reason the current version works the way it does? If not I can try to whip up a pull request to enforce what I guess I'm calling cider-like behavior."},"comment":{"url":"https://api.github.com/repos/greghendershott/racket-mode/issues/comments/152691008","html_url":"https://github.com/greghendershott/racket-mode/issues/171#issuecomment-152691008","issue_url":"https://api.github.com/repos/greghendershott/racket-mode/issues/171","id":152691008,"user":{"login":"greghendershott","id":265119,"avatar_url":"https://avatars.githubusercontent.com/u/265119?v=3","gravatar_id":"","url":"https://api.github.com/users/greghendershott","html_url":"https://github.com/greghendershott","followers_url":"https://api.github.com/users/greghendershott/followers","following_url":"https://api.github.com/users/greghendershott/following{/other_user}","gists_url":"https://api.github.com/users/greghendershott/gists{/gist_id}","starred_url":"https://api.github.com/users/greghendershott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greghendershott/subscriptions","organizations_url":"https://api.github.com/users/greghendershott/orgs","repos_url":"https://api.github.com/users/greghendershott/repos","events_url":"https://api.github.com/users/greghendershott/events{/privacy}","received_events_url":"https://api.github.com/users/greghendershott/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T04:10:00Z","updated_at":"2015-10-31T04:10:00Z","body":"> A solution which would satisfy both of us, I think, would be to copy the sexp C-x C-e is currently evaluating over to the REPL buffer, then run comint-send-input, which would make the expression available in input history.\r\n\r\nOne drawback to copying and showing them in the REPL, would be that <kbd>C-x C-e</kbd> -- and especially <kbd>M-C-x</kbd> -- may be used with very large sexps. It could be distracting for these to appear in the REPL, especially if they're big enough to cause the window to scroll far.\r\n\r\n> An alternative similar to the method I described in the OP would be to have some logic which moves the repl's point to before the current prompt, then runs comint-send-region so it appears as an \"output\" instead of an \"input\" (although that seems harder and for little benefit).\r\n\r\nAlthough not exactly what you're describing here, I'm testing a `comint-preoutput-filter-functions` hook that checks if point is on the same line as a prompt, and if so, inserts a `\\n` before the output.\r\n\r\n[ICYI: It's better if this is only used for the few `send-xxx-to-repl` commands that we're talking about -- not generally. Otherwise it causes extraneous newlines and prompts when Racket is sending its own hidden/internal commands to the Racket REPL process.]\r\n\r\nSo far this is working well but I'd like to test some more before committing and pushing."}}