Created
January 5, 2024 14:12
-
-
Save kim366/8abe978cc295b027df636b218862758e to your computer and use it in GitHub Desktop.
Emacs org-mode automatically fetch link title
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
;; Adpated from https://gist.github.com/jmn/34cd4205fa30ccf83f94cb1bc0198f3f | |
;; Automatically fetch link description (C-c C-l) for link at point | |
(defun my/url-get-title (url &optional descr) | |
(with-temp-buffer | |
(url-insert-file-contents url) | |
(goto-char (point-min)) | |
(search-forward-regexp (rx "<title>" (group (*? anything)) "</title>")) | |
(match-string 1))) | |
(setq org-make-link-description-function 'my/url-get-title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment