From 3803327b68eb746f8f3999e5e1b43138d3e39b4f Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 8 Sep 2005 11:25:47 +0000 Subject: [PATCH] [multani] emots are sorted by length so :qwe is tested before :q --- src/gajim.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gajim.py b/src/gajim.py index cc561e402..002067015 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -919,7 +919,10 @@ class Interface: self.basic_pattern_re = sre.compile(basic_pattern, sre.IGNORECASE) emoticons_pattern = '' - for emoticon in self.emoticons: # travel thru emoticons list + # sort keys by length so :qwe emot is checked before :q + keys = self.self.emoticons.keys() + sorted_keys = keys.sort(self.on_emoticon_sort) + for emoticon in sorted_keys: # travel thru emoticons list emoticon_escaped = sre.escape(emoticon) # espace regexp metachars emoticons_pattern += emoticon_escaped + '|'# | means or in regexp @@ -930,6 +933,15 @@ class Interface: # at least one character in 3 parts (before @, after @, after .) self.sth_at_sth_dot_sth_re = sre.compile(r'\S+@\S+\.\S*[^\s)?]') + def on_emoticon_sort (self, emot1, emot2): + len1 = len(emot1) + len2 = len(emot2) + if len1 < len2: + return 1 + elif len1 > len2: + return -1 + return 0 + def on_launch_browser_mailer(self, widget, url, kind): helpers.launch_browser_mailer(kind, url)