From 21a76640ad257d8ae641bbfc329c0ece92eb1540 Mon Sep 17 00:00:00 2001 From: defanor Date: Mon, 25 Dec 2017 19:36:29 +0300 Subject: Add `pancake-uri-at-point' --- pancake.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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'.") -- cgit v1.2.3