From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Sacha Chua Newsgroups: gmane.emacs.devel Subject: [PATCH] xclip.el: Add support for termux-clipboard-get Date: Mon, 01 Jul 2019 20:25:21 -0400 Message-ID: <877e91cmfi.fsf@sachachua.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="254118"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 02 04:55:33 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hi8xB-0013wY-Ba for ged-emacs-devel@m.gmane.org; Tue, 02 Jul 2019 04:55:33 +0200 Original-Received: from localhost ([::1]:47610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi8x9-00087J-V0 for ged-emacs-devel@m.gmane.org; Mon, 01 Jul 2019 22:55:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56266) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6dm-0004Hr-QR for emacs-devel@gnu.org; Mon, 01 Jul 2019 20:27:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6dh-00025O-AS for emacs-devel@gnu.org; Mon, 01 Jul 2019 20:27:20 -0400 Original-Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:59008 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6dE-0001zL-Af for emacs-devel@gnu.org; Mon, 01 Jul 2019 20:27:16 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hi6bv-000sGg-To for emacs-devel@gnu.org; Tue, 02 Jul 2019 02:25:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:2qlJdNz465AYRDJf7Kif4l6KvvU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238279 Archived-At: --=-=-= Content-Type: text/plain I've been getting into using Emacs on my Android via Termux. This small patch adds support for termux-clipboard-get/set to the xclip.el ELPA package so that people can easily copy from Emacs to Android apps and vice versa by installing xclip and putting (xclip-mode 1) in their config. I have copyright assignment papers on file. I hope it's useful! Sacha --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-xclip.el-Add-support-for-termux-clipboard-get-set.patch >From aa55af6b72b112591287b98c9b55c29f24ac7216 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Mon, 1 Jul 2019 20:21:16 -0400 Subject: [PATCH] xclip.el: Add support for termux-clipboard-get/set * packages/xclip/xclip.el (xclip-method): Add termux-clipboard-get. (xclip-set-selection): Use termux-clipboard-set if specified. (xclip-get-selection): Use termux-clipboard-get if specified. --- packages/xclip/xclip.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el index 2c7be8c95..28c8327fa 100644 --- a/packages/xclip/xclip.el +++ b/packages/xclip/xclip.el @@ -32,6 +32,7 @@ ;; http://www.vergenet.net/~conrad/software/xsel/ respectively). ;; - MacOS: `pbpaste/pbcopy' ;; - Cygwin: `getclip/putclip' +;; - Termux: `termux-clipboard-get/termux-clipboard-set' ;; - Emacs: It can also use Emacs's built-in GUI support to talk to the GUI. ;; This requires an Emacs built with GUI support. ;; It uses `make-frame-on-display' which has been tested to work under X11, @@ -75,6 +76,7 @@ If non-nil `xclip-program' is ignored.") (and (executable-find "xclip") 'xclip) (and (executable-find "xsel") 'xsel) (and (executable-find "wl-copy") 'wl-copy) ;github.com/bugaevc/wl-clipboard + (and (executable-find "termux-clipboard-get") 'termux-clipboard-get) ;github.com/bugaevc/wl-clipboard (and (fboundp 'x-create-frame) (getenv "DISPLAY") 'emacs) 'xclip) "Method to use to access the GUI's clipboard. @@ -86,6 +88,7 @@ and `getclip' under Cygwin, or `emacs' to use Emacs's GUI code for that." (const :tag "X11: xclip" xclip) (const :tag "X11: xsel" xsel) (const :tag "Wayland: wl-copy" wl-copy) + (const :tag "Termux: termux-clipboard-get/termux-clipboard-set" termux-clipboard-get) (const :tag "X11: Emacs" emacs))) (defcustom xclip-program (symbol-name xclip-method) @@ -136,6 +139,12 @@ See also `x-set-selection'." (apply #'start-process "wl-copy" nil xclip-program (if (memq type '(primary PRIMARY)) '("-p"))))) + (`termux-clipboard-get + (start-process "termux-clipboard-set" nil + (replace-regexp-in-string + "\\(.*\\)termux-clipboard-get" + "\\1termux-clipboard-set" + xclip-program 'fixedcase))) (method (error "Unknown `xclip-method': %S" method))))) (when proc (process-send-string proc data) @@ -176,6 +185,8 @@ See also `x-set-selection'." xclip-program 'fixedcase) nil standard-output nil (if (memq type '(primary PRIMARY)) '("-p"))))) + (`termux-clipboard-get + (call-process xclip-program nil standard-output nil)) (method (error "Unknown `xclip-method': %S" method)))))) ;;;###autoload -- 2.17.1 --=-=-=--