2

When you press 'y' (elfeed-search-yank) in an elfeed-search buffer, the selected entry's permalink url is copied to the emacs clipboard.

I don't have any automatic clipboard sync packages installed, and I don't intend to.

Is it possible to Meta-: Eval: and tell emacs to send whatever is in the emacs clipboard to the OS (MacOS) clipboard?

What I tried: browsed the source code for https://github.com/jkp/pbcopy.el/blob/master/pbcopy.el didn't see any interesting functions

NOTE: I'm using terminal emacs

2

3 Answers 3

1

You can call copy-to-x-clipboard from Meta-X or Eval:. No Emacs packages necessary. It relies on the pbcopy shell command, which is available in all macOS installations.

(defun copy-to-x-clipboard ()
  (interactive) 
  (switch-to-buffer (make-temp-name "scratch"))  
  (insert (current-kill 1))
  (shell-command-on-region (point-min) (point-max) "pbcopy")
  (kill-this-buffer))
3
  • The question relates to how to fetch some that was already copied to the emacs clipboard. elfeed-search-yank and many others copy entries to the emacs clipboard. When that happens, I need a way to upload that from the emacs clipboard to the OS (macOS) clipboard. Feb 10, 2018 at 16:48
  • And that's exactly what the above does. It gets the first item from the emacs clipboard, and pushes it to the macOS clipboard.
    – SamanGh
    Feb 10, 2018 at 17:54
  • I misunderstood Feb 10, 2018 at 18:03
1

Is it possible to Meta-: Eval: and tell emacs to send whatever is in the emacs clipboard to the OS (MacOS) clipboard?

Yes

M-: (call-process-region (car kill-ring) nil "pbcopy")
0

If you are running a GUI Emacs, it should copy automatically everything that goes into kill-ring to the system clipboard. Are you running emacs in a terminal?

To answer your question, the code to copy the latest kill-ring addition to system-kill ring is:

(kill-new (current-kill 1))
3
  • yes I'm 99% of the time on terminal.app with emacs -nw . (kill-new (current-kill 1)) looked promising but didn't work. I'll try again later Feb 9, 2018 at 18:18
  • I do not think it will work from within terminal.
    – Heikki
    Feb 9, 2018 at 19:01
  • @joshsverns You should update your question with that information. See stackoverflow.com/a/32051871/3084001 for terminal support.
    – Basil
    Feb 9, 2018 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.