emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/devdocs 3c03678 1/2: Add devdocs-copy-url command


From: ELPA Syncer
Subject: [elpa] externals/devdocs 3c03678 1/2: Add devdocs-copy-url command
Date: Sat, 2 Oct 2021 13:57:16 -0400 (EDT)

branch: externals/devdocs
commit 3c0367860771926cd68d892749d725be75a53c00
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Add devdocs-copy-url command
    
    Closes #5
---
 devdocs.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/devdocs.el b/devdocs.el
index 1baa003..a88651b 100644
--- a/devdocs.el
+++ b/devdocs.el
@@ -333,6 +333,21 @@ with the order of appearance in the text."
   (interactive "p")
   (devdocs-next-page (- count)))
 
+(defun devdocs-copy-url ()
+  "Copy the URL of the current DevDocs page to the kill ring."
+  (interactive)
+  (let-alist (or (car devdocs--stack)
+                 (user-error "Not in a DevDocs buffer"))
+    (let ((url (url-encode-url
+                (format "%s/%s/%s"
+                        devdocs-site-url
+                        .doc.slug
+                        (if .fragment
+                            (concat (devdocs--path-file .path) "#" .fragment)
+                          .path)))))
+      (kill-new url)
+      (message "Copied %s" url))))
+
 (let ((map devdocs-mode-map))
   (define-key map [tab] 'forward-button)
   (define-key map [backtab] 'backward-button)
@@ -343,6 +358,7 @@ with the order of appearance in the text."
   (define-key map "]" 'devdocs-next-page)
   (define-key map "l" 'devdocs-go-back)
   (define-key map "r" 'devdocs-go-forward)
+  (define-key map "w" 'devdocs-copy-url)
   (define-key map "." 'devdocs-goto-target))
 
 ;;; Rendering



reply via email to

[Prev in Thread] Current Thread [Next in Thread]