From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Making Abbreviated links Date: Fri, 18 May 2007 21:18:24 +0200 Message-ID: <871whe0wlb.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hp7yC-0007aD-7F for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:18:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hp7y9-0007Vk-OH for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:18:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hp7y9-0007VQ-F6 for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:18:29 -0400 Received: from ug-out-1314.google.com ([66.249.92.174]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hp7y9-0007YA-1f for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:18:29 -0400 Received: by ug-out-1314.google.com with SMTP id j3so535714ugf for ; Fri, 18 May 2007 12:18:27 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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