How to paste to Emacs from clipboard on OSX?

后端 未结 7 1763
谎友^
谎友^ 2021-01-31 02:52

This might be extraordinarily simple, but I am playing with Emacs (22.1.1) and I can\'t get it to paste text in the clipboard using Control-Y.

7条回答
  •  余生分开走
    2021-01-31 03:32

    See http://blog.binchen.org/?p=589

    Here is code:

    (require 'simpleclip)
    (defun copy-to-clipboard ()
      (interactive)
      (let ((thing (if (region-active-p)
                       (buffer-substring-no-properties (region-beginning) (region-end))
                     (thing-at-point 'symbol))))
        (simpleclip-set-contents thing)
        (message "thing => clipboard!")))
    
    (defun paste-from-clipboard()
      "Paste string clipboard"
      (interactive)
      (insert (simpleclip-get-contents)))
    

    The code use simpleclip (https://github.com/rolandwalker/simpleclip)

    Simpleclip requires you install some command line tool on Mac/Linux/Cygwin which . So even emacs without graphic support could also access clipboard.

    This solution works on any version of Emacs, any OS. It also works when your remote ssh if the server enables X forward, the complete command is ssh -X -C -c blowfish-cbc,arcfour name@host.com)

提交回复
热议问题