]> git.mdlowis.com Git - projs/tide.git/commitdiff
update tfetch to fix commands, also added flag for specifying line number
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 9 Oct 2018 03:03:48 +0000 (23:03 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 9 Oct 2018 03:03:48 +0000 (23:03 -0400)
tfetch
tide.c
topen [new file with mode: 0755]

diff --git a/tfetch b/tfetch
index cf78951014397f6ccf95c829f170c32b21f2a06d..48b41768c4677306c2064010fe6343f13009ce47 100755 (executable)
--- a/tfetch
+++ b/tfetch
@@ -57,11 +57,9 @@ def unset(var)
 end
 
 def exec(cmd)
-    require 'pp'
-    pp expand(cmd)
-    #if not system(expand(cmd)) then
-    #    raise "command failed"
-    #end
+    if not system(expand(cmd)) then
+        raise "command failed"
+    end
 end
 
 def launch(cmd)
@@ -86,14 +84,14 @@ rule do
     matches "data", "\\.[ch]$"
     is_dir "Code"
     exec "[[ $$(find Code -type f -name '*$data') ]]"
-    launch "find Code -type f -name '*$data' | xargs -r $EDITOR"
+    launch "find . -type f -name '*$data' -exec '$EDITOR' '{}' \;"
 end
 
 # Match URLS and open them with the browser
 rule do
     is_set "BROWSER"
     matches "data", "^(https?|ftp)://.*"
-    launch "$BROWSER $0"
+    launch "'$BROWSER' '$0'"
 end
 
 # Open files with addresses in the editor
@@ -101,7 +99,7 @@ rule do
     is_set "EDITOR"
     matches "data", "^([^:]+):([0-9]+)"
     is_file "$1"
-    launch "tctl $0"
+    launch "tctl '$0'"
 end
 
 # If it's an existing text file, open it with editor
@@ -109,7 +107,7 @@ rule do
     is_set "EDITOR"
     is_file "$data"
     exec "file --mime '$file' | grep -q 'text/'"
-    launch "$EDITOR $file"
+    launch "'$EDITOR' '$file'"
 end
 
 # Look it up in ctags database
@@ -117,13 +115,13 @@ rule do
     is_set "EDITOR"
     is_file "tags"
     exec "grep -q '^$data\\s\\+' tags"
-    launch "picktag fetch tags $data | xargs -r tide"
+    launch "topen \"$$(picktag fetch tags '$data')\""
 end
 
 # If it's an existing directory, open it with system default
 rule do
     is_dir "$data"
-    launch "open $data"
+    launch "open '$data'"
 end
 
 exit 1 #if we made it here then no rules matched
diff --git a/tide.c b/tide.c
index b6721ec75cb28a9d794b04b90f51659350ff6438..32b58aff76c72a0ce5b3b4df3899486f99073663 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -498,7 +498,7 @@ int main(int argc, char** argv) {
         char* path = realpath(*argv, NULL);
         if (!path) path = *argv; /* if file doesnt exist, use the original name */
         view_init(win_view(EDIT), path);
-        view_setln(win_view(EDIT), line_num);
+        if (line_num) view_setln(win_view(EDIT), line_num);
         win_title(path);
         win_prop_set("TIDE_FILE", "file", path);
     } else {
diff --git a/topen b/topen
new file mode 100755 (executable)
index 0000000..f7f82a1
--- /dev/null
+++ b/topen
@@ -0,0 +1,3 @@
+#!/bin/sh
+file="$1"
+[ -f "$1" ] && tide "$1"
\ No newline at end of file