Skip to content

Commit ee30c4b

Browse files
committed
add support for tag-based limiter
* gist.el (gist-parse-tags): parse simple tags query with positive and negative tags (gist-list-push-tag-limit): acivate tag limit
1 parent b424aff commit ee30c4b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

gist.el

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ put it into `kill-ring'."
609609
(define-key map "^" 'gist-unstar)
610610
(define-key map "f" 'gist-fork)
611611
(define-key map "/p" 'gist-list-push-visibility-limit)
612+
(define-key map "/t" 'gist-list-push-tag-limit)
612613
(define-key map "/w" 'gist-list-pop-limit)
613614
map))
614615

@@ -642,6 +643,39 @@ put it into `kill-ring'."
642643
gist-list-limits)
643644
(gist-list-user 'current-user))
644645

646+
(defun gist-parse-tags (tags)
647+
(let ((words (split-string tags))
648+
with without)
649+
(dolist (w words)
650+
(cond ((string-prefix-p "+" w)
651+
(push (substring w 1) with))
652+
((string-prefix-p "-" w)
653+
(push (substring w 1) without))
654+
(t
655+
(push w with))))
656+
(list with without)))
657+
658+
(defun gist-list-push-tag-limit (tags)
659+
(interactive "sTags: ")
660+
(let* ((lsts (gist-parse-tags tags))
661+
(with (car lsts))
662+
(without (cadr lsts)))
663+
(push (apply-partially (lambda (with without g)
664+
(and
665+
(every (lambda (tag)
666+
(string-match-p
667+
(format "#%s\\>" tag)
668+
(oref g :description)))
669+
with)
670+
(not (some (lambda (tag)
671+
(string-match-p
672+
(format "#%s\\>" tag)
673+
(oref g :description)))
674+
without))))
675+
with without)
676+
gist-list-limits))
677+
(gist-list-user 'current-user))
678+
645679
(defun gist-list-apply-limits (gists)
646680
(condition-case nil
647681
(delete nil

0 commit comments

Comments
 (0)