Skip to content

Commit

Permalink
Added sanity checks to add-group.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Moore Liles committed Aug 26, 2007
1 parent a54755f commit 15cb3d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 12 additions & 10 deletions core.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,18 @@ Groups are known as \"virtual desktops\" in the NETWM standard."
(defun add-group (screen name)
(check-type screen screen)
(check-type name string)
(let* ((initial-frame (make-initial-frame screen))
(ng (make-tile-group
:frame-tree initial-frame
:current-frame initial-frame
:screen screen
:number (find-free-group-number screen (if (equal (elt name 0) #\.) - 1))
:name name)))
(setf (screen-groups screen) (append (screen-groups screen) (list ng)))
(netwm-set-group-properties screen)
ng))
(unless (or (equal name "") (equal name "."))
(or (find-group screen name)
(let* ((initial-frame (make-initial-frame screen))
(ng (make-tile-group
:frame-tree initial-frame
:current-frame initial-frame
:screen screen
:number (find-free-group-number screen (if (equal (elt name 0) #\.) -1 0))
:name name)))
(setf (screen-groups screen) (append (screen-groups screen) (list ng)))
(netwm-set-group-properties screen)
ng))))

(defun find-group (screen name)
"Return the group with the name, NAME. Or NIL if none exists."
Expand Down
6 changes: 4 additions & 2 deletions user.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,10 @@ be found, select it. Otherwise simply run cmd."
(switch-to-group ng))))

(define-stumpwm-command "gnew" ((name :string "Group Name: "))
(switch-to-group (or (find-group (current-screen) name)
(add-group (current-screen) name))))
(let ((group (add-group (current-screen) name)))
(if group
(switch-to-group group)
(message "Groups must have a name!"))))

(define-stumpwm-command "gnewbg" ((name :string "Group Name: "))
(unless (find-group (current-screen) name)
Expand Down

0 comments on commit 15cb3d2

Please sign in to comment.