diff --git a/init.el b/init.el index 32fced7..e0be225 100644 --- a/init.el +++ b/init.el @@ -55,6 +55,17 @@ version 2022-06-09" ;; Clipboard integration for terminal (Need xclip) (when (not (display-graphic-p)) ;; Check if Emacs is running in the terminal + (defun my-cut-to-clipboard () + "Cut region to clipboard using xclip." + (interactive) + (if (use-region-p) + (let ((text (buffer-substring-no-properties (region-beginning) (region-end)))) + (with-temp-buffer + (insert text) + (call-process-region (point-min) (point-max) "xclip" nil 0 nil "-selection" "clipboard")) + (delete-region (region-beginning) (region-end)) + (message "Cut to clipboard")) + (message "No region selected."))) (defun my-copy-to-clipboard () "Copy region to clipboard using xclip." (interactive) @@ -66,7 +77,8 @@ version 2022-06-09" (message "Copied to clipboard")) (message "No region selected."))) - (global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard)) + (global-set-key (kbd "C-c C-w") 'my-cut-to-clipboard) + (global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard) ;; For example, set the default tab width to 4 spaces