Skip to content

Instantly share code, notes, and snippets.

@kim366
Created January 5, 2024 14:12
Show Gist options
  • Save kim366/8abe978cc295b027df636b218862758e to your computer and use it in GitHub Desktop.
Save kim366/8abe978cc295b027df636b218862758e to your computer and use it in GitHub Desktop.
Emacs org-mode automatically fetch link title
;; 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