You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Those of us trying to just reuse code from embark.el and adapt it to our need could use a brief mention in the README of the role that embark-multitarget-actions plays in determining how arguments are passed to embark actions.
I just spent an embarrassingly long time trying to understand why this didn't work as intended:
(defunmy/embark-copy-to-clipboard (strings)
"Join STRINGS and pass to the system clipboard using `simpleclip-set-contents'.With a prefix argument, prompt for the separator to join theSTRINGS, which defaults to a newline."
(simpleclip-set-contents (string-join strings (embark--separator strings))))
(define-key embark-general-map "W"#'my/embark-copy-to-clipboard)
I was looking for a way of mimicking the behavior of embark-copy-as-kill to send stuff to the system clipboard rather than the kill ring. So I figured I could just adapt embark-copy-as-kill to use simpleclip-set-contents rather than kill-new and get exactly what I was looking for.
After running into error message after error message, I discovered that the reason embark-copy-as-kill works the way it does is because it's an element of embark-multitarget-actions. Thus I could do what I wanted (mimic the behavior of embark-copy-as-kill but having the system clipboard play the role of the kill ring) I needed to add this one line of code.
Of course, if I had just read the README and understood all of it, I would have known how to define my function directly, say:
(defunmy/embark-copy-to-clipboard (string)
"Pass STRING to the system clipboard using `simpleclip-set-contents'."
(simpleclip-set-contents string))
(define-key embark-general-map "W"#'my/embark-copy-to-clipboard)
But I'm probably not the only one who just tries to reuse function definitions and tweak them a little rather than start from scratch, even when I don't fully understand why the original definition works the way it does. 😜
The text was updated successfully, but these errors were encountered:
I should definitely add something about embark-multitarget-actions to the README! The only reason I haven't is that I mistakenly thought I already had!
By the way, for your last code snippet, I'd cut out the middle man and just use (define-key embark-general-map "W" #'simpleclip-set-contents).
Those of us trying to just reuse code from
embark.el
and adapt it to our need could use a brief mention in the README of the role thatembark-multitarget-actions
plays in determining how arguments are passed to embark actions.I just spent an embarrassingly long time trying to understand why this didn't work as intended:
I was looking for a way of mimicking the behavior of
embark-copy-as-kill
to send stuff to the system clipboard rather than the kill ring. So I figured I could just adaptembark-copy-as-kill
to usesimpleclip-set-contents
rather thankill-new
and get exactly what I was looking for.After running into error message after error message, I discovered that the reason
embark-copy-as-kill
works the way it does is because it's an element ofembark-multitarget-actions
. Thus I could do what I wanted (mimic the behavior ofembark-copy-as-kill
but having the system clipboard play the role of the kill ring) I needed to add this one line of code.Of course, if I had just read the README and understood all of it, I would have known how to define my function directly, say:
But I'm probably not the only one who just tries to reuse function definitions and tweak them a little rather than start from scratch, even when I don't fully understand why the original definition works the way it does. 😜
The text was updated successfully, but these errors were encountered: