[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 21/77: New command easy-kill-mark-region
From: |
Leo Liu |
Subject: |
[elpa] 21/77: New command easy-kill-mark-region |
Date: |
Sat, 05 Apr 2014 04:08:14 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 2dfdf705005169f20fe7632519c981cdc1870ea9
Author: Leo Liu <address@hidden>
Date: Tue Oct 8 18:42:51 2013 +0800
New command easy-kill-mark-region
---
README.rst | 2 ++
easy-kill.el | 22 +++++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/README.rst b/README.rst
index 7ae3f96..8579e4e 100644
--- a/README.rst
+++ b/README.rst
@@ -22,6 +22,8 @@ Keys (customisable) immediately following ``M-w``:
#. ``b`` -> ``buffer-file-name`` or ``default-directory``
#. ``C-w`` -> kill current region
#. ``+``, ``-`` and ``0..9`` -> expand/shrink selection
+#. address@hidden or ``C-SPC`` -> turn current selection into an active
+ region
The following `screenshot <http://i.imgur.com/8TNgPly.png>`_ shows
``M-w l`` in action:
diff --git a/easy-kill.el b/easy-kill.el
index 59554d9..48319d6 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -51,6 +51,8 @@ CHAR is used immediately following `easy-kill' to select
THING."
(define-key map "+" 'easy-kill-expand)
(define-key map "=" 'easy-kill-expand)
(define-key map "\C-w" 'easy-kill-region)
+ (define-key map (kbd "C-SPC") 'easy-kill-mark-region)
+ (define-key map (kbd "C-@") 'easy-kill-mark-region)
(mapc (lambda (d)
(define-key map (number-to-string d) 'easy-kill-digit-argument))
(number-sequence 0 9))
@@ -180,8 +182,21 @@ candidate property instead."
(if (= beg end)
(easy-kill-message-nolog "Empty region")
(setq easy-kill-exit t)
+ (easy-kill-adjust-candidate nil "")
(kill-region beg end))))
+(defun easy-kill-mark-region ()
+ (interactive)
+ (let ((beg (overlay-start easy-kill-candidate))
+ (end (overlay-end easy-kill-candidate)))
+ (if (= beg end)
+ (easy-kill-message-nolog "Empty region")
+ (setq easy-kill-exit t)
+ (easy-kill-adjust-candidate nil "")
+ (set-mark beg)
+ (goto-char end)
+ (activate-mark))))
+
(defun easy-kill-activate-keymap ()
(let ((map (easy-kill-map)))
(set-temporary-overlay-map
@@ -191,7 +206,7 @@ candidate property instead."
(with-demoted-errors
(or (and (not (prog1 easy-kill-exit
(setq easy-kill-exit nil)))
- (eq this-command (lookup-key map (this-command-keys))))
+ (eq this-command (lookup-key map
(this-command-keys-vector))))
(when easy-kill-candidate
;; Do not modify the clipboard here because it will
;; intercept pasting from other programs and
@@ -213,6 +228,7 @@ Temporally activate additional key bindings as follows:
0..9 => expand current selection by that number;
+,=/- => expand or shrink current selection by 1;
C-w => kill current selection;
+ C-SPC => turn current selection into active region
others => save current selection to kill ring and exit."
(interactive "p")
(setq easy-kill-candidate
@@ -240,8 +256,8 @@ Temporally activate additional key bindings as follows:
(defun easy-kill-on-buffer-file-name (n)
"Get `buffer-file-name' or `default-directory'.
-If N is zero, remove the directory part; negative, remove the
-file name party; positive, full path."
+If N is zero, remove the directory part; -, remove the file name
+party; +, full path."
(let ((file (or buffer-file-name default-directory)))
(when file
(let* ((file (directory-file-name file))
- [elpa] 10/77: New function easy-kill-adjust-candidate and doc fix, (continued)
- [elpa] 10/77: New function easy-kill-adjust-candidate and doc fix, Leo Liu, 2014/04/05
- [elpa] 16/77: Make function easy-kill-candidate always return string, Leo Liu, 2014/04/05
- [elpa] 17/77: Fix error: (args-out-of-range 1009 1035), Leo Liu, 2014/04/05
- [elpa] 15/77: Some string and comment fixes, Leo Liu, 2014/04/05
- [elpa] 23/77: Use parse-partial-sexp in easy-kill-bounds-of-list, Leo Liu, 2014/04/05
- [elpa] 20/77: Replace `enlarge' with `expand' in strings and comments, Leo Liu, 2014/04/05
- [elpa] 19/77: Add lispy treatment for +/- on list and sexp, Leo Liu, 2014/04/05
- [elpa] 14/77: Doc fix and release v0.7.0, Leo Liu, 2014/04/05
- [elpa] 22/77: Handle the case when overlay has already been destroyed, Leo Liu, 2014/04/05
- [elpa] 25/77: Fix thinko in easy-kill-backward-down, Leo Liu, 2014/04/05
- [elpa] 21/77: New command easy-kill-mark-region,
Leo Liu <=
- [elpa] 24/77: Improve list expand/shrink support in smie-based modes, Leo Liu, 2014/04/05
- [elpa] 18/77: Consolidate all kill features in easy-kill-thing, Leo Liu, 2014/04/05
- [elpa] 26/77: Fix #2: just call kill-ring-save when region is active, Leo Liu, 2014/04/05
- [elpa] 27/77: Declare dependency on emacs 24, Leo Liu, 2014/04/05
- [elpa] 29/77: Merge pull request #4 from purcell/patch-1, Leo Liu, 2014/04/05
- [elpa] 31/77: Simplify the interactive form of easy-kill-thing, Leo Liu, 2014/04/05
- [elpa] 28/77: [remap kill-ring-save] should be a better key binding for this feature., Leo Liu, 2014/04/05
- [elpa] 35/77: Doc fix and release v0.8.0, Leo Liu, 2014/04/05
- [elpa] 36/77: New variable easy-kill-base-map for customising key bindings, Leo Liu, 2014/04/05
- [elpa] 33/77: Support append kill for append-next-kill and easy-kill, Leo Liu, 2014/04/05