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: Wed, 09 Dec 2015 18:25:56 +1100 [thread overview]
Message-ID: <87fuzcqe0r.fsf@gmail.com> (raw)
In-Reply-To: <56671464.7070707@gmail.com>
Paul <mafeuser@gmail.com> writes:
> thank YOu for the function
>
> I believe that there must be something ready to be used, because
> org-mode does provide function that is able to export document
> or its part as text file. Of course such function probably
> removes more elements than link only, but that would be no
> harm.
Oh, well, if you're not worried about affecting other elements,
then you could wrap the `org-export-as` function like so:
#+BEGIN_SRC emacs-lisp
(defun org-delinkify-region-2 ()
"Replace all Org-style links within the region with only the
link description text, and return the result."
(interactive) (org-export-as 'ascii nil t t))
#+END_SRC
The four arguments to `org-export-as` mean:
- Use the 'ascii export backend;
- Don't transcode the sub-tree at point; we're relying on
`org-export-as` working on the
region if the region is active.
- Don't export the contents of hidden elements.
- Don't add a surrounding template.
Note that `ox-ascii.el`, which defines the 'ascii export backend,
/does/ have an `ox-ascii-link` function, but that function needs
to be /passed/ the 'description' part of the link, the very thing
we want to extract. In usual usage, this extraction is done by
building a parse tree of an Org buffer, then calling
`ox-ascii-link` with the relevant parse tree data for all links in
the parse tree. So if i understand correctly, my code above is
probably as simple as one can get for your use-case.
Hope that helps!
Alexis.
next prev parent reply other threads:[~2015-12-09 7:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 17:33 function to copy org buffer substring with link description only Paul
2015-12-09 7:25 ` Alexis [this message]
[not found] <mailman.1527.1449434757.31583.help-gnu-emacs@gnu.org>
2015-12-09 19:57 ` Gene
-- strict thread matches above, loose matches on Subject: below --
2015-12-09 18:00 Paul
2015-12-06 20:45 Paul
2015-12-08 6:54 ` Alexis
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=87fuzcqe0r.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.