diff --git a/TODO b/TODO
index cce9e71..56243e7 100644
--- a/TODO
+++ b/TODO
@@ -10,11 +10,10 @@ features:
* Support creating new lists and adding users to it (as well as removing users and deleting lists)
* Changing the active user needs to do more 'work'
-** Refresh relavant pages
+** Refresh relevant pages
bugs:
* "ValueError: list.remove(x): x not in list" when trying to close a tab (error recurred after adding conversation support). Tabs can be reordered, then closed, as a workaround.
* Links must be right-clicked on to activate - can't left-click on the link directly. This seems to be a pygtk issue
-* If an @ appears anywhere in a status update, links after it try to resolve to user: links... need to work on my regexes
diff --git a/twitterwidgets.py b/twitterwidgets.py
index f571303..1a63bb3 100644
--- a/twitterwidgets.py
+++ b/twitterwidgets.py
@@ -443,8 +443,8 @@ class TweetBox(gtk.HBox):
new_text = re.sub(r'&([^;]*?)( |$)', r'&\1\2', new_text)
new_text = re.sub(r'"([^;]*?)( |$)', r'"\1\2', new_text)
if gtk.gtk_version[0] > 2 or (gtk.gtk_version[0] == 2 and gtk.gtk_version[1] >= 18):
- new_text = re.sub(r"(http://.*?)( |$)", r'\1\2', new_text)
- new_text = re.sub(r'@(.*?)( |$)', r'@\1\2', new_text)
+ new_text = re.sub(r"(http://.*?)([^0-9a-zA-Z.~/]|$)", r'\1\2', new_text)
+ new_text = re.sub(r'@(.*?)([^0-9a-zA-Z_]|$)', self._make_user_link, new_text)
self.text.set_markup(new_text)
# If this is in reply to something, set appropriate label
@@ -523,10 +523,19 @@ class TweetBox(gtk.HBox):
def on_url_clicked(self, widget, uri):
self.set_read()
self.emit('tweet-read')
+
if re.match(r'@', uri):
self.emit('show-user', re.sub(r'@', '', uri))
return True
+
+ def _make_user_link(self, matchobj):
+ name = matchobj.group(1)
+ if name == '':
+ return '@' + matchobj.group(2)
+ else:
+ return '@' + name + '' + matchobj.group(2)
+
# end class TweetBox
# signals for TweetBox
@@ -755,6 +764,7 @@ class CloseTabLabel(gtk.EventBox):
def on_button_press(self, event, direction):
self.emit('label-clicked')
+
### end class CloseTabLabel
# signals for CloseTabLabel