Comments (8)
Thanks! The Expected behavior
seems a reasonable expectation.
from cider.
Or probably we should overwrite the first comment, as I don't see much point in inserting multiple comments for evaluation results.
from cider.
Or probably we should overwrite the first comment, as I don't see much point in inserting multiple comments for evaluation results.
I've had this implemented locally for some time:
(defun cider-maybe-insert-multiline-comment (result comment-prefix continued-prefix comment-postfix)
"Insert eval RESULT at current location if RESULT is not empty.
RESULT will be preceded by COMMENT-PREFIX.
CONTINUED-PREFIX is inserted for each additional line of output.
COMMENT-POSTFIX is inserted after final text output."
(unless (string= result "")
;; replace existing comment
(when (and (skip-chars-forward " \t")
(looking-at-p (regexp-quote cider-comment-prefix)))
(delete-region (point)
(progn (while (and (forward-line 1)
(looking-at-p cider-comment-continued-prefix)))
(point))))
;; follow indentation
(clojure-indent-line)
(let ((lines (split-string result "[\n]+" t))
(beg (point))
(col (current-indentation)))
;; only the first line gets the normal comment-prefix
(insert (concat comment-prefix (pop lines)))
(dolist (elem lines)
(insert (concat "\n" continued-prefix elem)))
(unless (string= comment-postfix "")
(insert comment-postfix))
(indent-rigidly beg (line-end-position) col))))
But I'm aware it's a bit of a hack and might not work in the odd case where someone set up the prefix/postifix to use #_
or (comment)
from cider.
I've no strong opinion regarding replacing or appending the comment in a newline, but when doing this command outside the form it will append. I guessed this was the right behaviour.
from cider.
'Append' would seem better to me since:
- Deleting can remove unrelated comments
- One can plausibly want to append a new result time, e.g. I'm querying some API
from cider.
Sorry if this might be off-topic from the original issue - at least from my usage, the vast majority of the time I'm using eval-to-comment almost like a 'persistent' version of the regular eval overlays.
Having to manually 'clean up' the accumulated stacks of comment evals ended up being so annoying that I modified the function as above, and the rare couple of times I do want to append
I can simply place a newline above the previous ;; =>
line that I want to keep around.
Edit: a quick screen capture of what I meant
eval-to-comment.mov
from cider.
Yeah there are definitely many ways to use CIDER - for example I tend to send stuff to the repl so that I have a trail of past evals
We could have a defcustom for capturing the two styles of intended behavior.
from cider.
Sorry if this might be off-topic from the original issue - at least from my usage, the vast majority of the time I'm using eval-to-comment almost like a 'persistent' version of the regular eval overlays.
This is the way the feature was intended to be used, therefore my previous comment. But I do acknowledge that different people might have different expectations/use-cases. Perhaps some defcustom is the way to go indeed.
from cider.
Related Issues (20)
- Errors when auto complete called in Cljs repl HOT 2
- `sesman-use-friendly-sessions` not respected HOT 6
- Use pretty-print formatting inside cider-inspect HOT 1
- Support bookmarks to Cider REPLs HOT 2
- Spinner support while running tests
- can't use Clojure 1.12 `add-lib` when `cider-enrich-classpath` set to `t` HOT 8
- refresh ops shouldn't have a timeout HOT 3
- `cider-enable-flex-completion` is not a sufficient replacement for `cider-company-enable-fuzzy-completion` HOT 26
- "Not a tramp file name" when running cider-connect HOT 1
- `cider-locals` - false positives HOT 4
- Wrong previous-line behavior while overlay is active
- Change `cider-interactive-eval-override` to make it more usable HOT 5
- Stack overflow when using CIDER with datahike and sail HOT 5
- Integration tests are broken HOT 1
- False assumption in cider-popup-buffer-display (with fix) HOT 1
- Update cheatsheet HOT 5
- In CLJC mode, C-x C-e evaluates against multiple REPLs simultaneously HOT 1
- Test reporter can't handle interrupted test HOT 2
- Current way of displaying cheatsheet is inconvenient HOT 3
- Allow inspecting a class that is used as a ^TypeTag HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cider.