From: Miro Bezjak <bezjak.miro@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-insert-link with HTML title as default description
Date: Sat, 29 Sep 2012 14:23:44 +0200 [thread overview]
Message-ID: <CAMJqDfMrYBUHqK_5Qbuk3sM2k-6nZ-WUBb-CYeJkimnD7ZEtfw@mail.gmail.com> (raw)
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
next reply other threads:[~2012-09-29 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-29 12:23 Miro Bezjak [this message]
2012-09-29 14:42 ` org-insert-link with HTML title as default description 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMJqDfMrYBUHqK_5Qbuk3sM2k-6nZ-WUBb-CYeJkimnD7ZEtfw@mail.gmail.com \
--to=bezjak.miro@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).