From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexis Newsgroups: gmane.emacs.help Subject: Re: function to copy org buffer substring with link description only Date: Tue, 08 Dec 2015 17:54:24 +1100 Message-ID: <87oae1qvkv.fsf@gmail.com> References: <56649E58.1030707@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: ger.gmane.org 1449557711 20328 80.91.229.3 (8 Dec 2015 06:55:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2015 06:55:11 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Paul Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 08 07:54:49 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a6CAh-0003ED-Q7 for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 07:54:47 +0100 Original-Received: from localhost ([::1]:58183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6CAg-0002Nq-U2 for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 01:54:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6CAW-0002Nf-I7 for help-gnu-emacs@gnu.org; Tue, 08 Dec 2015 01:54:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6CAR-0001VF-JN for help-gnu-emacs@gnu.org; Tue, 08 Dec 2015 01:54:36 -0500 Original-Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]:35859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6CAR-0001VB-D2 for help-gnu-emacs@gnu.org; Tue, 08 Dec 2015 01:54:31 -0500 Original-Received: by pacdm15 with SMTP id dm15so7331526pac.3 for ; Mon, 07 Dec 2015 22:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; bh=aDDZn/XlBQqpRntstCe8i/cJczydeKxtVX7QHkfBMN4=; b=MyQO7dHxX7hcDAHkV2ZFBFEts1nt55u/3xjClg1LBqLcDOYM/F9g2KR/R7j7qj1HCj wyXIniJf7GLPrQYZFXBnWO86rQv1XFYeoYdq6QzS+QZ5pDqYc3GD69S6uCnpKeH7xWHz T5MgQe7XIGTFexgMGupLUbWV+WEWzjWGF+5zprD+E2iWnjdTWG43lMjc+tezJceqYS1d T3pFMPo5hzQt6PBO1/b8slN+wYa3V+GuBHc9A0eJRmltkDzbVU37GVxek42Fl1p+upZU Y8Hl9ebgo8EGty38BWYrtgCD8Y/bhrnXKn08I6Ytq4rhmetYd+gT3AVquay0+thrUVF6 Alow== X-Received: by 10.66.160.70 with SMTP id xi6mr2728024pab.54.1449557670302; Mon, 07 Dec 2015 22:54:30 -0800 (PST) Original-Received: from localhost (ppp118-209-101-190.lns20.mel4.internode.on.net. [118.209.101.190]) by smtp.gmail.com with ESMTPSA id q23sm2210864pfi.34.2015.12.07.22.54.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2015 22:54:29 -0800 (PST) In-reply-to: <56649E58.1030707@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::235 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108338 Archived-At: Paul writes: > (buffer-substring-no-properties (point) (mark)) on some part of > an org buffer that contains a link returns the following > example: > > "while [[(some-link)][description]] does not" > > > Do You know a ready to use function that would return the > following?: > > "while description does not" i'm not aware of any existing function that does this, so here's a function that's at least a start: #+BEGIN_SRC emacs-lisp (defun org-delinkify-region (start end) "Replace all Org-style links within the region with only the link description text, and return the result." (interactive "r") (let ((text (buffer-substring-no-properties start end))) (with-temp-buffer (insert text) (goto-char (point-min)) (while (re-search-forward "\\[\\[[^\\]+?]\\[\\(.+?\\)]\\]" (point-max) t) (replace-match (match-string 1))) (buffer-substring (point-min) (point-max))))) #+END_SRC Hope that helps! Alexis.