[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 07/77: Rename easy-kill-forward/backward to easy-kill-enlarge/shr
From: |
Leo Liu |
Subject: |
[elpa] 07/77: Rename easy-kill-forward/backward to easy-kill-enlarge/shrink |
Date: |
Sat, 05 Apr 2014 04:08:10 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 079a04dd8e65edf22c3fa6c4cccba0457d4dd016
Author: Leo Liu <address@hidden>
Date: Sun Oct 6 17:54:07 2013 +0800
Rename easy-kill-forward/backward to easy-kill-enlarge/shrink
and make them extensible via property easy-kill-enlarge.
---
easy-kill.el | 77 +++++++++++++++++++++++++++++++--------------------------
1 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index cf853d2..de01e73 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -44,8 +44,8 @@
(defun easy-kill-map ()
(let ((map (make-sparse-keymap)))
- (define-key map "-" 'easy-kill-backward)
- (define-key map "+" 'easy-kill-forward)
+ (define-key map "-" 'easy-kill-shrink)
+ (define-key map "+" 'easy-kill-enlarge)
(mapc (lambda (d)
(define-key map (number-to-string d) 'easy-kill-digit-argument))
(number-sequence 0 9))
@@ -84,29 +84,32 @@
(and interprogram-cut-function
(funcall interprogram-cut-function (easy-kill-candidate))))
-(defun easy-kill-forward (n)
+(defun easy-kill-enlarge (n)
(interactive "p")
- (let ((direction (if (minusp n) -1 +1))
- (thing (overlay-get easy-kill-candidate 'thing))
- (start (overlay-start easy-kill-candidate))
- (end (overlay-end easy-kill-candidate)))
+ (let ((thing (overlay-get easy-kill-candidate 'thing)))
(when thing
- (save-excursion
- (goto-char end)
- (with-demoted-errors
- (dotimes (_ (abs n))
- (forward-thing thing direction)
- (when (<= (point) start)
- (forward-thing thing 1)
- (return))))
- (when (/= end (point))
- (move-overlay easy-kill-candidate start (point))
- (easy-kill-select-text)
- t)))))
-
-(defun easy-kill-backward (n)
+ (if (get thing 'easy-kill-enlarge)
+ (funcall (get thing 'easy-kill-enlarge) n)
+ (let ((direction (if (minusp n) -1 +1))
+ (start (overlay-start easy-kill-candidate))
+ (end (overlay-end easy-kill-candidate)))
+ (when thing
+ (save-excursion
+ (goto-char end)
+ (with-demoted-errors
+ (dotimes (_ (abs n))
+ (forward-thing thing direction)
+ (when (<= (point) start)
+ (forward-thing thing 1)
+ (return))))
+ (when (/= end (point))
+ (move-overlay easy-kill-candidate start (point))
+ (easy-kill-select-text)
+ t))))))))
+
+(defun easy-kill-shrink (n)
(interactive "p")
- (easy-kill-forward (- n)))
+ (easy-kill-enlarge (- n)))
(defun easy-kill-digit-argument (&optional n)
(interactive
@@ -130,12 +133,12 @@
((intern-soft (format "easy-kill-on-%s" thing))
(funcall (intern-soft (format "easy-kill-on-%s" thing)) n))
((eq thing (overlay-get easy-kill-candidate 'thing))
- (easy-kill-forward n))
+ (easy-kill-enlarge n))
(t (let ((bounds (bounds-of-thing-at-point thing)))
(when bounds
(move-overlay easy-kill-candidate (car bounds) (cdr
bounds))
(overlay-put easy-kill-candidate 'thing thing)
- (easy-kill-forward (1- n))
+ (easy-kill-enlarge (1- n))
t))))))
(progn
(easy-kill-select-text)
@@ -190,17 +193,21 @@
(lambda () (cons (region-beginning) (region-end))))
(defun easy-kill-on-buffer-file-name (n)
- (when (or buffer-file-name default-directory)
- (move-overlay easy-kill-candidate (point) (point))
- (overlay-put easy-kill-candidate 'thing 'buffer-file-name)
- (let* ((file (or buffer-file-name default-directory))
- (text (and file (if (zerop n)
- (file-name-nondirectory
- (directory-file-name file))
- (directory-file-name file)))))
- (overlay-put easy-kill-candidate 'candidate text)
- (easy-kill-message-nolog "%s" text))
- t))
+ (let ((file (or buffer-file-name default-directory)))
+ (when file
+ (move-overlay easy-kill-candidate (point) (point))
+ (overlay-put easy-kill-candidate 'thing 'buffer-file-name)
+ (let* ((file (directory-file-name file))
+ (text (cond
+ ((zerop n) (file-name-nondirectory file))
+ ((plusp n) file)
+ (t (file-name-directory file)))))
+ (overlay-put easy-kill-candidate 'candidate text)
+ (easy-kill-message-nolog "%s" text))
+ t)))
+
+(put 'buffer-file-name 'easy-kill-enlarge
+ 'easy-kill-on-buffer-file-name)
(provide 'easy-kill)
;;; easy-kill.el ends here
- [elpa] branch master updated (769f2f2 -> 0a73626), Leo Liu, 2014/04/05
- [elpa] 03/77: Fix error: wrong-type-argument number-or-marker-p nil, Leo Liu, 2014/04/05
- [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 <=
- [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, 2014/04/05
- [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