[SVN] Bookmarks

Allan Odgaard throw-away-1 at macromates.com
Fri Apr 13 12:03:36 UTC 2007


On 12. Apr 2007, at 06:48, Adam Elliot wrote:

> Thank you very much, this is exactly what I was looking for!

The bookmarks are stored under the com.macromates.bookmarked_lines  
attribute name.

It is an array of line numbers (stored as a property list).

One caveat is that it is (likely) gzipped -- the reason for this is  
that extended attributes has a size limitation, and I did run into  
that when storing the values as their “raw” property lists.

There is no indicator of this, so you need to fetch the value, try to  
decompress is, and if that succeeds, parse it as a plist, otherwise  
try parse the raw value as a plist -- here is the code I use:

     ssize_t len = getxattr(path, key, NULL, 0, 0, 0);
     if(len <= 0)
         return nil;

     std::vector<char> v(len);
     if(getxattr(path, key, &v[0], v.size(), 0, 0) != -1)
     {
         uLongf destLen = 5 * v.size();
         std::vector<char> dest;
         int zlib_res = Z_BUF_ERROR;
         while(zlib_res == Z_BUF_ERROR && destLen < 1024*1024)
         {
             destLen <<= 2;
             dest = std::vector<char>(destLen);
             zlib_res = uncompress((Bytef*)&dest[0], &destLen,  
(Bytef*)&v[0], v.size());
         }

         if(zlib_res == Z_OK)
         {
             dest.resize(destLen);
             dest.swap(v);
         }

         res = [NSPropertyListSerialization propertyListFromData: 
[NSData dataWithBytes:&v[0] length:v.size()]  
mutabilityOption:NSPropertyListImmutable format:nil  
errorDescription:NULL];
     }


> On 11-Apr-07, at 9:13 PM, Benoit Gagnon wrote:
>
>> from the TextMate help:
>>
>> "19.4 Extended Attributes (Metadata)
>>
>> Starting with Tiger, OS X supports setxattr and friends.
>>
>> TextMate makes use of extended attributes to store the carets
>> position, bookmarks, what text is folded and is likely to make  
>> further
>> use of extended attributes in the future."
>>
>> and from this site you should find useful information on how to  
>> get to
>> the values:
>>
>> http://arstechnica.com/reviews/os/macosx-10.4.ars/7
>>
>> On 4/11/07, Adam Elliot <adam.elliot at gmail.com> wrote:
>>> Is there a way to access the bookmarks added to a file so they  
>>> can be
>>> used in a bundle for adding break points to a debugger?
>>>
>>> Thanks,
>>> Adam
>>>
>>> _______________________________________________
>>> textmate-dev mailing list
>>> textmate-dev at lists.macromates.com
>>> http://lists.macromates.com/mailman/listinfo/textmate-dev
>>>
>>
>> _______________________________________________
>> textmate-dev mailing list
>> textmate-dev at lists.macromates.com
>> http://lists.macromates.com/mailman/listinfo/textmate-dev
>
>
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate-dev




More information about the textmate-dev mailing list