Last active
September 12, 2023 19:36
-
-
Save jmn/34cd4205fa30ccf83f94cb1bc0198f3f to your computer and use it in GitHub Desktop.
How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage: | |
(defun jmn/url-get-title (url &optional descr) | |
"Takes a URL and returns the value of the <title> HTML tag, | |
Thanks to https://frozenlock.org/tag/url-retrieve/ for documenting url-retrieve" | |
(let ((buffer (url-retrieve-synchronously url)) | |
(title nil)) | |
(save-excursion | |
(set-buffer buffer) | |
(goto-char (point-min)) | |
(search-forward-regexp "<title>\\([^<]+?\\)</title>") | |
(setq title (match-string 1 ) ) | |
(kill-buffer (current-buffer))) | |
title)) | |
(setq org-make-link-description-function 'jmn/url-get-title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment