Skip to content

Commit e4d3a9e

Browse files
author
Alex Ross
committed
• Removing the useless "Triple Quote Selection" commands.
• Improved docmate. Currently, searches a local index file, and loads documentation for current word from http://docs.python.org. If there is more than one possible match, displayes a tm_dialog menu. This is pretty effective, the only drawback is that you have to be online to use it. I will add support for offline docs very soon. The command also remembers what docs you look at the most, so will list them in order of popularity. • Added a macro to forward and backward delete two quotes when pressing ⌫ inside of an empty triple-quoted string. • Made the scope for `Inside String: Insert "…"` more specific. git-svn-id: http://svn.textmate.org/trunk/Bundles/Python.tmbundle@6312 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
1 parent c2be0cf commit e4d3a9e

11 files changed

Lines changed: 54066 additions & 117 deletions

Commands/Documentation in Browser.plist

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,45 @@
55
<key>beforeRunningCommand</key>
66
<string>nop</string>
77
<key>command</key>
8-
<string>TPY=${TM_PYTHON:-python}
8+
<string>#!/usr/bin/env python
9+
# -*- coding: UTF-8 -*-
10+
import sys
11+
from sys import exit
12+
from os import environ as env
13+
import os.path
14+
sys.path.append(os.path.join(env["TM_BUNDLE_SUPPORT"], "DocMate"))
15+
sys.path.append(os.path.join(env["TM_SUPPORT_PATH"], "lib"))
916
10-
echo '&lt;html&gt;&lt;body&gt;'
11-
"$TPY" "${TM_BUNDLE_SUPPORT}/browse_pydocs.py"
12-
echo '&lt;/body&gt;&lt;/html&gt;'</string>
17+
from docmate import doc, increment_hitcount
18+
import dialog
19+
20+
word = env["TM_CURRENT_WORD"]
21+
22+
if "TM_PYTHON_DOCPATH" in env:
23+
path_to_doc = env["TM_PYTHON_DOCPATH"]
24+
else:
25+
path_to_doc = "http://docs.python.org/lib/"
26+
27+
opts = doc(word)
28+
url = dialog.menu(opts)
29+
30+
if url:
31+
increment_hitcount(url)
32+
url = os.path.join(path_to_doc, url)
33+
print "&lt;meta http-equiv='Refresh' content='0;URL=%s'&gt;" % url
34+
exit(205) # show as html.
35+
else:
36+
print "Didn't find any documentation for %s." % word
37+
exit(206) # show as tooltip.
38+
</string>
1339
<key>input</key>
1440
<string>none</string>
1541
<key>keyEquivalent</key>
1642
<string>^h</string>
1743
<key>name</key>
1844
<string>Documentation in Browser</string>
1945
<key>output</key>
20-
<string>showAsHTML</string>
46+
<string>showAsTooltip</string>
2147
<key>scope</key>
2248
<string>source.python</string>
2349
<key>uuid</key>

Commands/Triple Quote Selection (Double Quotes).tmCommand

Lines changed: 0 additions & 28 deletions
This file was deleted.

Commands/Triple Quote Selection (Single Quotes).tmCommand

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>commands</key>
6+
<array>
7+
<dict>
8+
<key>command</key>
9+
<string>deleteForward:</string>
10+
</dict>
11+
<dict>
12+
<key>command</key>
13+
<string>deleteForward:</string>
14+
</dict>
15+
<dict>
16+
<key>command</key>
17+
<string>deleteBackward:</string>
18+
</dict>
19+
<dict>
20+
<key>command</key>
21+
<string>deleteBackward:</string>
22+
</dict>
23+
</array>
24+
<key>keyEquivalent</key>
25+
<string></string>
26+
<key>name</key>
27+
<string>Inside Empty Block String: Reduce To Single Quoted String</string>
28+
<key>scope</key>
29+
<string>source.python string.quoted.single.block meta.empty-string, source.python string.quoted.double.block meta.empty-string</string>
30+
<key>uuid</key>
31+
<string>8C6C3826-E2AD-410D-9B18-1567F86F7569</string>
32+
</dict>
33+
</plist>

Snippets/Inside String: Insert "…".tmSnippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>name</key>
1010
<string>Inside String: Insert "…"</string>
1111
<key>scope</key>
12-
<string>source.python meta.empty-string.double.python</string>
12+
<string>source.python string.quoted.double.single-line meta.empty-string.double</string>
1313
<key>uuid</key>
1414
<string>44F64180-F86E-4980-895A-2994B0EEDB5D</string>
1515
</dict>

Snippets/Inside String: Insert '…'.tmSnippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>name</key>
1010
<string>Inside String: Insert '…'</string>
1111
<key>scope</key>
12-
<string>source.python meta.empty-string.single.python</string>
12+
<string>source.python string.quoted.single.single-line meta.empty-string.single</string>
1313
<key>uuid</key>
1414
<string>1BAD838C-8B2A-45FD-9AD2-7F3DCA2DD388</string>
1515
</dict>

0 commit comments

Comments
 (0)