[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 09/77: Restore the ability to inspect char properties for URLs
From: |
Leo Liu |
Subject: |
[elpa] 09/77: Restore the ability to inspect char properties for URLs |
Date: |
Sat, 05 Apr 2014 04:08:11 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit ce53c47e331d699bf2bf642157c28322e01733af
Author: Leo Liu <address@hidden>
Date: Sun Oct 6 23:05:09 2013 +0800
Restore the ability to inspect char properties for URLs
with new function easy-kill-on-url.
---
easy-kill.el | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index 453225d..1b3f94b 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -125,7 +125,7 @@ Otherwise, it is the value of the overlay's candidate
property."
?0)))
(easy-kill-thing (overlay-get easy-kill-candidate 'thing) n))
-(defun easy-kill-thing (thing &optional n)
+(defun easy-kill-thing (thing &optional n inhibit-handler)
(interactive
(list (cdr (assoc (car (last (listify-key-sequence
(single-key-description last-command-event))))
@@ -135,7 +135,8 @@ Otherwise, it is the value of the overlay's candidate
property."
(if (and thing
(let ((n (or n 1)))
(cond
- ((intern-soft (format "easy-kill-on-%s" thing))
+ ((and (not inhibit-handler)
+ (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-enlarge n))
@@ -202,6 +203,9 @@ Otherwise, it is the value of the overlay's candidate
property."
(lambda () (cons (region-beginning) (region-end))))
(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."
(let ((file (or buffer-file-name default-directory)))
(when file
(move-overlay easy-kill-candidate (point) (point))
@@ -217,5 +221,31 @@ Otherwise, it is the value of the overlay's candidate
property."
(put 'buffer-file-name 'easy-kill-enlarge 'easy-kill-on-buffer-file-name)
+(defun easy-kill-on-url (&optional _n)
+ "Get url at point or from char properties.
+Char properties `help-echo', `shr-url' and `w3m-href-anchor' are
+inspected."
+ (if (bounds-of-thing-at-point 'url)
+ (easy-kill-thing 'url nil t)
+ (let* ((get-url (lambda (text)
+ (when (stringp text)
+ (with-temp-buffer
+ (insert text)
+ (and (bounds-of-thing-at-point 'url)
+ (thing-at-point 'url))))))
+ (url (dolist (p '(help-echo shr-url w3m-href-anchor))
+ (pcase-let* ((`(,text . ,ov)
+ (get-char-property-and-overlay (point) p))
+ (u (or (funcall get-url text)
+ (funcall get-url
+ (and ov (overlay-get ov p))))))
+ (and u (return u))))))
+ (when url
+ (move-overlay easy-kill-candidate (point) (point))
+ (overlay-put easy-kill-candidate 'thing 'url)
+ (overlay-put easy-kill-candidate 'candidate url)
+ (easy-kill-message-nolog "%s" url)
+ t))))
+
(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, 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 <=
- [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
- [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