在Emacs for OSX上,如何将kill ring和剪贴板分开?

inc*_*man 12 emacs clipboard aquamacs kill-ring

在GNU Emacs for OSX中,如何将kill ring和OSX剪贴板分开?(这样我基本上有两个独立的杀戮戒指.)

通过所需的行为,这将起作用:
1.C将文本从Web复制到OSX剪贴板.
2. controlk在Emacs中杀死一条线.
3. controly将Emacs kill ring中的文本从当前的Emacs缓冲区中删除.
4. v将原始Web文本从OSX剪贴板粘贴到当前的Emacs缓冲区.

这在Aquamacs开箱即用.如何在GNU Emacs中工作?

这里讨论的问题与Windows有关: Emacs:如何将kill ring与系统剪贴板分开?

在这里:http: //lists.gnu.org/archive/html/help-emacs-windows/2010-02/msg00001.HTML

...但此解决方案在OSX中不起作用.我想要一个适用于Mac OSX的解决方案.

4ae*_*1e1 10

Emacs中的解决方案:如何将kill ring与系统剪贴板分开?确实有效,但并不完整.你可以打电话给pbcopy自己让剪贴板粘贴正确.例如,尝试以下内容.emacs.请注意,这s-v适用Cmd+V于OS X窗口系统.同样如此s-c.

;;; Tested on:
;;; 1.  GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0)
;;;     of 2013-12-22 on tennine-slave.macports.org
;;;     (MacPorts emacs@24.3_1)
;;;
;;; 2.  GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
;;;     of 2013-03-12 on bob.porkrind.org
;;;     (Emacs For Mac OS X)

(defun isolate-kill-ring()
  "Isolate Emacs kill ring from OS X system pasteboard.
This function is only necessary in window system."
  (interactive)
  (setq interprogram-cut-function nil)
  (setq interprogram-paste-function nil))

(defun pasteboard-copy()
  "Copy region to OS X system pasteboard."
  (interactive)
  (shell-command-on-region
   (region-beginning) (region-end) "pbcopy"))

(defun pasteboard-paste()
  "Paste from OS X system pasteboard via `pbpaste' to point."
  (interactive)
  (shell-command-on-region
   (point) (if mark-active (mark) (point)) "pbpaste" nil t))

(defun pasteboard-cut()
  "Cut region and put on OS X system pasteboard."
  (interactive)
  (pasteboard-copy)
  (delete-region (region-beginning) (region-end)))

(if window-system
    (progn
      (isolate-kill-ring)
      ;; bind CMD+C to pasteboard-copy
      (global-set-key (kbd "s-c") 'pasteboard-copy)
      ;; bind CMD+V to pasteboard-paste
      (global-set-key (kbd "s-v") 'pasteboard-paste)
      ;; bind CMD+X to pasteboard-cut
      (global-set-key (kbd "s-x") 'pasteboard-cut))

  ;; you might also want to assign some keybindings for non-window
  ;; system usage (i.e., in your text terminal, where the
  ;; command->super does not work)
  )
Run Code Online (Sandbox Code Playgroud)

如果您遇到过UTF-8问题,请考虑以下可能的解决方案:

;; handle emacs utf-8 input
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setenv "LANG" "en_US.UTF-8")
Run Code Online (Sandbox Code Playgroud)