diff --git a/README.in.rst b/README.in.rst index bf128f0..6595588 100644 --- a/README.in.rst +++ b/README.in.rst @@ -56,7 +56,7 @@ Enter the ``nnhackernews:news`` newsgroup with ``RET``. Gnus will only show followup comments for threads you read, so be selective. If you accidentally read a thread, or decide the thread is uninteresting, you may ``C-k`` it to prevent Gnus from showing followups. Use ``C-k`` liberally. -The signal-to-noise of the hackernews firehose is such that I often "catch-up" via ``c`` to flush the unread threads. +When finished, "catch-up" via ``c`` to flush the unread threads. Gnus will not show comments for them. Create a post via ``a``. diff --git a/README.rst b/README.rst index cd3b437..28b13f7 100644 --- a/README.rst +++ b/README.rst @@ -56,7 +56,7 @@ Enter the ``nnhackernews:news`` newsgroup with ``RET``. Gnus will only show followup comments for threads you read, so be selective. If you accidentally read a thread, or decide the thread is uninteresting, you may ``C-k`` it to prevent Gnus from showing followups. Use ``C-k`` liberally. -The signal-to-noise of the hackernews firehose is such that I often "catch-up" via ``c`` to flush the unread threads. +When finished, "catch-up" via ``c`` to flush the unread threads. Gnus will not show comments for them. Create a post via ``a``. diff --git a/features/rpc.feature b/features/rpc.feature index 3e74066..41307a8 100644 --- a/features/rpc.feature +++ b/features/rpc.feature @@ -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 I press "q" Then I should be in buffer "*Group*" - And I dump buffer Then of-record unreads for "nnhackernews:news" is 186 And I scan news Then of-record unreads for "nnhackernews:news" is 280 When I go to word "nnhackernews:news" And I press "RET" + Then I should be in buffer "*Summary nnhackernews:news*" And I go to word "DoreenMich" And I press "C-k" And prospective unreads for "nnhackernews:news" is 273 @@ -52,7 +52,6 @@ Scenario: delete When I switch to buffer "*Summary nnhackernews:news*" And I press "c y" Then I should be in buffer "*Group*" - And I dump buffer And I scan news When I go to word "nnhackernews:news" 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 press "M->" And I type "this is a test" - And I dump buffer And I press "C-c C-c" When I switch to buffer "*Messages*" Then I should not see "Couldn't send message via news" diff --git a/nnhackernews.el b/nnhackernews.el index 5253170..cacd8cc 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -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--last-scan-time (truncate (float-time)) +(defvar nnhackernews--last-scan-time (- (truncate (float-time)) 100) "Don't scan more than once every few seconds.") (defmacro nnhackernews--callback (result &optional callback) @@ -426,8 +426,10 @@ If GROUP classification omitted, figure it out." (defun nnhackernews-vote-current-article (vote) "VOTE is +1, -1, 0." (unless gnus-newsgroup-name (error "No current newgroup")) - (if-let ((article-number (or (cdr gnus-article-current) - (gnus-summary-article-number)))) + (if-let ((article-number (or (with-current-buffer gnus-article-buffer + (cdr gnus-article-current)) + (with-current-buffer gnus-summary-buffer + (gnus-summary-article-number))))) (let* ((header (nnhackernews--get-header article-number (gnus-group-real-name gnus-newsgroup-name))) (orig-score (format "%s" (plist-get header :score))) @@ -553,9 +555,12 @@ Originally written by Paul Issartel." "Call `gnus-summary-exit' without the hackery." (remove-function (symbol-function 'gnus-summary-exit) (symbol-function 'nnhackernews--score-pending)) - (gnus-summary-exit nil t) - (add-function :after (symbol-function 'gnus-summary-exit) - (symbol-function 'nnhackernews--score-pending))) + (unwind-protect + (progn + (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) "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) (when (or force (> num-headers seen)) (save-window-excursion - (let ((gnus-auto-select-subject nil) - (gnus-summary-next-group-on-exit nil) + (let (gnus-auto-select-subject + gnus-summary-next-group-on-exit (unread (length (gnus-list-of-unread-articles group)))) (if (zerop unread) (gnus-message 7 "nnhackernews--rescore: skipping %s no unread" group) (nnhackernews--with-mutex nnhackernews--mutex-display-article - (gnus-summary-read-group group nil t) - (nnhackernews--summary-exit)))))))))) + (gnus-summary-read-group group nil t) + (with-current-buffer (gnus-summary-buffer-name group) + (nnhackernews--summary-exit))))))))))) (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) "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))) (t (save-excursion - (let ((gnus-auto-select-subject nil)) + (let (gnus-auto-select-subject) (gnus-summary-read-group gnus-newsgroup-name nil t) - (dolist (datum gnus-newsgroup-data) - (-when-let* ((article (gnus-data-number datum)) - (plst (nnhackernews--get-header article)) - (scored-story-p (and (plist-get plst :title) - (> (gnus-summary-article-score article) 0)))) - (gnus-message 7 "nnhackernews--mark-scored-as-read: %s (%s %s)" - (plist-get plst :title) group article) - (gnus-summary-mark-as-read article))) - (nnhackernews--summary-exit)))))))) + (with-current-buffer (gnus-summary-buffer-name gnus-newsgroup-name) + (dolist (datum gnus-newsgroup-data) + (-when-let* ((article (gnus-data-number datum)) + (plst (nnhackernews--get-header article)) + (scored-story-p (and (plist-get plst :title) + (> (gnus-summary-article-score article) 0)))) + (gnus-message 7 "nnhackernews--mark-scored-as-read: %s (%s %s)" + (plist-get plst :title) group article) + (gnus-summary-mark-as-read article))) + (nnhackernews--summary-exit))))))))) (deffoo nnhackernews-request-group-scan (group &optional server info) "M-g from *Group* calls this." @@ -1545,6 +1554,7 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).") (if (nnhackernews--gate) nil gnus-summary-next-group-on-exit))) (apply f args)))) + (add-function :after (symbol-function 'gnus-summary-exit) (symbol-function 'nnhackernews--score-pending))