unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] xclip.el: Add support for termux-clipboard-get
@ 2019-07-02  0:25 Sacha Chua
  2019-07-02  4:48 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Sacha Chua @ 2019-07-02  0:25 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-xclip.el-Add-support-for-termux-clipboard-get-set.patch --]
[-- Type: text/x-diff, Size: 3039 bytes --]

From aa55af6b72b112591287b98c9b55c29f24ac7216 Mon Sep 17 00:00:00 2001
From: Sacha Chua <sacha@sachachua.com>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xclip.el: Add support for termux-clipboard-get
  2019-07-02  0:25 [PATCH] xclip.el: Add support for termux-clipboard-get Sacha Chua
@ 2019-07-02  4:48 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2019-07-02  4:48 UTC (permalink / raw)
  To: emacs-devel

> 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.

Thanks, installed.  Should appear in xclip-1.9 in a few hours.


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-02  4:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-02  0:25 [PATCH] xclip.el: Add support for termux-clipboard-get Sacha Chua
2019-07-02  4:48 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).