Dev #13

Merged
dickmao merged 3 commits from dev into master 2019-11-23 15:12:54 +00:00
2 changed files with 32 additions and 24 deletions

View File

@ -17,12 +17,12 @@ Scenario: gnus-demon-scan-news while summary buffer open, then auto-rescore upon
And prospective unreads for "nnhackernews:news" is 93 And prospective unreads for "nnhackernews:news" is 93
And I press "q" And I press "q"
Then I should be in buffer "*Group*" Then I should be in buffer "*Group*"
And I dump buffer
Then of-record unreads for "nnhackernews:news" is 186 Then of-record unreads for "nnhackernews:news" is 186
And I scan news And I scan news
Then of-record unreads for "nnhackernews:news" is 280 Then of-record unreads for "nnhackernews:news" is 280
When I go to word "nnhackernews:news" When I go to word "nnhackernews:news"
And I press "RET" And I press "RET"
Then I should be in buffer "*Summary nnhackernews:news*"
And I go to word "DoreenMich" And I go to word "DoreenMich"
And I press "C-k" And I press "C-k"
And prospective unreads for "nnhackernews:news" is 273 And prospective unreads for "nnhackernews:news" is 273
@ -52,7 +52,6 @@ Scenario: delete
When I switch to buffer "*Summary nnhackernews:news*" When I switch to buffer "*Summary nnhackernews:news*"
And I press "c y" And I press "c y"
Then I should be in buffer "*Group*" Then I should be in buffer "*Group*"
And I dump buffer
And I scan news And I scan news
When I go to word "nnhackernews:news" When I go to word "nnhackernews:news"
And I press "RET" And I press "RET"
@ -87,7 +86,6 @@ Scenario: submit a text which must be titled
And I type "test baby test baby 123" And I type "test baby test baby 123"
And I press "M->" And I press "M->"
And I type "this is a test" And I type "this is a test"
And I dump buffer
And I press "C-c C-c" And I press "C-c C-c"
When I switch to buffer "*Messages*" When I switch to buffer "*Messages*"
Then I should not see "Couldn't send message via news" Then I should not see "Couldn't send message via news"

View File

@ -91,7 +91,7 @@ Do not set this to \"localhost\" as a numeric IP is required for the oauth hands
(defvar nnhackernews--debug-request-items nil "Keep track of ids to re-request for testing.") (defvar nnhackernews--debug-request-items nil "Keep track of ids to re-request for testing.")
(defvar nnhackernews--last-scan-time (truncate (float-time)) (defvar nnhackernews--last-scan-time (- (truncate (float-time)) 100)
"Don't scan more than once every few seconds.") "Don't scan more than once every few seconds.")
(defmacro nnhackernews--callback (result &optional callback) (defmacro nnhackernews--callback (result &optional callback)
@ -426,8 +426,10 @@ If GROUP classification omitted, figure it out."
(defun nnhackernews-vote-current-article (vote) (defun nnhackernews-vote-current-article (vote)
"VOTE is +1, -1, 0." "VOTE is +1, -1, 0."
(unless gnus-newsgroup-name (error "No current newgroup")) (unless gnus-newsgroup-name (error "No current newgroup"))
(if-let ((article-number (or (cdr gnus-article-current) (if-let ((article-number (or (with-current-buffer gnus-article-buffer
(gnus-summary-article-number)))) (cdr gnus-article-current))
(with-current-buffer gnus-summary-buffer
(gnus-summary-article-number)))))
(let* ((header (nnhackernews--get-header article-number (let* ((header (nnhackernews--get-header article-number
(gnus-group-real-name gnus-newsgroup-name))) (gnus-group-real-name gnus-newsgroup-name)))
(orig-score (format "%s" (plist-get header :score))) (orig-score (format "%s" (plist-get header :score)))
@ -553,9 +555,12 @@ Originally written by Paul Issartel."
"Call `gnus-summary-exit' without the hackery." "Call `gnus-summary-exit' without the hackery."
(remove-function (symbol-function 'gnus-summary-exit) (remove-function (symbol-function 'gnus-summary-exit)
(symbol-function 'nnhackernews--score-pending)) (symbol-function 'nnhackernews--score-pending))
(gnus-summary-exit nil t) (unwind-protect
(add-function :after (symbol-function 'gnus-summary-exit) (progn
(symbol-function 'nnhackernews--score-pending))) (gnus-summary-exit t t)
(gnus-kill-buffer gnus-summary-buffer))
(add-function :after (symbol-function 'gnus-summary-exit)
(symbol-function 'nnhackernews--score-pending))))
(defsubst nnhackernews--ensure-score-files (group) (defsubst nnhackernews--ensure-score-files (group)
"File I/O remains a perennial problem for score files for GROUP." "File I/O remains a perennial problem for score files for GROUP."
@ -596,18 +601,21 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'."
(unless (zerop seen) (unless (zerop seen)
(when (or force (> num-headers seen)) (when (or force (> num-headers seen))
(save-window-excursion (save-window-excursion
(let ((gnus-auto-select-subject nil) (let (gnus-auto-select-subject
(gnus-summary-next-group-on-exit nil) gnus-summary-next-group-on-exit
(unread (length (gnus-list-of-unread-articles group)))) (unread (length (gnus-list-of-unread-articles group))))
(if (zerop unread) (if (zerop unread)
(gnus-message 7 "nnhackernews--rescore: skipping %s no unread" (gnus-message 7 "nnhackernews--rescore: skipping %s no unread"
group) group)
(nnhackernews--with-mutex nnhackernews--mutex-display-article (nnhackernews--with-mutex nnhackernews--mutex-display-article
(gnus-summary-read-group group nil t) (gnus-summary-read-group group nil t)
(nnhackernews--summary-exit)))))))))) (with-current-buffer (gnus-summary-buffer-name group)
(nnhackernews--summary-exit)))))))))))
(defalias 'nnhackernews--score-pending (defalias 'nnhackernews--score-pending
(lambda (&rest _args) (nnhackernews--rescore (gnus-group-name-at-point)))) (lambda (&rest _args)
(aif (gnus-group-name-at-point)
(nnhackernews--rescore it))))
(defun nnhackernews--score-unread (group) (defun nnhackernews--score-unread (group)
"Filter unread messages for GROUP now. "Filter unread messages for GROUP now.
@ -631,17 +639,18 @@ Otherwise *Group* buffer annoyingly overrepresents unread."
(gnus-message 7 (concat preface "(extant %s)") (buffer-name extant))) (gnus-message 7 (concat preface "(extant %s)") (buffer-name extant)))
(t (t
(save-excursion (save-excursion
(let ((gnus-auto-select-subject nil)) (let (gnus-auto-select-subject)
(gnus-summary-read-group gnus-newsgroup-name nil t) (gnus-summary-read-group gnus-newsgroup-name nil t)
(dolist (datum gnus-newsgroup-data) (with-current-buffer (gnus-summary-buffer-name gnus-newsgroup-name)
(-when-let* ((article (gnus-data-number datum)) (dolist (datum gnus-newsgroup-data)
(plst (nnhackernews--get-header article)) (-when-let* ((article (gnus-data-number datum))
(scored-story-p (and (plist-get plst :title) (plst (nnhackernews--get-header article))
(> (gnus-summary-article-score article) 0)))) (scored-story-p (and (plist-get plst :title)
(gnus-message 7 "nnhackernews--mark-scored-as-read: %s (%s %s)" (> (gnus-summary-article-score article) 0))))
(plist-get plst :title) group article) (gnus-message 7 "nnhackernews--mark-scored-as-read: %s (%s %s)"
(gnus-summary-mark-as-read article))) (plist-get plst :title) group article)
(nnhackernews--summary-exit)))))))) (gnus-summary-mark-as-read article)))
(nnhackernews--summary-exit)))))))))
(deffoo nnhackernews-request-group-scan (group &optional server info) (deffoo nnhackernews-request-group-scan (group &optional server info)
"M-g from *Group* calls this." "M-g from *Group* calls this."
@ -1545,6 +1554,7 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).")
(if (nnhackernews--gate) nil (if (nnhackernews--gate) nil
gnus-summary-next-group-on-exit))) gnus-summary-next-group-on-exit)))
(apply f args)))) (apply f args))))
(add-function :after (symbol-function 'gnus-summary-exit) (add-function :after (symbol-function 'gnus-summary-exit)
(symbol-function 'nnhackernews--score-pending)) (symbol-function 'nnhackernews--score-pending))