[elpa] master cd1280d: Brief mode: merge Stefan's patch and revised some legacy code.

2018-08-23 Thread Luke Lee
branch: master
commit cd1280d0f18ada3b58a2dd2a971db3d4b1a213b3
Author: Luke Lee 
Commit: Luke Lee 

Brief mode: merge Stefan's patch and revised some legacy code.

* packages/brief/brief.el: coding style fix, revise legacy code and
variables, and backward compatibility fix for Emacs v23 and v24.
---
 packages/brief/brief.el | 758 +---
 1 file changed, 388 insertions(+), 370 deletions(-)

diff --git a/packages/brief/brief.el b/packages/brief/brief.el
index 0100852..a7a1710 100644
--- a/packages/brief/brief.el
+++ b/packages/brief/brief.el
@@ -5,7 +5,7 @@
 ;; Author: Luke Lee 
 ;; Maintainer: Luke Lee 
 ;; Keywords:   brief, emulations, crisp
-;; Version:5.83
+;; Version:5.84
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -412,7 +412,7 @@
 ;; backward compatibility issues.
 ;;(require 'replace)
 
-(defconst brief-version "5.83"
+(defconst brief-version "5.84"
   "The version of this Brief emulator.")
 
 ;;
@@ -685,28 +685,21 @@ Also, under terminal mode it can't actually get the 
slowdown."
   ;;   * Rectangle active:   mouse-track-rectangle-p = t   and mark-active = t
   `cua--rectangle)
 
-(eval-when (compile load eval)
-  (if (version< emacs-version "24.0")
-  ;; for Emacs23, rectangle won't activate region
-  (defmacro brief-use-region ()
-"In Brief this means either a line region or rectangle is active."
-`(or (ignore-errors
-   ;; In Emacs23 sometimes this will invoke (region-end) and cause
-   ;; error: "The mark is not set now, so there is no region"
-   (use-region-p))
- (brief-rectangle-active)))
-(defmacro brief-use-region ()
-  "In Brief this means either a line region or rectangle is active."
-  `(or (use-region-p)
-   ;; [2018-02-01 Thu] If we don't include `brief-rectangle-active'
-   ;; here, on some rare cases the `use-region-p' will return NIL
-   ;; while `brief-rectangle-active' remains non-NIL.  For example, it
-   ;; once happened when: (1) marking a rectangle (2) use 
self-inserting
-   ;; commands (3) undo -- at this moment the rectangle will disappear
-   ;; and `deactivate-mark-hook' will be executed.  During this period
-   ;; of time, any function in the hook will experience `use-region-p'
-   ;; be NIL while `brief-rectangle-active' be non-NIL.
-   (brief-rectangle-active)
+(defun brief-use-region ()
+  "In Brief this means either a line region or rectangle is active."
+  (or (ignore-errors
+;; In Emacs<24 sometimes this will invoke `region-end' and cause
+;; error: "The mark is not set now, so there is no region"
+(use-region-p))
+  ;; [2018-02-01 Thu] If we don't include `brief-rectangle-active'
+  ;; here, in some rare cases the `use-region-p' will return NIL
+  ;; while `brief-rectangle-active' remains non-NIL.  For example, it
+  ;; once happened when: (1) marking a rectangle (2) use self-inserting
+  ;; commands (3) undo -- at this moment the rectangle will disappear
+  ;; and `deactivate-mark-hook' will be executed.  During this period
+  ;; of time, any function in the hook will experienced `use-region-p'
+  ;; be NIL while `brief-rectangle-active' be non-NIL.
+  (brief-rectangle-active)))
 
 (defun brief-region-beginning ()
   "Safe version of `region-beginning' to prevent error signaling."
@@ -1044,7 +1037,7 @@ Xclipboard."
  ;; Forward reference to brief-in-favor-of-xsel, if
  ;; not yet defined, use its default
  (xc(if (or (and (boundp 'brief-in-favor-of-xsel)
- (eval 'brief-in-favor-of-xsel))
+ brief-in-favor-of-xsel)
 brief-in-favor-of-xsel-default)
 (or xsel xclip)
   (or xclip xsel
@@ -1246,7 +1239,7 @@ slowdown factor; otherwise, return 1.0."
 (defvar brief-query-replace-last nil)
 
 [2011-04-14 Thu 13:53] rem 1
-;;(defvar brief-global-case-fold-search nil)  default nil : case-sensitive
+;;(defvar brief-global-case-fold-search nil) ;; default nil : case-sensitive
 (defvar brief-get-current-word nil)
 (defvar brief-search-history nil)
 
@@ -1392,9 +1385,9 @@ modified."
   (forward-char 1))
   (point))
 
-(defun brief-rectangle-mode (arg)
+(defun brief-rectangle-mode ()
   "Start marking rectangle region."
-  (interactive "p")
+  (interactive)
   ;; TODO: support native rectangle mode
   (cua-set-rectangle-mark))
 
@@ -1628,11 +1621,11 @@ example, add the following into .emacs:
   (point-to-register temp2)))
 (unless
 ;; (equal marker1 marker2)  ;; Do not overwrite REG we're
-;;; bookmarking the same position
+;

[elpa] master b6aee5c: * xclip/xclip.el: Add support for `xsel` and Cygwin's `getclip`

2018-08-23 Thread Stefan Monnier
branch: master
commit b6aee5c820cc98d2714d611d3f927e6040105e66
Author: Stefan Monnier 
Commit: Stefan Monnier 

* xclip/xclip.el: Add support for `xsel` and Cygwin's `getclip`

Move Emacs<25 code to the end.
(xclip): New group.
(xclip-program): Change default to depend on
xclip-use-pbcopy&paste.  Move accordingly.
(xclip-select-enable-clipboard): Mark as obsolete.
(xclip-use-pbcopy&paste): Make it into a defvar.  Mark as obsolete.
(xclip-method): New defcustom.
(xclip-set-selection, xclip-get-selection): Use it.
(xclip-mode): Simplify.
---
 packages/xclip/xclip.el | 234 ++--
 1 file changed, 146 insertions(+), 88 deletions(-)

diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el
index 992fd9b..2b8f97c 100644
--- a/packages/xclip/xclip.el
+++ b/packages/xclip/xclip.el
@@ -1,6 +1,6 @@
-;;; xclip.el --- use xclip to copy&paste -*- lexical-binding: t; 
-*-
+;;; xclip.el --- Copy&paste GUI clipboard from text terminal  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2007, 2012, 2013, 2017  Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2012, 2013, 2017, 2018  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu 
 ;; Keywords: convenience, tools
@@ -22,39 +22,58 @@
 
 ;;; Commentary:
 
-;; This package allows Emacs to copy to and paste from the X clipboard
-;; when running in xterm.  It uses the external command-line tool xclip
-;; found on http://xclip.sourceforge.net.
+;; This package allows Emacs to copy to and paste from the GUI clipboard
+;; when running in text terminal.
 ;;
-;; To use: (xclip-mode 1)
+;; It relies on external command-line tools for that, which you may need
+;; to install in order for the package to work.
+;; More specifically, it can use the following tools:
+;; - Under X11: `xclip' or `xsel' (http://xclip.sourceforge.net and
+;;   http://www.vergenet.net/~conrad/software/xsel/ respectively).
+;; - MacOS: `pbpaste/pbcopy'
+;; - Cygwin: `getclip/putclip'
+;;
+;; To use, just add (xclip-mode 1) to your ~/.emacs or do `M-x clip-mode'
+;; after which the usual kill/yank commands will use the GUI selections
+;; according to `select-enable-clipboard/primary'.
 
 ;;; Code:
 
-(defcustom xclip-program "xclip"
-  "Name of the xclip program."
-  :type 'string
+(defgroup xclip ()
+  "Copy&paste GUI clipboard from text terminal."
   :group 'killing)
 
 (defcustom xclip-select-enable-clipboard t
   "Non-nil means cutting and pasting uses the clipboard.
 This is in addition to, but in preference to, the primary selection."
-  :type 'boolean
-  :group 'killing)
+  :type 'boolean)
+(make-obsolete 'xclip-select-enable-clipboard
+   'select-enable-clipboard "Emacs-25")
 
-(defcustom xclip-use-pbcopy&paste (and xclip-select-enable-clipboard
-   (eq system-type 'darwin)
-   (executable-find "pbcopy")
-   t)
+(defvar xclip-use-pbcopy&paste (and (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.")
-
-(defvar xclip-last-selected-text-primary nil
-  "The value of the PRIMARY X selection from xclip.")
+If non-nil `xclip-program' is ignored.")
+(make-obsolete 'xclip-use-pbcopy&paste 'xclip-method "xclip-1.5")
+
+(defcustom xclip-method
+   (if xclip-use-pbcopy&paste 'pbpaste
+ (or
+  (and (executable-find "xclip") 'xclip)
+  (and (executable-find "xsel") 'xsel)
+  (and (eq system-type 'cygwin) (executable-find "getclip") 'getclip)
+  'xclip))
+  "Method to use to access the GUI's clipboard.
+Can be one of `pbpaste' for MacOS, `xclip' or `xsel' for X11,
+and `getclip' under Cygwin."
+  :type '(choice
+  (const :tag "MacOS: pbcopy/pbpaste" pbpaste)
+  (const :tag "X11: xclip" xclip)))
+
+(defcustom xclip-program (symbol-name xclip-method)
+  "Name of the clipboard access command."
+  :type 'string)
 
  Core functions.
 
@@ -63,12 +82,33 @@ If non-nil `xclip-program' is ignored."
 
 See also `x-set-selection'."
   (let* ((process-connection-type nil)
- (proc (cond
-((and xclip-use-pbcopy&paste (memq type '(clipboard 
CLIPBOARD)))
- (start-file-process "pbcopy" nil "pbcopy"))
-((getenv "DISPLAY")
- (start-file-process "xclip" nil xclip-program
- "-selection" (symbol-name type))
+ (proc
+  (pcase xclip-method
+('pbpaste
+ (when (memq type '(clipboard CLIPBOARD))
+   (start-file-process
+"pbcopy" nil
+(replace-regexp-in-string "\\(.*\\)p