diff --git a/ChangeLog b/ChangeLog index 41dbaaed..7609ac4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ * twittering-mode.el (twittering-use-show-minibuffer-length): Add suggestion into a docstring. +2010-01-08 Yuto Hayamizu + + * twittering-mode.el (twittering-status-not-blank-p): bug fix: + always return nil with strings with trailing newline. + 2010-01-07 Yuto Hayamizu * twittering-mode.el (twittering-url-reserved-p): bug fix: some diff --git a/test/test-twittering-mode.el b/test/test-twittering-mode.el index 8639113d..5413737c 100644 --- a/test/test-twittering-mode.el +++ b/test/test-twittering-mode.el @@ -350,3 +350,15 @@ (test-assert-ok (not (twittering-url-reserved-p ?\\))) (test-assert-ok (not (twittering-url-reserved-p ?^))) (test-assert-ok (not (twittering-url-reserved-p ?`)))) + +(defcase test-status-not-blank-p nil nil + (test-assert-ok (not (twittering-status-not-blank-p ""))) + (test-assert-ok (not (twittering-status-not-blank-p "\n"))) + (test-assert-ok (not (twittering-status-not-blank-p "@foo"))) + (test-assert-ok (not (twittering-status-not-blank-p "@bar "))) + (test-assert-ok (twittering-status-not-blank-p "hello")) + (test-assert-ok (twittering-status-not-blank-p "@baz hello")) + (test-assert-ok (twittering-status-not-blank-p "@baz\n\nhello")) + (test-assert-ok (twittering-status-not-blank-p "\nhello")) + (test-assert-ok (twittering-status-not-blank-p "hello\n")) + ) diff --git a/twittering-mode.el b/twittering-mode.el index d80db4a8..719ec156 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -1819,9 +1819,13 @@ following symbols; (remove-hook 'post-command-hook 'twittering-show-minibuffer-length t)) (defun twittering-status-not-blank-p (status) - (not (string-match - "^\\s-*\\(?:@[-_a-z0-9]+\\(?:\\s-+@[-_a-z0-9]+\\)*\\)?\\s-*$" status))) - + (with-temp-buffer + (insert status) + (goto-char (point-min)) + (while (re-search-forward "@[-_a-z0-9]+" nil t) + nil) ;; skip user name + (re-search-forward "[^\n\r \t]+" nil t))) + (defun twittering-update-status-from-minibuffer (&optional init-str reply-to-id) (when (and (null init-str) twittering-current-hashtag)