[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 13/77: New command easy-kill-region to kill current selection
From: |
Leo Liu |
Subject: |
[elpa] 13/77: New command easy-kill-region to kill current selection |
Date: |
Sat, 05 Apr 2014 04:08:12 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit c00060c7c9c1c97d86bdeb4ed1cd97174a0500bb
Author: Leo Liu <address@hidden>
Date: Mon Oct 7 15:40:58 2013 +0800
New command easy-kill-region to kill current selection
---
easy-kill.el | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index 1a30d10..98a284c 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -47,6 +47,7 @@
(define-key map "-" 'easy-kill-shrink)
(define-key map "+" 'easy-kill-enlarge)
(define-key map "=" 'easy-kill-enlarge)
+ (define-key map "\C-w" 'easy-kill-region)
(mapc (lambda (d)
(define-key map (number-to-string d) 'easy-kill-digit-argument))
(number-sequence 0 9))
@@ -72,6 +73,9 @@
(error "`string-match' failed in `easy-kill-strip'")))
(t s)))
+(defvar easy-kill-exit nil
+ "If non-nil tells `set-temporary-overlay-map' to exit.")
+
(defvar easy-kill-candidate nil)
(defun easy-kill-candidate ()
@@ -136,6 +140,16 @@ candidate property instead."
?0)))
(easy-kill-thing (overlay-get easy-kill-candidate 'thing) n))
+(defun easy-kill-region ()
+ "Kill current selection and exit."
+ (interactive)
+ (let ((beg (overlay-start easy-kill-candidate))
+ (end (overlay-end easy-kill-candidate)))
+ (if (/= beg end)
+ (kill-region beg end)
+ (easy-kill-message-nolog "Region empty")))
+ (setq easy-kill-exit t))
+
(defun easy-kill-thing (thing &optional n inhibit-handler)
(interactive
(list (cdr (assoc (car (last (listify-key-sequence
@@ -163,15 +177,9 @@ candidate property instead."
(lambda ()
;; When any error happens the keymap is active forever.
(with-demoted-errors
- (or (let ((cmd (lookup-key map (this-command-keys))))
- (eq this-command
- (if (and (numberp cmd)
- universal-argument-num-events
- (> (length (this-command-keys))
- universal-argument-num-events))
- (lookup-key map (substring (this-command-keys)
-
universal-argument-num-events))
- cmd)))
+ (or (and (not (prog1 easy-kill-exit
+ (setq easy-kill-exit nil)))
+ (eq this-command (lookup-key map (this-command-keys))))
(when easy-kill-candidate
;; Do not modify the clipboard here because it will
;; intercept pasting from other programs and
- [elpa] 02/77: Fix error when interprogram-cut-function unset, (continued)
- [elpa] 02/77: Fix error when interprogram-cut-function unset, Leo Liu, 2014/04/05
- [elpa] 05/77: Call interprogram-cut-function in easy-kill-forward, Leo Liu, 2014/04/05
- [elpa] 01/77: Initial commit, Leo Liu, 2014/04/05
- [elpa] 07/77: Rename easy-kill-forward/backward to easy-kill-enlarge/shrink, Leo Liu, 2014/04/05
- [elpa] 08/77: Give overlay by easy-kill-candidate higher priority, Leo Liu, 2014/04/05
- [elpa] 06/77: Various bug fixes and improvements, Leo Liu, 2014/04/05
- [elpa] 09/77: Restore the ability to inspect char properties for URLs, Leo Liu, 2014/04/05
- [elpa] 04/77: Use overlay for storing kill candidate and change +/-, Leo Liu, 2014/04/05
- [elpa] 11/77: Minor tweaks to easy-kill-on-url, Leo Liu, 2014/04/05
- [elpa] 12/77: Tweak the definition of thing `region', Leo Liu, 2014/04/05
- [elpa] 13/77: New command easy-kill-region to kill current selection,
Leo Liu <=
- [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