[Tkabber-dev] r535 - branches/plugins-0.11.1/juick

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jul 21 18:59:50 MSK 2013


Author: Totktonada
Date: 2013-07-21 18:59:50 +0400 (Sun, 21 Jul 2013)
New Revision: 535

Modified:
   branches/plugins-0.11.1/juick/juick.tcl
   branches/plugins-0.11.1/juick/tkabber-0.11.1-compatibility.tcl
Log:
Juick plugin (svn branch):

* Optimize 'expr' usage and few indent fixes.
* Fix string comparison by 'expr'.


Modified: branches/plugins-0.11.1/juick/juick.tcl
===================================================================
--- branches/plugins-0.11.1/juick/juick.tcl	2013-07-21 14:59:17 UTC (rev 534)
+++ branches/plugins-0.11.1/juick/juick.tcl	2013-07-21 14:59:50 UTC (rev 535)
@@ -140,15 +140,15 @@
 proc is_juick_jid {jid} {
     set jid [::xmpp::jid::removeResource $jid]
     set node [::xmpp::jid::node $jid]
-    return [expr [string equal $jid "juick at juick.com"] || \
-        [string equal $node "juick%juick.com"]]
+    return [expr {[string equal $jid "juick at juick.com"] || \
+        [string equal $node "juick%juick.com"]}]
 
 #    if {$without_resource} { \
-#        return [expr [string equal $jid "juick at juick.com"] \
-#           || [regexp "juick%juick.com at .+" $jid]] \
+#        return [expr {[string equal $jid "juick at juick.com"] \
+#           || [regexp "juick%juick.com at .+" $jid]}] \
 #    } else { \
-#       return [expr [string equal $jid "juick at juick.com/Juick"] \
-#           || [regexp "juick%juick.com at .+/Juick" $jid]] \
+#       return [expr {[string equal $jid "juick at juick.com/Juick"] \
+#           || [regexp "juick%juick.com at .+/Juick" $jid]}] \
 #    }
 }
 
@@ -240,13 +240,13 @@
             [get_juick_nickname $from] $reply_to_nick]
     }
 
-    return [expr $private_msg || $reply_to_my_comment]
+    return [expr {$private_msg || $reply_to_my_comment}]
 }
 
 proc update_juick_tab {chatid from type body x} {
     variable options
-    if {![expr [is_juick_jid $from] && [string equal $type "chat"] \
-        && $options(special_update_juick_tab)]} \
+    if {!([is_juick_jid $from] && [string equal $type "chat"] \
+        && $options(special_update_juick_tab))} \
     {
         ::plugins::update_tab::update $chatid $from $type $body $x
         return
@@ -272,15 +272,15 @@
 }
 
 proc ignore_server_messages {chatid from type body x} {
-    if {[is_juick $chatid] && $from == ""} {
-        return stop;
+    if {[is_juick $chatid] && $from eq ""} {
+        return stop
     }
 }
 
 proc add_number_of_messages_from_juick_to_title {chatid from type body x} {
     variable options
-    if {![expr [is_juick_jid $from] && [string equal $type "chat"] \
-        && $options(special_update_juick_tab)]} \
+    if {!([is_juick_jid $from] && [string equal $type "chat"] \
+        && $options(special_update_juick_tab))} \
     {
         ::ifacetk::add_number_of_messages_to_title $chatid $from $type \
             $body $x
@@ -298,7 +298,7 @@
     }
 
     if {[::ifacetk::chat_window_is_active $chatid]} return
-    if {$from == ""} return
+    if {$from eq ""} return
 
     variable ::ifacetk::number_msg
     variable ::ifacetk::personal_msg
@@ -384,7 +384,7 @@
         set thing [string range [lindex $tags $idx] 6 end]
     }
 
-    if {$thing == ""} return
+    if {$thing eq ""} return
 
     if {![is_juick_jid $jid]} {
         set xlib [chat::get_xlib $chatid]
@@ -412,7 +412,7 @@
         set thing [string range [lindex $tags $idx] 6 end]
     }
 
-    if {$thing == ""} return
+    if {$thing eq ""} return
 
     $m add command -label [::msgcat::mc \
         "\[J\] Copy thing to clipboard."] \
@@ -674,20 +674,21 @@
             continue
         }
 
-        if {[expr [lsearch -exact $type citing]>=0]} {
-        lappend tags CITING
+        if {[lsearch -exact $type citing] >=0} {
+            lappend tags CITING
         }
 
-        if {[expr [lsearch -exact $type juick_ligth]>=0]} {
-        lappend tags JLIGTH
+        if {[lsearch -exact $type juick_ligth] >= 0} {
+            lappend tags JLIGTH
         }
 
         set index 0; set uStart 0; set uEnd 0
         while {[eval {spot_$what $s $index uStart uEnd}]} {
             if {$uStart - $index > 0} {
                 # Write out text before current thing, if any:
-                lappend out [string range $s $index \
-                    [expr {$uStart - 1}]] $type $tags
+                lappend out \
+                    [string range $s $index [expr {$uStart - 1}]] \
+                    $type $tags
             }
 
             set thing [string range $s $uStart $uEnd]
@@ -697,21 +698,21 @@
         }
         # Write out text after the last thing, if any:
         if {[string length $s] - $index > 0} {
-        lappend out [string range $s $index end] $type $tags
+            lappend out [string range $s $index end] $type $tags
         }
     }
     set chunks $out
 }
 
 proc render_juick {w type thing tags args} {
-    if {[expr [lsearch -exact $tags CITING] < 0] && \
-        [expr [lsearch -exact $tags JLIGTH] < 0]} \
+    if {[lsearch -exact $tags CITING] < 0 && \
+        [lsearch -exact $tags JLIGTH] < 0} \
     {
-        if {[string equal [string index $thing 0] "#" ]} {
+        if {[string equal [string index $thing 0] "#"]} {
             set type JNUM
-        } elseif {[string equal [string index $thing 0] "*" ]} {
+        } elseif {[string equal [string index $thing 0] "*"]} {
             set type JTAG
-        } elseif {[string equal [string index $thing 0] "@" ]} {
+        } elseif {[string equal [string index $thing 0] "@"]} {
             set type JNICK
         }
     } else {

Modified: branches/plugins-0.11.1/juick/tkabber-0.11.1-compatibility.tcl
===================================================================
--- branches/plugins-0.11.1/juick/tkabber-0.11.1-compatibility.tcl	2013-07-21 14:59:17 UTC (rev 534)
+++ branches/plugins-0.11.1/juick/tkabber-0.11.1-compatibility.tcl	2013-07-21 14:59:50 UTC (rev 535)
@@ -9,7 +9,7 @@
 proc ::hook::add {hook func {seq 50}} {
     if {[string equal $hook roster_push_hook] && \
         [string equal $func "::plugins::juick::request_juick_nick"] && \
-        [expr $seq == 99]} \
+        $seq == 99} \
     {
         ::hook::add_orig roster_item_hook $func $seq
     } else {
@@ -197,7 +197,7 @@
 proc ::message::send_msg {xlib args} {
     set invoke [list ::message::send_msg_tkabber_0_11_1]
 
-    if {[expr [llength $args] % 2] == 0} {
+    if {[llength $args] % 2 == 0} {
         # tkabber-0.11.1 invoke
         set jid $xlib
         lappend invoke $jid



More information about the Tkabber-dev mailing list