summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-25 19:36:29 +0300
committerdefanor <defanor@uberspace.net>2017-12-25 19:36:29 +0300
commit21a76640ad257d8ae641bbfc329c0ece92eb1540 (patch)
tree2b1af531701df1271dc693b17ec3725464e5ccd8
parentb627b6b13cf860df11efc8d1b0df75ed129f361a (diff)
Add `pancake-uri-at-point'
-rw-r--r--pancake.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/pancake.el b/pancake.el
index e2f2855..e759cb1 100644
--- a/pancake.el
+++ b/pancake.el
@@ -198,6 +198,18 @@ while avoiding code duplication."
"-"
(symbol-name attr))))
+(defun pancake-uri-at-point (&optional print-uri)
+ "Returns an absolute URI at point. Prints it when called
+interactively."
+ (interactive "p")
+ (let* ((button (button-at (point)))
+ (uri (and button (button-get button 'pancake-absolute-uri))))
+ (when print-uri
+ (if uri
+ (message "%s" uri)
+ (message "No URI found at point.")))
+ uri))
+
(defun pancake-button-action (button)
"An action to be invoked on button activation."
(funcall 'browse-url (button-get button 'pancake-absolute-uri)))
@@ -506,6 +518,7 @@ it to `pancake-process' as input."
(define-key map (kbd "Q") 'pancake-quit)
(define-key map (kbd "R") 'pancake-reload)
(define-key map (kbd "I") 'pancake-load-images)
+ (define-key map (kbd "U") 'pancake-uri-at-point)
map)
"Keymap for `pancake-mode'.")