문제

I have code in one buffer in a screen virtual terminal that i want to transfer to another buffer in a virtual terminal. How do i do that? I've tried killing the code but it seems like each virtual terminal has its own kill ring and the code i killed wasn't yanked into the other virtual terminal.

도움이 되었습니까?

해결책

It seems that the clipboard variables mentioned by @Ehvince (which are useful BTW when working on GUI emacs) are not useful in terminals. A workaround is described here. I am adding the code in the article below, to avoid dead links

(unless window-system
      (when (getenv "DISPLAY")
        ;; Callback for when user cuts
        (defun xsel-cut-function (text &optional push)
          ;; Insert text to temp-buffer, and "send" content to xsel stdin
          (with-temp-buffer
            (insert text)
            ;; I prefer using the "clipboard" selection (the one the
            ;; typically is used by c-c/c-v) before the primary selection
            ;; (that uses mouse-select/middle-button-click)
            (call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
        ;; Call back for when user pastes
        (defun xsel-paste-function()
          ;; Find out what is current selection by xsel. If it is different
          ;; from the top of the kill-ring (car kill-ring), then return
          ;; it. Else, nil is returned, so whatever is in the top of the
          ;; kill-ring will be used.
          (let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
            (unless (string= (car kill-ring) xsel-output)
              xsel-output )))
        ;; Attach callbacks to hooks
        (setq interprogram-cut-function 'xsel-cut-function)
        (setq interprogram-paste-function 'xsel-paste-function)))

Add this your init file. You will need to install the an external program xsel for this to work.

다른 팁

You could use emacs daemon for that. Start it with emacs --daemon and then on screen start emacs as a client with emacsclient(maybe with -nw or -t, depending on what you want). This works for me.

Hope it helps :)

I have this snippet of code that helps me kill/yank between applications located outside of emacs. You can try it (but I didn't test in your environment).

(setq x-select-enable-clipboard t        ;; copy-paste should work ...
 interprogram-paste-function            ;; ...with...
 'x-cut-buffer-or-selection-value)      ;; ...other X clients

source: http://www.djcbsoftware.nl/dot-emacs.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top