Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix opening files with symbolic links #24

Open
wants to merge 2 commits into from

1 participant

@stepheneb

This fixes issue 5: #5 -- but in an ugly manner.

I asked for advice a while ago on the textmate list but didn't get any suggestions about how to make it cleaner.

http://lists.macromates.com/textmate/2010-September/031412.html

There are two commits in this pull request. The first makes it easier to debug Ackmate while doing development. The second fixes the problem with symbolic links.

stepheneb added some commits
@stepheneb stepheneb debug target creates symbolic link to plugin
The target "Run Script" now deletes any existing AckMate.tmplugin
in the TextMate PlugIn dir and then if:
debug target:
  creates a symbolic link to the plugin in the debug build
release target:
  copies the plugin to the TextMate PlugIn dir

To use this capability create a new Custom Executable referencing TextMate:

  "Project", "New Custom Executable..."

Then after setting breakpoints: Clean and then 
"Build and Debug - Breakpoints On"

adapted from: http://developer.apple.com/mac/library/qa/qa2006/qa1500.html
ba2e685
@stepheneb stepheneb open files in mate via NSTask
See issue: 
  Searching inside symlinked folders opens a new window
  http://github.com/protocool/AckMate/issues/#issue/5

This is a bit of a hack because it doesn't check to 
make sure the mate shell executable is installed.
1bc7e4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2010
  1. @stepheneb

    debug target creates symbolic link to plugin

    stepheneb authored
    The target "Run Script" now deletes any existing AckMate.tmplugin
    in the TextMate PlugIn dir and then if:
    debug target:
      creates a symbolic link to the plugin in the debug build
    release target:
      copies the plugin to the TextMate PlugIn dir
    
    To use this capability create a new Custom Executable referencing TextMate:
    
      "Project", "New Custom Executable..."
    
    Then after setting breakpoints: Clean and then 
    "Build and Debug - Breakpoints On"
    
    adapted from: http://developer.apple.com/mac/library/qa/qa2006/qa1500.html
  2. @stepheneb

    open files in mate via NSTask

    stepheneb authored
    See issue: 
      Searching inside symlinked folders opens a new window
      http://github.com/protocool/AckMate/issues/#issue/5
    
    This is a bit of a hack because it doesn't check to 
    make sure the mate shell executable is installed.
This page is out of date. Refresh to see the latest.
View
2  AckMate.xcodeproj/project.pbxproj
@@ -332,7 +332,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\ncp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\"";
+ shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\n# adapted from: http://developer.apple.com/mac/library/qa/qa2006/qa1500.html\n# Depending on the build configuration, either copy or link to the most recent product\nrm -rf \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nif [ \"${CONFIGURATION}\" == \"Debug\" ]; then\n # if we're debugging, add a symbolic link to the plug-in\n ln -sf \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \\\n \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nelif [ \"${CONFIGURATION}\" == \"Release\" ]; then\n # if we're compiling for release, just copy the plugin to the Internet Plug-ins folder\n cp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
View
1  source/controllers/JPAckWindowController.h
@@ -36,6 +36,7 @@ extern NSString * const kJPAckWindowPosition;
NSString* selectedSearchFolder;
BOOL selectionSearch;
NSString* fileName;
+ NSTask* mateTask;
NSMutableDictionary* preferences;
NSArray* history;
View
30 source/controllers/JPAckWindowController.m
@@ -20,6 +20,7 @@ - (void)updateSearchSelectionForEvent:(NSEvent*)event;
@property(nonatomic, retain) NSArray* ackTypes;
@property(nonatomic, readwrite, copy) NSArray* history;
@property(nonatomic, copy) NSString* selectedSearchFolder;
+@property(retain) NSTask* mateTask;
@end
@implementation JPAckWindowController
@@ -50,6 +51,7 @@ @implementation JPAckWindowController
@synthesize folders;
@synthesize currentProcess;
@synthesize currentTypesProcess;
+@synthesize mateTask;
+ (NSSet*)keyPathsForValuesAffectingRunning
{
@@ -88,6 +90,8 @@ - (id)initWithProjectDirectory:(NSString*)directory controller:(id)controller pr
preferences = prefs;
pasteboardChangeCount = NSNotFound;
+ mateTask = nil;
+
NSString* projectfile = [projectController filename] ? [projectController filename] : directory;
fileName = [[[projectfile lastPathComponent] stringByDeletingPathExtension] copy];
projectDirectory = [directory copy];
@@ -327,27 +331,17 @@ - (void)loadAckTypes
- (void)openProjectFile:(NSString*)file atLine:(NSString*)line selectionRange:(NSRange)selectionRange
{
NSString* absolute = [projectDirectory stringByAppendingPathComponent:file];
- [[[NSApplication sharedApplication] delegate] openFiles:[NSArray arrayWithObject:absolute]];
-
- for (NSWindow *w in [[NSApplication sharedApplication] orderedWindows])
- {
- id wc = [w windowController];
- NSString* openFileName = nil;
- if ([[wc className] isEqualToString:@"OakProjectController"] || [[wc className] isEqualToString:@"OakDocumentController"])
- openFileName = [[[wc textView] document] filename];
+ self.mateTask = [[[NSTask alloc] init] autorelease];
+ [self.mateTask setCurrentDirectoryPath:projectDirectory];
+ [self.mateTask setLaunchPath:@"/usr/bin/env"];
- if ([openFileName isEqualToString:absolute])
- {
- [[wc textView] goToLineNumber:line];
- [[wc textView] goToColumnNumber:[NSNumber numberWithInt:selectionRange.location + 1]];
+ NSMutableArray* args = [NSMutableArray arrayWithObjects:@"mate", absolute, nil];
+ [args addObject:@"-l"];
+ [args addObject:line];
- if (selectionRange.length > 0)
- [[wc textView] selectToLine:line andColumn:[NSNumber numberWithInt:selectionRange.location + selectionRange.length + 1]];
-
- break;
- }
- }
+ [self.mateTask setArguments:args];
+ [self.mateTask launch];
}
- (IBAction)cancel:(id)sender
Something went wrong with that request. Please try again.