Pasting text into emacs on Macintosh

前端 未结 2 1693
梦毁少年i
梦毁少年i 2021-02-04 12:33

I\'m on a Macintosh and am using \"terminal\" for my shell. When I copy text from any window (via mouse drag then right mouse button menu -> copy) and then I paste the text (ri

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 12:59

    Try this:

    (defun pt-pbpaste ()
      "Paste data from pasteboard."
      (interactive)
      (shell-command-on-region
       (point)
       (if mark-active (mark) (point))
       "pbpaste" nil t))
    
    (defun pt-pbcopy ()
      "Copy region to pasteboard."
      (interactive)
      (print (mark))
      (when mark-active
        (shell-command-on-region
         (point) (mark) "pbcopy")
        (kill-buffer "*Shell Command Output*")))
    
    (global-set-key [?\C-x ?\C-y] 'pt-pbpaste)
    (global-set-key [?\C-x ?\M-w] 'pt-pbcopy)
    

    Use C-x C-y to paste and C-x M-w to copy.

提交回复
热议问题