Skip to content

Commit

Permalink
bug fix of twittering-status-not-blank-p
Browse files Browse the repository at this point in the history
* twittering-mode.el (twittering-status-not-blank-p): bug fix:
always return nil with strings with trailing newline.
  • Loading branch information
hayamiz committed Jan 8, 2010
1 parent d8f2864 commit 1d82f4e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,11 @@
* twittering-mode.el (twittering-use-show-minibuffer-length): Add
suggestion into a docstring.

2010-01-08 Yuto Hayamizu <y.hayamizu@gmail.com>

* twittering-mode.el (twittering-status-not-blank-p): bug fix:
always return nil with strings with trailing newline.

2010-01-07 Yuto Hayamizu <y.hayamizu@gmail.com>

* twittering-mode.el (twittering-url-reserved-p): bug fix: some
Expand Down
12 changes: 12 additions & 0 deletions test/test-twittering-mode.el
Expand Up @@ -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"))
)
10 changes: 7 additions & 3 deletions twittering-mode.el
Expand Up @@ -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)
Expand Down

0 comments on commit 1d82f4e

Please sign in to comment.