Giter VIP home page Giter VIP logo

Comments (8)

vemv avatar vemv commented on May 26, 2024

Thanks! The Expected behavior seems a reasonable expectation.

from cider.

bbatsov avatar bbatsov commented on May 26, 2024

Or probably we should overwrite the first comment, as I don't see much point in inserting multiple comments for evaluation results.

from cider.

yuhan0 avatar yuhan0 commented on May 26, 2024

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.

filipesilva avatar filipesilva commented on May 26, 2024

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.

vemv avatar vemv commented on May 26, 2024

'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.

yuhan0 avatar yuhan0 commented on May 26, 2024

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.

vemv avatar vemv commented on May 26, 2024

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.

bbatsov avatar bbatsov commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.