all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alexis <flexibeast@gmail.com>
To: Paul <mafeuser@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: function to copy org buffer substring with link description only
Date: Tue, 08 Dec 2015 17:54:24 +1100	[thread overview]
Message-ID: <87oae1qvkv.fsf@gmail.com> (raw)
In-Reply-To: <56649E58.1030707@gmail.com>


Paul <mafeuser@gmail.com> 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.



  reply	other threads:[~2015-12-08  6:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 20:45 function to copy org buffer substring with link description only Paul
2015-12-08  6:54 ` Alexis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-12-08 17:33 Paul
2015-12-09  7:25 ` Alexis
2015-12-09 18:00 Paul
     [not found] <mailman.1527.1449434757.31583.help-gnu-emacs@gnu.org>
2015-12-09 19:57 ` Gene

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oae1qvkv.fsf@gmail.com \
    --to=flexibeast@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mafeuser@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.