emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-insert-link with HTML title as default description
@ 2012-09-29 12:23 Miro Bezjak
  2012-09-29 14:42 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Miro Bezjak @ 2012-09-29 12:23 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-29 23:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29 12:23 org-insert-link with HTML title as default description Miro Bezjak
2012-09-29 14:42 ` Bastien
2012-09-29 15:09   ` Sylvain Rousseau
2012-09-29 18:43     ` Miro Bezjak
2012-09-29 20:53     ` Bastien
2012-09-29 23:00       ` Sylvain Rousseau

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).