[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] org-insert-link with HTML title as default description
From: |
Miro Bezjak |
Subject: |
[O] org-insert-link with HTML title as default description |
Date: |
Sat, 29 Sep 2012 14:23:44 +0200 |
Hi all.
I'm new to the whole emacs/elisp/org-mode thing and I have to say I'm
amazed by it. Thank you for all the hard work.
That having been said, I've hacked together two functions that are
useful to me. I was wondering what are your thoughts on including
their idea (but with a better implementation) to org-mode? I've done
some reasonable googling but haven't concluded that org-mode has
something similar.
8<------------------------------------------------------------------------
(defun my-org-insert-link ()
"Insert org link where default description is set to html title."
(interactive)
(let* ((url (read-string "URL: "))
(title (get-html-title-from-url url)))
(org-insert-link nil url title)))
(defun get-html-title-from-url (url)
"Return content in <title> tag."
(let (x1 x2 (download-buffer (url-retrieve-synchronously url)))
(save-excursion
(set-buffer download-buffer)
(beginning-of-buffer)
(setq x1 (search-forward "<title>"))
(search-forward "</title>")
(setq x2 (search-backward "<"))
(buffer-substring-no-properties x1 x2))))
-------------------------------------------------------------------------->8
Cheers,
Miro
- [O] org-insert-link with HTML title as default description,
Miro Bezjak <=