- "See `x-cut-buffer-or-selection-value'."
- (when (and (executable-find xclip-program) (getenv "DISPLAY"))
- (let (clip-text primary-text)
- (when xclip-select-enable-clipboard
- (setq clip-text (shell-command-to-string
- (concat (shell-quote-argument xclip-program)
- " -o -selection clipboard")))
- (setq clip-text
- (cond ;; check clipboard selection
- ((or (not clip-text) (string= clip-text ""))
- (setq xclip-last-selected-text-primary 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)))))
- (setq primary-text (shell-command-to-string
- (concat (shell-quote-argument xclip-program) " -o")))
- (setq primary-text
- (cond ;; check primary selection
- ((or (not primary-text) (string= primary-text ""))
- (setq xclip-last-selected-text-primary nil))
- ((eq primary-text xclip-last-selected-text-primary) nil)
- ((string= primary-text xclip-last-selected-text-primary)
- ;; Record the newer string,
- ;; so subsequent calls can use the `eq' test.
- (setq xclip-last-selected-text-primary primary-text)
- nil)
- (t (setq xclip-last-selected-text-primary primary-text))))
- (or clip-text primary-text))))
+ "See `x-selection-value'."
+ (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
+ (when (and (not xclip-use-pbcopy&paste) (getenv "DISPLAY"))
+ (let ((primary-text (with-output-to-string
+ (process-file xclip-program nil
+ standard-output nil "-o"))))
+ (setq primary-text
+ (cond ; Check primary selection.
+ ((or (not primary-text) (string= primary-text ""))
+ (setq xclip-last-selected-text-primary nil))
+ ((eq primary-text xclip-last-selected-text-primary)
+ nil)
+ ((string= primary-text xclip-last-selected-text-primary)
+ ;; Record the newer string so subsequent calls can
+ ;; use the `eq' test.
+ (setq xclip-last-selected-text-primary primary-text)
+ nil)
+ (t (setq xclip-last-selected-text-primary primary-text))))
+ primary-text)))))