Open mooseyboots opened 2 years ago
That would more idiomatically belong in the org-web-tools-read-url-as-org
function's interactive
form. But it would seem to be a matter of preference, because some users might want the command to ignore any links at point.
@alphapapa thanks for the hint.
i came up with this:
(defcustom org-web-tools-use-link-at-point nil
"Whether `org-web-tools' should operate on the link at point."
:type 'boolean)
(cl-defun org-web-tools-read-url-as-org (url &key (show-buffer-fn #'switch-to-buffer))
"Read URL's readable content in an Org buffer.
Buffer is displayed using SHOW-BUFFER-FN."
(interactive
(list
(if org-web-tools-use-link-at-point
(or
;; shr link (modified from `elfeed-get-link-at-point'):
(or (shr-url-at-point nil)
(and (fboundp 'eww-current-url)
(funcall 'eww-current-url))
(get-text-property (point) :nt-link))
;; org link:
(plist-get (get-text-property (point) 'htmlize-link) :uri)
;; plain URL (from `elfeed-get-url-at-point'):
(or (if (fboundp 'thing-at-point-url-at-point)
(thing-at-point-url-at-point)
(with-no-warnings (url-get-url-at-point)))
(thing-at-point 'url))
;; kill ring as per usual:
(org-web-tools--get-first-url))
(org-web-tools--get-first-url))))
(let ((entry (org-web-tools--url-as-readable-org url)))
(when entry
(funcall show-buffer-fn url)
(org-mode)
(insert entry)
;; Set buffer title
(goto-char (point-min))
(rename-buffer (cdr (org-web-tools--read-org-bracket-link))))))
i thought to add this to
org-web-tools
, in order to say, runorg-web-tools-read-url-as-org
on a link in an elfeed entry or in eww, or on also an org link:could poss add some others, could poss find more rigorous way of fetching them...