Browse Source

Pre-pend public routine

Alois Mahdal 9 years ago
parent
commit
c2b98de96a
1 changed files with 47 additions and 47 deletions
  1. 47
    47
      src/ffoo/saturnin_urimagic.sh

+ 47
- 47
src/ffoo/saturnin_urimagic.sh View File

@@ -4,6 +4,53 @@ ffoo import inigrep
4 4
 ffoo import pretty
5 5
 
6 6
 
7
+saturnin_urimagic__scan() {
8
+    #
9
+    # Scan stdin for what looks like URI, ID or keyword
10
+    #
11
+    # Output URIs: first what were apparent uris, then IDs converted to
12
+    # URIs, then equal sign expressions, then "tags" like bug1234 (i.e.
13
+    # letters+nubmbers, no spaces), then things that looked like
14
+    # kw expressions, converted to URIs.
15
+    #
16
+    # Note that kw expressions (e.g. "bug 123") work only if they start
17
+    # the line.
18
+    #
19
+    # Apply this filter to args or clipboard, and either use head -1 or
20
+    # if you are brave, open all URIs.
21
+    #
22
+    local d=$(mktemp -d -t saturnin_urimagic.XXXXXXXX)
23
+    local p=__saturnin_urimagic__
24
+    pushd $d >&/dev/null
25
+        ##
26
+        # heat up and fill pipes
27
+        #
28
+        mkfifo maybe_uris maybe_ids maybe_exps maybe_tags maybe_kws \
29
+               uris uris_from_ids uris_from_exps uris_from_tags uris_from_kws
30
+        cat | tee maybe_uris maybe_ids maybe_exps maybe_tags maybe_kws \
31
+            >/dev/null &
32
+        ##
33
+        # process each pipe *async* by different filter
34
+        #
35
+        < maybe_uris ${p}flt_uris             > uris &
36
+        < maybe_ids  ${p}flt_ids  | ${p}deref > uris_from_ids &
37
+        < maybe_exps ${p}flt_exps | ${p}deref > uris_from_exps &
38
+        < maybe_tags ${p}flt_tags | ${p}deref > uris_from_tags &
39
+        < maybe_kws  ${p}flt_kws  | ${p}deref > uris_from_kws &
40
+        ##
41
+        # print result *sync* in correct order
42
+        #
43
+        {
44
+            cat uris
45
+            cat uris_from_ids
46
+            cat uris_from_exps
47
+            cat uris_from_tags
48
+            cat uris_from_kws
49
+        } | grep .  # throw away empties; add missing LF
50
+    popd >&/dev/null
51
+    rm -rf $d
52
+}
53
+
7 54
 __saturnin_urimagic__deref() {
8 55
     #
9 56
     # Turn keyword or query (like "g hello" for google) to URI
@@ -79,50 +126,3 @@ __saturnin_urimagic__flt_uris() {
79 126
             print "$1\n";
80 127
         '
81 128
 }
82
-
83
-saturnin_urimagic__scan() {
84
-    #
85
-    # Scan stdin for what looks like URI, ID or keyword
86
-    #
87
-    # Output URIs: first what were apparent uris, then IDs converted to
88
-    # URIs, then equal sign expressions, then "tags" like bug1234 (i.e.
89
-    # letters+nubmbers, no spaces), then things that looked like
90
-    # kw expressions, converted to URIs.
91
-    #
92
-    # Note that kw expressions (e.g. "bug 123") work only if they start
93
-    # the line.
94
-    #
95
-    # Apply this filter to args or clipboard, and either use head -1 or
96
-    # if you are brave, open all URIs.
97
-    #
98
-    local d=$(mktemp -d -t saturnin_urimagic.XXXXXXXX)
99
-    local p=__saturnin_urimagic__
100
-    pushd $d >&/dev/null
101
-        ##
102
-        # heat up and fill pipes
103
-        #
104
-        mkfifo maybe_uris maybe_ids maybe_exps maybe_tags maybe_kws \
105
-               uris uris_from_ids uris_from_exps uris_from_tags uris_from_kws
106
-        cat | tee maybe_uris maybe_ids maybe_exps maybe_tags maybe_kws \
107
-            >/dev/null &
108
-        ##
109
-        # process each pipe *async* by different filter
110
-        #
111
-        < maybe_uris ${p}flt_uris             > uris &
112
-        < maybe_ids  ${p}flt_ids  | ${p}deref > uris_from_ids &
113
-        < maybe_exps ${p}flt_exps | ${p}deref > uris_from_exps &
114
-        < maybe_tags ${p}flt_tags | ${p}deref > uris_from_tags &
115
-        < maybe_kws  ${p}flt_kws  | ${p}deref > uris_from_kws &
116
-        ##
117
-        # print result *sync* in correct order
118
-        #
119
-        {
120
-            cat uris
121
-            cat uris_from_ids
122
-            cat uris_from_exps
123
-            cat uris_from_tags
124
-            cat uris_from_kws
125
-        } | grep .  # throw away empties; add missing LF
126
-    popd >&/dev/null
127
-    rm -rf $d
128
-}