Browse files

Add user setting to limit the Gists displayed in the `Open Gist` list…

… by prefix.
  • Loading branch information...
1 parent cc39105 commit abd79d1f4c057d59d772466bbf21fbc280ea5865 @hungrymedia committed Oct 13, 2012
Showing with 14 additions and 2 deletions.
  1. +5 −2 Gist.sublime-settings
  2. +4 −0 README.md
  3. +5 −0 gist.py
View
7 Gist.sublime-settings
@@ -17,5 +17,8 @@
"url": "",
// Max Gists to show (max 100 allowed by GitHub API)
- "max_gists": 100
-}
+ "max_gists": 100,
+
+ // Limit to gists with specific prefix
+ "gist_prefix": "Snippet:"
+}
View
4 README.md
@@ -43,6 +43,10 @@ If you're using OS X and have a keychain entry for github.com, no configuration
Set the maximum number of Gists that can will fetched by the plugin. It can't be higher than 100, because of GitHub API limitations.
+* `"gist_prefix": ""`
+
+ Limit the Gists displayed in the `Open Gist` list by prefix. Leave blank to display all Gists. Example: `"gist_prefix": "Snippet:"` will only list Gists with names starting with the text **Snippet:**.
+
# Usage
All functionality of the plugin is available in the `Tools` / `Gist` menu and in the command pallette.
View
5 gist.py
@@ -12,6 +12,7 @@
import traceback
import contextlib
import shutil
+import re
DEFAULT_CREATE_PUBLIC_VALUE = 'false'
DEFAULT_USE_PROXY_VALUE = 'false'
@@ -469,6 +470,10 @@ class GistListCommandBase(object):
def run(self, *args):
gists = get_gists()
gist_names = [gist_title(gist) for gist in gists]
+ if settings.get('gist_prefix'):
+ prefix_pattern = "^%s" % (settings.get('gist_prefix'))
+ gist_names = filter (lambda a: re.search(prefix_pattern, a), gist_names)
+ print gist_names
def on_gist_num(num):
if num != -1:

0 comments on commit abd79d1

Please sign in to comment.