aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2020-02-14 22:46:45 +0100
committerGitHub <noreply@github.com>2020-02-14 22:46:45 +0100
commit4f84afbf888187dfe57b14f8a38159561e7684c9 (patch)
treed268da54fd940327ce334c494ab3f230d008dea5
parentffc2f419524054575141dfe3c8e8238452bc9239 (diff)
parent0d16b6b8100421011123313ecb11142b87a750eb (diff)
Merge pull request #47 from dov/feature-copy-url
Added function for copying the url under the cursor into the kill-ring.
-rw-r--r--nov.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/nov.el b/nov.el
index e4ace61..5736395 100644
--- a/nov.el
+++ b/nov.el
@@ -394,6 +394,7 @@ Each alist item consists of the identifier and full path."
(define-key map (kbd "l") 'nov-history-back)
(define-key map (kbd "r") 'nov-history-forward)
(define-key map (kbd "RET") 'nov-browse-url)
+ (define-key map (kbd "c") 'nov-copy-url)
(define-key map (kbd "<follow-link>") 'mouse-face)
(define-key map (kbd "<mouse-2>") 'nov-browse-url)
(define-key map (kbd "TAB") 'shr-next-link)
@@ -673,6 +674,15 @@ Internal URLs are visited with `nov-visit-relative-file'."
(browse-url url)
(apply 'nov-visit-relative-file (nov-url-filename-and-target url)))))
+(defun nov-copy-url (&optional mouse-event)
+ (interactive (list last-nonmenu-event))
+ (mouse-set-point mouse-event)
+ (let ((url (get-text-property (point) 'shr-url)))
+ (when (not url)
+ (user-error "No link under point"))
+ (kill-new url)
+ (message url)))
+
(defun nov-saved-places ()
"Retrieve saved places in `nov-save-place-file'."
(when (and nov-save-place-file (file-exists-p nov-save-place-file))