emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA-diffs] ELPA branch, master, updated. f160382d9dd3acb36f562e82993e0


From: Leo Liu
Subject: [ELPA-diffs] ELPA branch, master, updated. f160382d9dd3acb36f562e82993e07765411c354
Date: Fri, 06 Sep 2013 04:39:02 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "ELPA".

The branch, master has been updated
       via  f160382d9dd3acb36f562e82993e07765411c354 (commit)
      from  afa778dbeac52aed1d1c57a9daadd2eea204bb56 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f160382d9dd3acb36f562e82993e07765411c354
Author: Leo Liu <address@hidden>
Date:   Fri Sep 6 12:32:20 2013 +0800

    * xclip.el: Use pbcopy and pbpaste if available
    
    (xclip-use-pbcopy&paste): New variable.
    (xclip-set-selection, xclip-selection-value, xclip-mode): Use it.

diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el
index d08dcd2..bc9b640 100644
--- a/packages/xclip/xclip.el
+++ b/packages/xclip/xclip.el
@@ -5,7 +5,7 @@
 ;; Author: Leo Liu <address@hidden>
 ;; Keywords: convenience, tools
 ;; Created: 2007-12-30
-;; Version: 1.1
+;; Version: 1.2
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -41,6 +41,15 @@ This is in addition to, but in preference to, the primary 
selection."
   :type 'boolean
   :group 'killing)
 
+(defcustom xclip-use-pbcopy&paste (and xclip-select-enable-clipboard
+                                       (eq system-type 'darwin)
+                                       (executable-find "pbcopy")
+                                       t)
+  "Non-nil means using pbcopy and pbpaste instead of xclip.
+If non-nil `xclip-program' is ignored."
+  :type 'boolean
+  :group 'killing)
+
 (defvar xclip-last-selected-text-clipboard nil
   "The value of the CLIPBOARD X selection from xclip.")
 
@@ -51,12 +60,17 @@ This is in addition to, but in preference to, the primary 
selection."
   "TYPE is a symbol: primary, secondary and clipboard.
 
 See also `x-set-selection'."
-  (when (getenv "DISPLAY")
-    (let* ((process-connection-type nil)
-           (proc (start-process "xclip" nil xclip-program
-                                "-selection" (symbol-name type))))
+  (let* ((process-connection-type nil)
+         (proc (cond
+                (xclip-use-pbcopy&paste
+                 (start-file-process "pbcopy" nil "pbcopy"))
+                ((getenv "DISPLAY")
+                 (start-file-process "xclip" nil xclip-program
+                                     "-selection" (symbol-name type))))))
+    (when proc
       (process-send-string proc data)
-      (process-send-eof proc))))
+      (process-send-eof proc))
+    data))
 
 (defun xclip-select-text (text)
   "See `x-select-text'."
@@ -68,24 +82,28 @@ See also `x-set-selection'."
 
 (defun xclip-selection-value ()
   "See `x-selection-value'."
-  (when (getenv "DISPLAY")
-    (let ((clip-text (when xclip-select-enable-clipboard
-                       (with-output-to-string
+  (let ((clip-text (when xclip-select-enable-clipboard
+                     (with-output-to-string
+                       (cond
+                        (xclip-use-pbcopy&paste
+                         (process-file "pbpaste" nil standard-output nil))
+                        ((getenv "DISPLAY")
                          (process-file xclip-program nil standard-output nil
-                                       "-o" "-selection" "clipboard")))))
-      (setq clip-text
-            (cond                       ; Check clipboard selection.
-             ((or (not clip-text) (string= clip-text ""))
-              (setq xclip-last-selected-text-clipboard nil))
-             ((eq clip-text xclip-last-selected-text-clipboard)
-              nil)
-             ((string= clip-text xclip-last-selected-text-clipboard)
-              ;; Record the newer string so subsequent calls can use
-              ;; the `eq' test.
-              (setq xclip-last-selected-text-clipboard clip-text)
-              nil)
-             (t (setq xclip-last-selected-text-clipboard clip-text))))
-      (or clip-text
+                                       "-o" "-selection" "clipboard")))))))
+    (setq clip-text
+          (cond                         ; Check clipboard selection.
+           ((or (not clip-text) (string= clip-text ""))
+            (setq xclip-last-selected-text-clipboard nil))
+           ((eq clip-text xclip-last-selected-text-clipboard)
+            nil)
+           ((string= clip-text xclip-last-selected-text-clipboard)
+            ;; Record the newer string so subsequent calls can use the
+            ;; `eq' test.
+            (setq xclip-last-selected-text-clipboard clip-text)
+            nil)
+           (t (setq xclip-last-selected-text-clipboard clip-text))))
+    (or clip-text
+        (when (getenv "DISPLAY")
           (let ((primary-text (with-output-to-string
                                 (process-file xclip-program nil
                                               standard-output nil "-o"))))
@@ -113,9 +131,11 @@ See also `x-set-selection'."
   :global t
   (if xclip-mode
       (progn
-        (or (executable-find xclip-program)
+        (or xclip-use-pbcopy&paste
+            (executable-find xclip-program)
             (signal 'file-error (list "Searching for program"
                                       xclip-program "no such file")))
+        ;; NOTE: See `tty-run-terminal-initialization' and term/README
         (add-hook 'terminal-init-xterm-hook 'turn-on-xclip))
     (remove-hook 'terminal-init-xterm-hook 'turn-on-xclip)))
 

-----------------------------------------------------------------------

Summary of changes:
 packages/xclip/xclip.el |   68 ++++++++++++++++++++++++++++++----------------
 1 files changed, 44 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
ELPA



reply via email to

[Prev in Thread] Current Thread [Next in Thread]