Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add user setting to limit the Gists displayed in "Open Gist" #46

Merged
merged 1 commit into from

2 participants

@hungrymedia

Add user setting to limit the Gists displayed in the Open Gist list by prefix.

@condemil condemil merged commit 89f07af into condemil:master
@condemil
Owner

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 13, 2012
  1. @hungrymedia
This page is out of date. Refresh to see the latest.
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:
Something went wrong with that request. Please try again.