Add c binding to the Elpher menu
[elpher.git] / elpher.el
index fbcad2b..67eb790 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -2045,6 +2045,7 @@ With an optional argument, add all the history items, too."
     (define-key map "\C-m" 'elpher-menu-this-window)
     (define-key map "o" 'elpher-menu-other-window)
     (define-key map "\C-o" 'elpher-menu-switch-other-window)
+    (define-key map "c" 'elpher-menu-copy-current-url)
     (define-key map "d" 'Buffer-menu-delete)
     (define-key map "k" 'Buffer-menu-delete)
     (define-key map "\C-k" 'Buffer-menu-delete)
@@ -2188,6 +2189,23 @@ and apply FUNC to ARGS."
          (t
           (error "There's no entry on this line of the menu")))))
 
+(defun elpher-menu-copy-current-url ()
+  "Copy the URL of the current menu item."
+  (interactive)
+  (let ((data (tabulated-list-get-id)))
+    (cond ((bufferp data)
+          (with-current-buffer data
+            (elpher-copy-page-url elpher-current-page)))
+         ((listp data)
+          (elpher-copy-page-url (nth 2 data)))
+         (t
+          (error "There's no entry on this line of the menu")))))
+
+  (defun elpher-copy-current-url ()
+  "Copy URL of current page to `kill-ring'."
+  (interactive)
+  (elpher-copy-page-url elpher-current-page))
+
 (defvar elpher-title nil)
 
 (defun elpher-find-title ()