Open nvgeele opened 4 years ago
Hi Nils,
Apologies for overlooking this issue.
That could be a useful feature. It should be a simple command to write. Would you be willing to submit a PR?
Thanks for the suggestion.
two years late but I found a need for this today. Probably a terrible way to do it, but works for me :)
(defun org-web-tools-insert-link-on-point ()
(interactive)
(replace-string (thing-at-point 'url t) (org-web-tools--org-link-for-url (thing-at-point 'url t))))
Another nice feature related to this would be to parse selected text for url and convert them to org-links in batch. I am not sure how to do that in a non-blocking manner atm. any ideas around that?
@geekodour Well, using replace-string
is unidiomatic Elisp, but if it works... :)
Another nice feature related to this would be to parse selected text for url and convert them to org-links in batch. I am not sure how to do that in a non-blocking manner atm. any ideas around that?
Doing it asynchronously would require care to account for the case in which the buffer's contents might have changed before the command finishes. As well, you'd need an asynchronous version of org-web-tools--org-link-for-url
(that part would be easy). But it could certainly be done.
@alphapapa I am not sure what happened but after an update today the function that I wrote(https://github.com/alphapapa/org-web-tools/issues/38#issuecomment-1412616933) broke. Maybe related to https://github.com/steelman/org-mode/issues/1 and https://github.com/alphapapa/org-web-tools/issues/61
Just mentioning just in case it's relevant.
@geekodour You'll have to be more specific than "broke." :)
@alphapapa
error in process sentinel: Wrong number of arguments: #<subr libxml-parse-html-region>, 0 [2 times]
plz--sentinel: Wrong type argument: number-or-marker-p, nil
libxml-parse-html-region seems to take START
and END
. Think this change: https://github.com/alphapapa/org-web-tools/commit/43c90dff9fc3caa8149bab1971a87a0de7abec3c ( Change: Use plz, remove --html-title, etc. ) introduced this issue
Following change to org-web-tools--org-link-for-url
seems to fix it for me
(cl-defun org-web-tools--org-link-for-url (&optional (url (org-web-tools--get-first-url)))
"Return Org link to URL using title of HTML page at URL.
If URL is not given, look for first URL in `kill-ring'. If page
at URL has no title, return URL."
(if-let ((dom
(with-temp-buffer
(insert (plz 'get url))
(libxml-parse-html-region (point-min) (point-max))))
(title (cl-caddr (car (dom-by-tag dom 'title)))))
(org-link-make-string url (org-web-tools--cleanup-title title))
(message "HTML page at URL has no title")
url))
@alphapapa any update on this? should I make a PR for this change?
@geekodour Please see https://github.com/alphapapa/org-web-tools/issues/63.
First of all, thanks for this package. It's making my notes, which often include a lot of (lists of) links to articles and so on, a lot more readable.
I have quite a few notes which already include a number of plain URLs or URLs with a short version of the page title. To make these notes more readable I would like to automatically change their description to the title of the linked page. Instead of yanking each URL and calling
org-web-tools-insert-link-for-url
, it would be handy to have another command which looks at the URL under the cursor, and replaces it with a link that has the title of the page as its description. If the link already has a description it could simply replace the existing description.