--- autoaway.tcl	2006-08-03 14:42:15.432388800 +0400
+++ autoaway.tcl,patched	2006-08-03 14:41:48.651824400 +0400
@@ -58,9 +58,19 @@
 Tkabber is moving to away state."] \
 	-group AutoAway -type string
 
-    custom::defvar options(drop_priority) 1 \
-	[::msgcat::mc "Set priority to 0 when moving to extended away state."] \
+    custom::defvar options(change_priority_away) 1 \
+	[::msgcat::mc "Change priority when moving to away state."] \
 	-group AutoAway -type boolean
+    custom::defvar options(priority_away) 0 \
+	[::msgcat::mc "Priority value to set when moving to away state."] \
+	-group AutoAway -type integer
+
+    custom::defvar options(change_priority_xa) 1 \
+	[::msgcat::mc "Change priority when moving to extended away state."] \
+	-group AutoAway -type boolean
+    custom::defvar options(priority_xa) 0 \
+	[::msgcat::mc "Priority value to set when moving to extended away state."] \
+	-group AutoAway -type integer
 
     hook::add connected_hook    [namespace current]::after_idle
     hook::add disconnected_hook [namespace current]::after_idle_cancel
@@ -99,10 +109,11 @@
 
     if {[set idletime [$idle_command]] < [expr {$options(awaytime)*60*1000}]} {
         if {![cequal $savestatus ""]} {
-	    if {$options(drop_priority) && ($userpriority >= 0)} {
+	    if {($options(change_priority_away) || $options(change_priority_xa)) \
+	    && ($userpriority >= 0)} {
 		set userpriority $savepriority
 	    }
-	    set savepriority 0
+	    catch { unset savepriority }
 	    set textstatus $savetext
 	    set savetext ""
             set userstatus $savestatus
@@ -121,12 +132,15 @@
 	    set savepriority $userpriority
             set textstatus $options(status)
             if {$idletime >= [expr {$options(xatime)*60*1000}]} {
-		if {$options(drop_priority) && ($userpriority >= 0)} {
-		    set userpriority 0
+		if {$options(change_priority_xa) && ($userpriority >= 0)} {
+		    set userpriority $options(priority_xa)
 		}
                 set userstatus xa
                 set_status [::msgcat::mc "Moving to extended away"]
             } else {
+		if {$options(change_priority_away) && ($userpriority >= 0)} {
+		    set userpriority $options(priority_away)
+		}
                 set userstatus away
                 set_status [::msgcat::mc "Starting auto-away"]
             }
@@ -136,10 +150,12 @@
         away {
             if {(![cequal $savestatus ""]) && \
 		    ($idletime >= [expr {$options(xatime)*60*1000}])} {
-		set savepriority $userpriority
+		if {![info exists savepriority]} {
+		    set savepriority $userpriority
+		}
 		set textstatus $options(status)
-		if {$options(drop_priority) && ($userpriority >= 0)} {
-		    set userpriority 0
+		if {$options(change_priority_xa) && ($userpriority >= 0)} {
+		    set userpriority $options(priority_xa)
 		}
                 set userstatus xa
                 set_status [::msgcat::mc "Moving to extended away"]
