[TxMt] Re: Executing command on all files in a project AND using TM variables in a search and replace

James Fishwick fishwick.hmco at gmail.com
Fri Oct 20 18:27:36 UTC 2006


Awesome, apreciate it Allan.

Very impressed you're on here answering questions. Consider me a an  
"offical" textmate user now!

-J

> From: Allan Odgaard <throw-away-1 at macromates.com>
> Date: October 20, 2006 1:42:15 AM EDT
> To: TextMate users <textmate at lists.macromates.com>
> Subject: Re: [TxMt] Executing command on all files in a project AND  
> using TM variables in a search and replace
> Reply-To: TextMate users <textmate at lists.macromates.com>
>
>
> On 19. Oct 2006, at 22:12, J Fishwick wrote:
>
>> Command:
>> eval arr=("$TM_SELECTED_FILES")
>> for (( i = 0; i < ${#arr[@]}; i++ )); do
>> perl -pe 'while ($string =~ m/mc\d+(.*\n.*True)/g) {$string =~
>> s/mc\d+/tf$TM_FILENAME/g;}';
>> done
>>
>> Input: Entire Doc
>> Output: Replace selected text
>
> You need to set input/output to none/discard (or show tool tip, or  
> maybe show as HTML and make your command output some progress info).
>
> Then your actual command needs to load the file itself, it already  
> iterators over the selected files, it just doesn’t tell perl to  
> load/overwrite each of them.
>
> So a simple example would instead be:
>
>     eval arr=("$TM_SELECTED_FILES")
>     for f in "${arr[@]}"; do
>         perl -i.bak -pe 's/bar/bar/' "$f"
>     done
>     rescan_project # do this after you make changes to files, so TM  
> will rescan
>
> This will replace foo with bar in all selected files (and create  
> a .bak file with the old contents).
>
> Two other things: 1) inside single quoted strings, shell variables  
> are not expanded, so if you want to use $TM_… then you need to use  
> double quotes, and 2) TM_FILENAME is the filename of the file open  
> when you called the file, it won’t update inside the loop. Here you  
> would instead use the current file given by the loop (in my example  
> $f).
>



On Oct 20, 2006, at 7:43 AM, textmate-request at lists.macromates.com  
wrote:

> Send textmate mailing list submissions to
> 	textmate at lists.macromates.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.macromates.com/mailman/listinfo/textmate
> or, via email, send a message with subject or body 'help' to
> 	textmate-request at lists.macromates.com
>
> You can reach the person managing the list at
> 	textmate-owner at lists.macromates.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of textmate digest..."
> Today's Topics:
>
>    1. Re: Executing command on all files in a project AND using TM
>       variables in a search and replace (Allan Odgaard)
>    2. Re: Latex: completion with esc not working (Christopher  
> Brewster)
>    3. Re: TODO problem (Jasper van der Meulen)
>
> From: Allan Odgaard <throw-away-1 at macromates.com>
> Date: October 20, 2006 1:42:15 AM EDT
> To: TextMate users <textmate at lists.macromates.com>
> Subject: Re: [TxMt] Executing command on all files in a project AND  
> using TM variables in a search and replace
> Reply-To: TextMate users <textmate at lists.macromates.com>
>
>
> On 19. Oct 2006, at 22:12, J Fishwick wrote:
>
>> Command:
>> eval arr=("$TM_SELECTED_FILES")
>> for (( i = 0; i < ${#arr[@]}; i++ )); do
>> perl -pe 'while ($string =~ m/mc\d+(.*\n.*True)/g) {$string =~
>> s/mc\d+/tf$TM_FILENAME/g;}';
>> done
>>
>> Input: Entire Doc
>> Output: Replace selected text
>
> You need to set input/output to none/discard (or show tool tip, or  
> maybe show as HTML and make your command output some progress info).
>
> Then your actual command needs to load the file itself, it already  
> iterators over the selected files, it just doesn’t tell perl to  
> load/overwrite each of them.
>
> So a simple example would instead be:
>
>     eval arr=("$TM_SELECTED_FILES")
>     for f in "${arr[@]}"; do
>         perl -i.bak -pe 's/bar/bar/' "$f"
>     done
>     rescan_project # do this after you make changes to files, so TM  
> will rescan
>
> This will replace foo with bar in all selected files (and create  
> a .bak file with the old contents).
>
> Two other things: 1) inside single quoted strings, shell variables  
> are not expanded, so if you want to use $TM_… then you need to use  
> double quotes, and 2) TM_FILENAME is the filename of the file open  
> when you called the file, it won’t update inside the loop. Here you  
> would instead use the current file given by the loop (in my example  
> $f).
>
>
>
>
>
>
>
> From: Christopher Brewster <C.Brewster at dcs.shef.ac.uk>
> Date: October 20, 2006 6:35:06 AM EDT
> To: TextMate users <textmate at lists.macromates.com>
> Subject: Re: [TxMt] Latex: completion with esc not working
> Reply-To: TextMate users <textmate at lists.macromates.com>
>
>
>
>> On 19 Oct 2006, at 23:13, Charilaos Skiadas wrote:
>>
>>> Is this what they should be?
>>>
>> That looks right. Is this a saved file? Try it with both saved  
>> files as well as untitled documents.
>
> The problem is specific to that project I am afraid. There is no  
> problem with other latex files in other folders.
>
>> Is it part of a project, via TM_LATEX_MASTER?
>
> yes it is
>> Are you setting TM_LATEX_BIB? (You don't have to, just checking  
>> your settings)
>
> Checking this I realised for Bibtex the path had changed. So the  
> \cite{} case is solved.
> But the \ref{} case is still not working (in this project).
>
>> How are you testing that it is not working?
>
> for \ref{}
> put cursor in braces and press esc
>
>> Does the other completion command work, the one via opt-esc?
> This does nothing.
>
>> Make sure that you are up to date, I recently fixed a problem  
>> someone else had that sounds possibly similar, though his was with  
>> the Command Completion command.
> I am up to date.
>
> Thanks,
>
> Christopher
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
>
>
>
> From: Jasper van der Meulen <jasper at logt.nu>
> Date: October 20, 2006 7:43:02 AM EDT
> To: TextMate users <textmate at lists.macromates.com>
> Subject: Re: [TxMt] TODO problem
> Reply-To: TextMate users <textmate at lists.macromates.com>
>
>
> I don't think you understand what i mean...
>
> I've got it in a picture now ..
>
> <screenshot 2.png>
> however
> Regards J.
>
>
> On 20-okt-2006, at 7:26, Allan Odgaard wrote:
>
>> On 20. Oct 2006, at 00:02, Jasper van der Meulen wrote:
>>
>>> Could it be that a project is different for the TODO ?
>>
>> It visits all files found under TM_PROJECT_DIRECTORY (using the  
>> globally configured folder reference patterns for what to skip).
>>
>>
>>
>>
>> _____________________________________________________________________ 
>> _
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you  
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20061020/d14f5f27/attachment.html>


More information about the textmate mailing list