emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Making Abbreviated links
@ 2007-05-18 19:18 Bastien
  2007-05-21  7:08 ` Carsten Dominik
  2007-05-22  4:37 ` Xavier Maillard
  0 siblings, 2 replies; 3+ messages in thread
From: Bastien @ 2007-05-18 19:18 UTC (permalink / raw)
  To: emacs-orgmode

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

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

end of thread, other threads:[~2007-05-22  4:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-18 19:18 Making Abbreviated links Bastien
2007-05-21  7:08 ` Carsten Dominik
2007-05-22  4:37 ` Xavier Maillard

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