Skip to content

Commit

Permalink
Use *group-number-map* in select-group.
Browse files Browse the repository at this point in the history
  • Loading branch information
dangerousben committed Mar 17, 2011
1 parent 9bbdb2e commit 0375162
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions command.lisp
Expand Up @@ -409,18 +409,17 @@ then describes the symbol."

(defun select-group (screen query)
"Attempt to match string QUERY against group number or partial name."
(let ((num (ignore-errors (parse-integer query))))
(labels ((match-whole (grp)
(string-equal (group-name grp) query))
(match-partial (grp)
(let* ((end (min (length (group-name grp)) (length query))))
(string-equal (group-name grp) query :end1 end :end2 end)))
(match-num (grp)
(eql (group-number grp) num)))
(when query
(or (find-if #'match-whole (screen-groups screen))
(find-if #'match-partial (screen-groups screen))
(find-if #'match-num (screen-groups screen)))))))
(labels ((match-num (grp)
(string-equal (princ-to-string (group-map-number grp)) query))
(match-whole (grp)
(string-equal (group-name grp) query))
(match-partial (grp)
(let* ((end (min (length (group-name grp)) (length query))))
(string-equal (group-name grp) query :end1 end :end2 end))))
(when query
(or (find-if #'match-num (screen-groups screen))
(find-if #'match-whole (screen-groups screen))
(find-if #'match-partial (screen-groups screen))))))

(define-stumpwm-type :group (input prompt)
(let ((match (select-group (current-screen)
Expand Down

0 comments on commit 0375162

Please sign in to comment.