Codefolding IF|FOREACH for textmate - textmate

Hope someone can help.
I am a new user to textmate and want to add code folding to if|endif & foreach|endforeach on textmate.
These are the current supported folds
foldingStartMarker = '(/\*|\{\s*$|<<<HTML)';
foldingStopMarker = '(\*/|^\s*\}|^HTML)';
I have tried
foldingStartMarker = '(/\*|\{\s*$|<<<HTML|if)';
foldingStopMarker = '(\*/|^\s*\}|^HTML|endif)';
Which starts the fold for an if but the stop Marker is not being picked up.
Has anyone else done this ?
Hope you can advise

Change The HTML bundle instead of the PHP bundle!
I've changed |array\s?(\s*$ into |array(\s*$ to get array folding. This might work for you as well.
I've also tried this: |array\s*(\s*$ because I want to fold array( as well as array ( or array (. I don't know if this is exactly the right syntax, but it works perfectly!
Thanks to Chris Adams:
http://old.nabble.com/Any-chance-of-a-little-help-sorting-this-language-regexp-to-make-php-coding-less-painful-in-textmate--td30458020.html

Related

Add sample names to s.class

So I'm trying to add sample names to my PCA s.class. Someone here (on another question) suggested adding text() to it, but I can't seem to figure out how to align the two.
Here is my code:
s.class(pca1$li, fac = beardata$pop, xax=1, yax=2)
add.scatter.eig(pca1$eig[1:20], 3,1,2, pos="bottomright", inset=.01, ratio=.18)
first code image
s.class(pca1$li, fac = beardata$pop)
text(pca1$li,labels=indNames(beardata),cex=0.7)
add.scatter.eig(pca1$eig[1:20], 3,1,2, pos="bottomright", inset=.01, ratio=.18)
This is what I get with added text()
Thank you for any help, I'm quite new at this so I hope this has easy solution.

How do I copy large ranges between workbooks efficiently?

i'm writing a copy paste function for a fairly large dataset to be copied from one workbook to a specific sheet in another. I have written the bellow code, in the hope that it will copy paste as efficiently as possible, however during debugging the code was shown not to be working at all, it doesnt copy or paste anything and I dont understand why, does anyone have any ideas / solutions? thanks in advance
Windows("TempResults.xlsm").Activate
numofrows = ActiveSheet.UsedRange.Rows.Count
Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A2", "AE" & CStr(numofrows)).Copy Destination:=Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1").End(xlDown).Offset(1, 0)
I guess this is what you want
Windows("TempResults.xlsm").Activate
numofrows = ActiveSheet.UsedRange.Rows.Count
Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A2", "AE" & CStr(numofrows)).Copy Destination:=Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1")
Regarding the efficiency concern expressed in your question: you can try an alternative approach, like the following:
Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1").Value = Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A1").Value
Try to see how it works, then modify the range correspondingly to your case.
Hope this will help. Regards,

TextMate Snippet: How to uppercase the first letter in a regexp

How can I make the first letter upper case in the following:
${1:${TM_FILENAME/[\.php]+$//}}
Basically if the filename is "welcome.php", I'd like it to write out "Welcome". This at the moment writes "welcome" (lower case w).
Try the following snippet. Works for me.
${TM_FILENAME/(.*?)(\..+)/\u$1/}
For some reason the above example gives you weird charectors when using it ... it took me a while but the solution below works if you are still looking. It has two solutions here for you the first one is for actual textmate on mac:
${TM_FILENAME/(^.)(.*?)(\.php)/(?1:\U$1)(?2:)(?3:)/}
The next is if you are using e Texteditor on PC:
${TM_FILENAME/(^.)(.*?)(\.php)/(?1:)(?2:$2)(?3:)/}
I hope this helps you if you haven't already.
TM_FILENAME not works for windows?

Descendent-or-self in InfoPath

I want to use XPath code in an InfoPath form to sum the data in field12 when field11 is equal to IT. I tried using the following code, but it doesn't work.
number(sum(/descendant-or-self::node()/my:group12[my:field11 = "IT;"]/my:field12))
I suspect this has to do with the multilayering of groups, as shown below. Does anyone know the code that would allow me to get to the data in group12? Thanks in advance for your help.
myfields>group9>group10>group11>group12>field11 field12
Genipro
Looks like:
number(sum(/descendant-or-self::my:group12[my:field11 = 'IT;']/my:field12))
could be right.
decendant-or-self should not be necissary in this case (unless you need the expression to work even if group12 is moved).
This should work fine:
sum(/my:myfields/my:group9/my:group10/my:group11/my:group12[contains(my:field11,'IT')]/my:field12)
It doesn't matter if any of the other groups are repeating either. All group12's will be checked.

Programming TextMate in Ruby. Problem with TextMate.go_to

I'm modding a TextMate bundle even though I'm a complete beginner at Ruby. The problem I'm trying to solve is the issue of moving the caret to a certain positition after the command has made its output.
Basically what happens is this:
I hit a key combo which triggers a command to filter through the document and inserts text at the relevant places, then exits with replacing the document with the new filtered text.
What I want to happen next is for the caret to move back to where it originally was. I was pretty happy when I found the TextMate.go_to function, but I can only get it partly to work. The function:
positionY = ENV['TM_LINE_NUMBER']
positionX = ENV['TM_LINE_INDEX']
...
TextMate.go_to :line => positionY, :column => positionX; #column no worky
I can get the caret to the right line, but the column parameter isn't working. I've tried shifting them about and even doing the function with just the column param, but no luck. I've also tried with a hard coded integer, but the positionX param prints the correct line index, so I doubt there's anything there.
This is the only documentation I've found on this method, but I took a look in the textmate.rb and to my untrained eyes it seems I'm using it properly.
I know this can be achieved by macros, but I want to avoid that if possible.
I also know that you can use markers if you choose "Insert as snippet" but then I'd have to clear the document first, and I haven't really figured out how to do this either without using the "Replace document" option.
Anyone?
Let's look at the source code of the bindings:
def go_to(options = {})
default_line = options.has_key?(:file) ? 1 : ENV['TM_LINE_NUMBER']
options = {:file => ENV['TM_FILEPATH'], :line => default_line, :column => 1}.merge(options)
if options[:file]
`open "txmt://open?url=file://#{e_url options[:file]}&line=#{options[:line]}&column=#{options[:column]}"`
else
`open "txmt://open?line=#{options[:line]}&column=#{options[:column]}"`
end
end
Rather hackishly, the binding sets up a txmt:// URL and calls open on it in the shell.
So the first thing to do would be constructing an open URL and typing it into Terminal/your browser to see if TextMate is respecting the column parameter. If that works then perhaps there is a bug in your version's implementation of Textmate.go_to.

Resources