Fork me on GitHub
#cider
<
2023-04-06
>
macrobartfast17:04:38

Is there a way to send an eval output from a buffer to the osx clipboard easily? I can copy from the buffer with pbcopy but this crossed my mind as an alternative possibility.

bherrmann03:04:09

Not exactly an emacs binding, but I do use this to have clojure use the java api to copy into the clipboard.

(defn to-clip [ s ]
  (let [
        string-selection (java.awt.datatransfer.StringSelection. s)
        clipboard (.. (java.awt.Toolkit/getDefaultToolkit) (getSystemClipboard))
        ]
    (.setContents clipboard string-selection nil)))

macrobartfast03:04:46

That’d work for me! I’ll give it a go. Thanks!

pppaul20:04:31

i just updated cider, and now when i press enter it adds a newline instead of evaluating code. this is also happening in the minibuffer with some cider commands, mainly undef symbol anyone have this issue as well?

dpsutton20:04:47

i think paredit changed some keybindings. Some details here: https://clojurians.slack.com/archives/C0617A8PQ/p1671790072091949

dpsutton20:04:12

(I personally am a fan of newlines and control-j to send for eval but you can configure as you like)

pppaul05:04:07

my biggest problem is not being able to undef symbols, new lines are just a new thing that also happened around the same time i lost the ability to undef symbols

bozhidar06:04:42

Yeah, that's coming from Paredit changes. Perhaps at some point I'll have CIDER override them, it's just kind of a bad practice for one library to change the defaults of another.

👍 1
pppaul19:04:54

maybe I can disable paredit in the minibuffer. I haven't really configured that before, could paredit-everywhere-mode be a possible cause, or is there something else I should be looking at to fix this?

Akiz15:04:04

@U0LAJQLQ1 I’d say so. I just recently had to explicitly enable paredit for REPL, because I wanted the described behaviour. When paredit is disabled, enter evals..

Akiz15:04:31

(use-package paredit
      :ensure t
      :hook ((clojure-mode . paredit-mode)
             (clojurec-mode . paredit-mode)
             (clojurescript-mode . paredit-mode)
             (cider-repl-mode . paredit-mode))
...
This is my config. Without cider-repl-mode-hook it does what you want.

pppaul20:04:29

thanks, my init.el already does what you suggested. my minibuffer is completely useless for many cider commands, and i don't think it's cider's fault. is there a way for me to see the minor-modes in the minibuffer? or is there some meta command i can use in the mini-buffer to get it to execute the commands i want? it is the case that only cider commands are breaking, and not all, mainly the undef command, but i assume that commands that require me to enter text will similarly break.

Akiz07:04:32

Pressing , in Cider Repl and then C-h m should do it.

lilactown21:04:54

are there any examples of writing custom commands that wrap a defun or symbol in some extra stuff before evaluating?

lilactown21:04:26

e.g. if I wanted to bind a hotkey that evaled whatever symbol was under my cursor wrapped in (tap> ,,,)

practicalli-johnny00:04:22

Some examples of calling Portal Clojure commands from an Emacs interactive function using cider-nrepl-sync-request:eval https://practical.li/clojure/data-inspector/portal/#editor-commands

cwchriswilliams07:04:37

Mine probably aren't as clean as John's, but I do have one where you can call it with C-u to bring up a list of viewers for the tapped thing to display as https://github.com/cwchriswilliams/emacs-2023/blob/main/post-init.org#portal-extensions (these are particularly if you're using Portal, I should add)

dakra08:04:08

If you just want to tap> there's already cider-tap-sexp-at-point and cider-tap-last-sexp in the latest cider release. The https://github.com/clojure-emacs/cider/blob/68709bc29b81fdd0b9d2cb8089cdd43a429a685f/cider-eval.el#L1036-L1045 is also very simple in case you want to customise it a bit. E.g. I have https://github.com/dakra/dmacs/blob/6dce0b73318a3b6666afa1b1aea502083e576b48/init.org?plain=1#L5723-L5736 in my config to tap the last sexp to clerk for their vega-lite viewer.

👀 2
cwchriswilliams08:04:22

Awesome. I didn't know that had been added. 👍

lilactown16:04:52

@UFAP0C8KU I was able to crib off of those built in functions to do what I wanted. Thanks!

👍 2