emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Extract source code /with/ captions
Date: Mon, 13 Jan 2014 12:46:38 -0500	[thread overview]
Message-ID: <87k3e3n5a9.fsf@alphaville.bos.redhat.com> (raw)
In-Reply-To: 87ob3fn75e.fsf@alphaville.bos.redhat.com

Nick Dokos <ndokos@gmail.com> writes:

> James Harkins <jamshark70@gmail.com> writes:
>
>> ELEMENT:
>> (((#("25% coin toss in SuperCollider" 0 30 (:parent #2)))))
>>
>> This is correct, and I also see that I can use (plist-get ... :value)
>> to get the code string.
>>
>> Here, I'm hung up on some (large?) gaps in my elisp knowledge. I have
>> no idea what #(...) signifies, or what functions I can use to get the
>> string out of it. "#" Is not an especially useful search term in
>> google, bing etc...
>>
>> Can anyone help with my next step?
>>
>
> Not sure whether this will help but these are basically just strings
> with text properties. See
>
>      (info "(elisp) Text Properties in Strings")
>

I should have added:

o You can use substring-no-properties on a string to just get the
  sequence of characters it consists of without its text properties[fn:1]

--8<---------------cut here---------------start------------->8---
(setq s #("25% coin toss in SuperCollider" 0 30 (face bold)))
(substring-no-properties s) ==> "25% coin toss in SuperCollider"
--8<---------------cut here---------------end--------------->8---

o You can similarly use (buffer-substring-no-properties START END) if
  you want to extract a substring out of a buffer without its text
  properties.

Footnotes:
[fn:1] Note that I had to modify the properties a bit to make it into
       a string that the lisp reader could grok. When you print out the
       element, you get a shorthand representation of it:

       #("25% coin toss in SuperCollider" 0 30 (:parent #2))

       indicating the parent, but #2 is not legal as far as the lisp reader
       is concerned - it is just a useful shorthand for humans; however
       when you map your function on what org-element-parse-buffer
       returns, calling substring-no-properties on it before you print
       it (or whatever else you want to do to it) will do the right
       thing (modulo bugs of course).

Nick
        
       

      
      
       
       

  reply	other threads:[~2014-01-13 17:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 14:49 Extract source code /with/ captions James Harkins
2014-01-12 17:19 ` John Kitchin
2014-01-13  2:52   ` James Harkins
2014-01-13 17:06     ` Nick Dokos
2014-01-13 17:46       ` Nick Dokos [this message]
2014-01-13 18:01       ` Nick Dokos
2014-01-18  2:20         ` James Harkins
2014-01-18  3:04           ` James Harkins
2014-01-12 18:34 ` Charles Berry

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87k3e3n5a9.fsf@alphaville.bos.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 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).