[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.


(defun my-org-insert-link ()
  "Insert org link where default description is set to html title."
  (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)))
      (set-buffer download-buffer)
      (setq x1 (search-forward "<title>"))
      (search-forward "</title>")
      (setq x2 (search-backward "<"))
      (buffer-substring-no-properties x1 x2))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]