summaryrefslogtreecommitdiffhomepage
path: root/lib/doc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-07 04:31:09 +0100
committerjao <jao@gnu.org>2021-04-07 04:31:09 +0100
commitf67bb416dabaef9d9c5262d37dc36afd481a7bab (patch)
tree2f830528ae1479ba959bdd7bc927fa3a6fd45a90 /lib/doc
parent984bff80c7dbe96e06cb3bd7ff90f1adfaca8ea5 (diff)
downloadelibs-f67bb416dabaef9d9c5262d37dc36afd481a7bab.tar.gz
elibs-f67bb416dabaef9d9c5262d37dc36afd481a7bab.tar.bz2
jao-doc-view-visit-url
Diffstat (limited to 'lib/doc')
-rw-r--r--lib/doc/jao-doc-view.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el
index 762719b..5c6cbbc 100644
--- a/lib/doc/jao-doc-view.el
+++ b/lib/doc/jao-doc-view.el
@@ -182,4 +182,35 @@
(advice-add 'doc-view-goto-page :before #'jao-doc-view--trail-push)
+;;; Find URLs
+(defun jao-doc-view--page-urls ()
+ (if doc-view--current-converter-processes
+ (message "DocView: please wait till conversion finished.")
+ (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir)))
+ (page (doc-view-current-page)))
+ (if (file-readable-p txt)
+ (with-current-buffer (find-file-noselect txt)
+ (goto-char (point-min))
+ (re-search-forward page-delimiter nil t (1- page))
+ (let ((end (save-excursion
+ (if (re-search-forward page-delimiter nil t)
+ (point)
+ (point-max))))
+ (urls))
+ (while (re-search-forward "https?://" end t)
+ (push (thing-at-point-url-at-point) urls))
+ urls))
+ (doc-view-doc->txt txt 'jao-doc-view--page-urls)))))
+
+(defun jao-doc-view-visit-url ()
+ "Visit URL displayed in this page."
+ (interactive nil doc-view-mode)
+ (let ((urls (jao-doc-view--page-urls)))
+ (if (null urls)
+ (message "No URLs in this page")
+ (when-let (url (completing-read "URL: " urls nil nil
+ (when (null (cdr urls)) (car urls))))
+ (browse-url url)))))
+
+
(provide 'jao-doc-view)