emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: Making Abbreviated links
Date: Fri, 18 May 2007 21:18:24 +0200	[thread overview]
Message-ID: <871whe0wlb.fsf@bzg.ath.cx> (raw)

Hello,

this function allows you to turn the region into a abbreviated link, the
minibuffer being aware of the local #+LINK: options.  With a prefix, ask
for the link itself as well.

Comments & suggestions welcome !

========================================================================
(defun bzg-org-link-this-region (&optional full)
  "Turn the region into a abbreviated link.
With a prefix, ask the for link as well."
  (interactive "P")
  (when (org-region-active-p)
    (let* ((beg (region-beginning))
	   (end (region-end))
	   (history (mapcar 'car org-link-abbrev-alist-local))
	   (desc (buffer-substring-no-properties beg end))
           (link (if full (concat (completing-read "#+LINK: " history)
				  ":" (read-from-minibuffer "Link: "))
		   (concat (completing-read "#+LINK: " history) ":" desc))))
      (kill-region beg end)
      (insert (org-make-link-string link desc)))))
========================================================================

-- 
Bastien

             reply	other threads:[~2007-05-18 19:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-18 19:18 Bastien [this message]
2007-05-21  7:08 ` Making Abbreviated links Carsten Dominik
2007-05-22  4:37 ` Xavier Maillard

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=871whe0wlb.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).