Permalink
Browse files

• 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
  • Loading branch information...
lasersox committed Dec 8, 2006
1 parent c2be0cf commit e4d3a9ef7d89b6d945d31637e1ecb54dc69d9582
@@ -5,19 +5,45 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
- <string>TPY=${TM_PYTHON:-python}
+ <string>#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+import sys
+from sys import exit
+from os import environ as env
+import os.path
+sys.path.append(os.path.join(env["TM_BUNDLE_SUPPORT"], "DocMate"))
+sys.path.append(os.path.join(env["TM_SUPPORT_PATH"], "lib"))
-echo '&lt;html&gt;&lt;body&gt;'
-"$TPY" "${TM_BUNDLE_SUPPORT}/browse_pydocs.py"
-echo '&lt;/body&gt;&lt;/html&gt;'</string>
+from docmate import doc, increment_hitcount
+import dialog
+
+word = env["TM_CURRENT_WORD"]
+
+if "TM_PYTHON_DOCPATH" in env:
+ path_to_doc = env["TM_PYTHON_DOCPATH"]
+else:
+ path_to_doc = "http://docs.python.org/lib/"
+
+opts = doc(word)
+url = dialog.menu(opts)
+
+if url:
+ increment_hitcount(url)
+ url = os.path.join(path_to_doc, url)
+ print "&lt;meta http-equiv='Refresh' content='0;URL=%s'&gt;" % url
+ exit(205) # show as html.
+else:
+ print "Didn't find any documentation for %s." % word
+ exit(206) # show as tooltip.
+</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^h</string>
<key>name</key>
<string>Documentation in Browser</string>
<key>output</key>
- <string>showAsHTML</string>
+ <string>showAsTooltip</string>
<key>scope</key>
<string>source.python</string>
<key>uuid</key>
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>beforeRunningCommand</key>
- <string>nop</string>
- <key>command</key>
- <string>if [ -n "$TM_SELECTED_TEXT" ]; then
- echo -n '"""$TM_SELECTED_TEXT"""$0'
-else
- echo -n '"""$0"""'
-fi</string>
- <key>fallbackInput</key>
- <string>none</string>
- <key>input</key>
- <string>selection</string>
- <key>keyEquivalent</key>
- <string>^"</string>
- <key>name</key>
- <string>Triple Quote Selection (Double Quotes)</string>
- <key>output</key>
- <string>insertAsSnippet</string>
- <key>scope</key>
- <string>source.python</string>
- <key>uuid</key>
- <string>FFBE5EDC-D4C2-4412-A381-E59D40BF910A</string>
-</dict>
-</plist>
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>beforeRunningCommand</key>
- <string>nop</string>
- <key>command</key>
- <string>if [ -n "$TM_SELECTED_TEXT" ]; then
- echo -n "'''$TM_SELECTED_TEXT'''\$0"
-else
- echo -n "'''\$0'''"
-fi</string>
- <key>fallbackInput</key>
- <string>none</string>
- <key>input</key>
- <string>selection</string>
- <key>keyEquivalent</key>
- <string>^'</string>
- <key>name</key>
- <string>Triple Quote Selection (Single Quotes)</string>
- <key>output</key>
- <string>insertAsSnippet</string>
- <key>scope</key>
- <string>source.python</string>
- <key>uuid</key>
- <string>77359DF3-E248-45CE-9A51-AFE55329A725</string>
-</dict>
-</plist>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>commands</key>
+ <array>
+ <dict>
+ <key>command</key>
+ <string>deleteForward:</string>
+ </dict>
+ <dict>
+ <key>command</key>
+ <string>deleteForward:</string>
+ </dict>
+ <dict>
+ <key>command</key>
+ <string>deleteBackward:</string>
+ </dict>
+ <dict>
+ <key>command</key>
+ <string>deleteBackward:</string>
+ </dict>
+ </array>
+ <key>keyEquivalent</key>
+ <string></string>
+ <key>name</key>
+ <string>Inside Empty Block String: Reduce To Single Quoted String</string>
+ <key>scope</key>
+ <string>source.python string.quoted.single.block meta.empty-string, source.python string.quoted.double.block meta.empty-string</string>
+ <key>uuid</key>
+ <string>8C6C3826-E2AD-410D-9B18-1567F86F7569</string>
+</dict>
+</plist>
@@ -9,7 +9,7 @@
<key>name</key>
<string>Inside String: Insert "…"</string>
<key>scope</key>
- <string>source.python meta.empty-string.double.python</string>
+ <string>source.python string.quoted.double.single-line meta.empty-string.double</string>
<key>uuid</key>
<string>44F64180-F86E-4980-895A-2994B0EEDB5D</string>
</dict>
@@ -9,7 +9,7 @@
<key>name</key>
<string>Inside String: Insert '…'</string>
<key>scope</key>
- <string>source.python meta.empty-string.single.python</string>
+ <string>source.python string.quoted.single.single-line meta.empty-string.single</string>
<key>uuid</key>
<string>1BAD838C-8B2A-45FD-9AD2-7F3DCA2DD388</string>
</dict>
Oops, something went wrong.

0 comments on commit e4d3a9e

Please sign in to comment.