Skip to content

Commit 742cbc8

Browse files
committed
“Documentation for Word”: Prompt for input if no current word
1 parent ba95d7b commit 742cbc8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Commands/man.plist

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
1111
word=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
1212
13+
if [[ $word = '' ]]; then
14+
cat <<-'RUBYEOF' > /tmp/textmate-command-$$.rb
15+
require ENV["TM_SUPPORT_PATH"] + "/lib/ui.rb"
16+
puts TextMate::UI.request_string(
17+
:title => "Documentation for Word / Selection",
18+
:prompt => "Lookup Documentation for: "
19+
).to_s
20+
RUBYEOF
21+
22+
word=$(ruby18 -wKU /tmp/textmate-command-$$.rb)
23+
rm /tmp/textmate-command-$$.rb
24+
fi
25+
1326
try_help () {
1427
if help "$word" &>/dev/null; then
1528
source "$TM_SUPPORT_PATH/lib/webpreview.sh"
@@ -24,10 +37,12 @@ try_help () {
2437
fi
2538
}
2639
27-
MANSECT=${MANSECT:-2:3:4:5:6:7:8:9} try_help
28-
try_help
40+
if [[ $word != '' ]]; then
41+
MANSECT=${MANSECT:-2:3:4:5:6:7:8:9} try_help
42+
try_help
2943
30-
echo "Couldn’t find documentation for “${word}”"
44+
echo "Couldn’t find documentation for “${word}”"
45+
fi
3146
</string>
3247
<key>fallbackInput</key>
3348
<string>word</string>

0 commit comments

Comments
 (0)