Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stepheneb/554581 to your computer and use it in GitHub Desktop.
Save stepheneb/554581 to your computer and use it in GitHub Desktop.
From f42801da968a1e6fe2927fe7a24ccbaf617293f3 Mon Sep 17 00:00:00 2001
From: Stephen Bannasch <stephen.bannasch@gmail.com>
Date: Fri, 27 Aug 2010 22:18:10 -0400
Subject: [PATCH 2/2] hack to 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 an unfinished hack because it doesn't wait for
mate to open before trying to move to the correct line.
It also doesn't check to make sure the mate shell
executable is installed.
---
source/controllers/JPAckWindowController.h | 1 +
source/controllers/JPAckWindowController.m | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/source/controllers/JPAckWindowController.h b/source/controllers/JPAckWindowController.h
index ba9e345..e290c27 100644
--- a/source/controllers/JPAckWindowController.h
+++ b/source/controllers/JPAckWindowController.h
@@ -36,6 +36,7 @@ extern NSString * const kJPAckWindowPosition;
NSString* selectedSearchFolder;
BOOL selectionSearch;
NSString* fileName;
+ NSTask* mateTask;
NSMutableDictionary* preferences;
NSArray* history;
diff --git a/source/controllers/JPAckWindowController.m b/source/controllers/JPAckWindowController.m
index ddd1f20..f2fba24 100644
--- a/source/controllers/JPAckWindowController.m
+++ b/source/controllers/JPAckWindowController.m
@@ -20,6 +20,7 @@
@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 @@ NSString * const kJPAckWindowPosition = @"kJPAckWindowPosition";
@synthesize folders;
@synthesize currentProcess;
@synthesize currentTypesProcess;
+@synthesize mateTask;
+ (NSSet*)keyPathsForValuesAffectingRunning
{
@@ -88,6 +90,8 @@ NSString * const kJPAckWindowPosition = @"kJPAckWindowPosition";
preferences = prefs;
pasteboardChangeCount = NSNotFound;
+ mateTask = nil;
+
NSString* projectfile = [projectController filename] ? [projectController filename] : directory;
fileName = [[[projectfile lastPathComponent] stringByDeletingPathExtension] copy];
projectDirectory = [directory copy];
@@ -327,8 +331,18 @@ NSString * const kJPAckWindowPosition = @"kJPAckWindowPosition";
- (void)openProjectFile:(NSString*)file atLine:(NSString*)line selectionRange:(NSRange)selectionRange
{
NSString* absolute = [projectDirectory stringByAppendingPathComponent:file];
- [[[NSApplication sharedApplication] delegate] openFiles:[NSArray arrayWithObject:absolute]];
+ // [[[NSApplication sharedApplication] delegate] openFiles:[NSArray arrayWithObject:absolute]];
+
+ self.mateTask = [[[NSTask alloc] init] autorelease];
+
+ [self.mateTask setCurrentDirectoryPath:projectDirectory];
+ [self.mateTask setLaunchPath:@"/usr/bin/env"];
+ NSMutableArray* args = [NSMutableArray arrayWithObjects:@"mate", absolute, nil];
+ [self.mateTask setArguments:args];
+
+ [self.mateTask launch];
+
for (NSWindow *w in [[NSApplication sharedApplication] orderedWindows])
{
id wc = [w windowController];
--
1.7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment