emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: Convert the region into an abbrev link
Date: Sat, 22 Dec 2007 17:42:43 +0100	[thread overview]
Message-ID: <87r6he65q4.fsf@bzg.ath.cx> (raw)

Hi list,

I'm regularily using Org for taking notes in meetings.  It's very handy
to be able to send a HTML/PDF report to everyone quickly.  While doing
this, I like to link some parts of the text that need to be searched
further, after the meeting.    

Then I'm using this small function to convert the selected text into a
google search:

(defun bzg-org-googlify-region (beg end)
  "Convert the selected region into a google search.
This requires that \"google\" is an abbreviated link for
http://www.google.com/search?q=%s"
  (interactive "r")
  (let ((query (buffer-substring beg end)))
    (delete-region beg end)
    (insert (org-make-link-string (concat "google:" query) query))))

This can be generalized for any kind of abbreviated link:

(defun bzg-org-abbrev-linkify-region (beg end)
  "Convert the selected region into an abbreviated link."
  (interactive "r")
  (let ((abbrev
	 (completing-read 
	  "Abbrev: " 
	  (mapcar (lambda (x) (list (concat (car x) ":")))
		  (append org-link-abbrev-alist-local 
			  org-link-abbrev-alist))))
	(reg (buffer-substring beg end)))
    (delete-region beg end)
    (insert (org-make-link-string (concat abbrev reg) reg))))

I guess this might be useful to other people...

-- 
Bastien

                 reply	other threads:[~2007-12-22 16:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87r6he65q4.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --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).