From 6499586dde4866f4e0ee2bb92e7816bf201072f5 Mon Sep 17 00:00:00 2001 From: Matt Spear Date: Thu, 17 Mar 2011 01:10:43 -0700 Subject: [PATCH] add patches --- command.lisp | 23 +++++++++++------------ group.lisp | 2 +- primitives.lisp | 4 ++-- window.lisp | 23 ++++++++++++++--------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/command.lisp b/command.lisp index 07d1d60..4be5795 100644 --- a/command.lisp +++ b/command.lisp @@ -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) diff --git a/group.lisp b/group.lisp index 3117642..c980bb7 100644 --- a/group.lisp +++ b/group.lisp @@ -110,7 +110,7 @@ otherwise specified." (let* ((len (length *group-number-map*)) (num (group-number group))) (if (<= num len) - (char *group-number-map* (- num 1)) + (elt *group-number-map* (- num 1)) num))) (defun fmt-group-status (group) diff --git a/primitives.lisp b/primitives.lisp index 0749dfc..9d00265 100644 --- a/primitives.lisp +++ b/primitives.lisp @@ -471,10 +471,10 @@ exist, in which case they go into the current group.") (format stream "#S(frame ~d ~a ~d ~d ~d ~d)" (frame-number object) (frame-window object) (frame-x object) (frame-y object) (frame-width object) (frame-height object))) -(defvar *window-number-map* "0123456789" +(defvar *window-number-map* #(0 1 2 3 4 5 6 7 8 9) "Set this to a string to remap the window numbers to something more convinient.") -(defvar *group-number-map* "1234567890" +(defvar *group-number-map* #(1 2 3 4 5 6 7 8 9 10) "Set this to a string to remap the group numbers to something more convinient.") (defvar *frame-number-map* "0123456789abcdefghijklmnopqrstuvxwyz" diff --git a/window.lisp b/window.lisp index 9e6b9ac..86d2de2 100644 --- a/window.lisp +++ b/window.lisp @@ -256,7 +256,7 @@ _NET_WM_STATE_DEMANDS_ATTENTION set" (defun window-map-number (window) (let ((num (window-number window))) (or (and (< num (length *window-number-map*)) - (char *window-number-map* num)) + (elt *window-number-map* num)) num))) (defun fmt-window-status (window) @@ -874,14 +874,19 @@ window. Default to the current window. if (defcommand select-window (query) ((:window-name "Select: ")) "Switch to the first window that starts with @var{query}." (let (match) - (labels ((match (win) - (let* ((wname (window-name win)) - (end (min (length wname) (length query)))) - (string-equal wname query :end1 end :end2 end)))) - (unless (null query) - (setf match (find-if #'match (group-windows (current-group))))) - (when match - (group-focus-window (current-group) match))))) + (labels ((match-num (win) + (string-equal (princ-to-string (window-map-number win)) query)) + (match-whole (win) + (string-equal (window-name win) query)) + (match-partial (win) + (let* ((end (min (length (window-name win)) (length query)))) + (string-equal (window-name win) query :end1 end :end2 end)))) + (setf match + (when query + (or (find-if #'match-num (group-windows (current-group))) + (find-if #'match-whole (group-windows (current-group))) + (find-if #'match-partial (group-windows (current-group))))))) + (group-focus-window (current-group) match))) (defcommand-alias select select-window) -- 1.7.3.5