Skip to content

Commit

Permalink
Merge pull request #46 from hungrymedia/gist_prefix
Browse files Browse the repository at this point in the history
Add user setting to limit the Gists displayed in "Open Gist"
  • Loading branch information
condemil committed Oct 13, 2012
2 parents 8be61c4 + abd79d1 commit 89f07af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Gist.sublime-settings
Expand Up @@ -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:"
}
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -47,6 +47,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.
Expand Down
5 changes: 5 additions & 0 deletions gist.py
Expand Up @@ -12,6 +12,7 @@
import traceback
import contextlib
import shutil
import re

DEFAULT_CREATE_PUBLIC_VALUE = 'false'
DEFAULT_USE_PROXY_VALUE = 'false'
Expand Down Expand Up @@ -488,6 +489,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:
Expand Down

0 comments on commit 89f07af

Please sign in to comment.