How can i paste the selected region outside of emacs?

后端 未结 3 2110
忘了有多久
忘了有多久 2020-12-15 07:48

I am using Mac OS and emacs -nw (the terminal mode). I don\'t know how can I paste things (having been implemented by M-w in emacs -nw) outside the emacs.

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 08:25

    x-select-text is only used if you're running Emacs in a GUI. (Emacs maps the Mac/Windows pasteboard/clipboard APIs to the X11 model, hence the name). You can always use C-h f to find out more about a function like this one and view its definition if it's written in elisp.

    On the Mac, there is no concept of CLIPBOARD versus PRIMARY selections, so there is no point in setting x-select-enable-clipboard.

    The whole point of running emacs -nw is that it doesn't interact with the windowing system. Why use Emacs in a terminal when there are plenty of graphical Emacsen that work very nicely on the Mac?

    That said, if you really wanted to hook up terminal Emacs to the Mac pasteboard, you could do something like this:

    (setq interprogram-cut-function
          (lambda (text &optional push)
        (let* ((process-connection-type nil)
               (pbproxy (start-process "pbcopy" "pbcopy" "/usr/bin/pbcopy")))
          (process-send-string pbproxy text)
          (process-send-eof pbproxy))))
    

提交回复
热议问题