emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Extract source code /with/ captions


From: Nick Dokos
Subject: Re: [O] Extract source code /with/ captions
Date: Mon, 13 Jan 2014 12:46:38 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Nick Dokos <address@hidden> writes:

> James Harkins <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]