Clipboard integration

This commit is contained in:
Dita Aji Pratama 2024-11-18 11:32:41 +07:00
parent 629baa89b3
commit 9f3a05e500

20
init.el
View File

@ -82,6 +82,26 @@ version 2022-06-09"
;; Disable line numbers for Treemacs ;; Disable line numbers for Treemacs
(add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0))) (add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0)))
;; Clipboard integration (Not work in terminal)
(setq select-enable-clipboard t)
(setq select-enable-primary t)
;; Clipboard integration for terminal (Need xclip)
(when (not (display-graphic-p)) ;; Check if Emacs is running in the terminal
(defun my-copy-to-clipboard ()
"Copy 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"))
(message "Copied to clipboard"))
(message "No region selected.")))
(global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard))
;; For example, set the default tab width to 4 spaces ;; For example, set the default tab width to 4 spaces
(setq-default tab-width 4) (setq-default tab-width 4)
;; For Python mode, set the indentation style ;; For Python mode, set the indentation style