Last active
August 14, 2025 05:49
-
-
Save andiogenes/d96f9803c8f457ffe4b795c1b01710e9 to your computer and use it in GitHub Desktop.
Idea: Killing/yanking text from X clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Exchange between `emacs -nw` and X clipboard | |
| (defun x-select-text (text) | |
| "Send TEXT to X11's clipboard." | |
| (let ((process-connection-type nil)) | |
| (let ((proc (start-process "xsel" "*Messages*" "xsel" "-i" "-b"))) | |
| (process-send-string proc text) | |
| (process-send-eof proc)))) | |
| (defun x-selection-value () | |
| "Get X11' clipboard string to insert it into in `kill-buffer`." | |
| (shell-command-to-string "xsel -b")) | |
| (when (not (display-graphic-p)) | |
| (setq-default | |
| interprogram-cut-function #'x-select-text | |
| interprogram-paste-function #'x-selection-value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment