Skip to content
This repository

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

Merged
merged 1 commit into from over 1 year ago

2 participants

Warren Harrison Dmitry Budaev
Warren Harrison

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

Dmitry Budaev condemil merged commit 89f07af into from October 13, 2012
Dmitry Budaev condemil closed this October 13, 2012
Dmitry Budaev
Owner

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 13, 2012
Warren Harrison Add user setting to limit the Gists displayed in the `Open Gist` list…
… by prefix.
abd79d1
This page is out of date. Refresh to see the latest.
7  Gist.sublime-settings
@@ -17,5 +17,8 @@
17 17
 	"url": "",
18 18
 
19 19
 	// Max Gists to show (max 100 allowed by GitHub API)
20  
-	"max_gists": 100
21  
-}
  20
+	"max_gists": 100, 
  21
+
  22
+	// Limit to gists with specific prefix
  23
+	"gist_prefix": "Snippet:"
  24
+}
4  README.md
Source Rendered
@@ -43,6 +43,10 @@ If you're using OS X and have a keychain entry for github.com, no configuration
43 43
 
44 44
 	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.
45 45
 
  46
+* `"gist_prefix": ""`
  47
+
  48
+	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:**.
  49
+
46 50
 # Usage
47 51
 
48 52
 All functionality of the plugin is available in the `Tools` / `Gist` menu and in the command pallette.
5  gist.py
@@ -12,6 +12,7 @@
12 12
 import traceback
13 13
 import contextlib
14 14
 import shutil
  15
+import re
15 16
 
16 17
 DEFAULT_CREATE_PUBLIC_VALUE = 'false'
17 18
 DEFAULT_USE_PROXY_VALUE = 'false'
@@ -469,6 +470,10 @@ class GistListCommandBase(object):
469 470
     def run(self, *args):
470 471
         gists = get_gists()
471 472
         gist_names = [gist_title(gist) for gist in gists]
  473
+        if settings.get('gist_prefix'):
  474
+            prefix_pattern = "^%s" % (settings.get('gist_prefix'))
  475
+            gist_names = filter (lambda a: re.search(prefix_pattern, a), gist_names)
  476
+        print gist_names
472 477
 
473 478
         def on_gist_num(num):
474 479
             if num != -1:
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.