From 53b6a0516eacd092e868c18252ede9d1d515bf07 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 11 Nov 2019 15:54:43 -0500 Subject: [PATCH 1/4] get travis badge to turn green --- README.in.rst | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.in.rst b/README.in.rst index d398a9c..0364cfc 100644 --- a/README.in.rst +++ b/README.in.rst @@ -47,7 +47,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. -When finished, "catch-up" via ``c`` to flush the unread threads. Gnus will not show comments for them. +The signal-to-noise of the hackernews firehose is such that I often "catch-up" via ``c`` to flush the unread threads. Create a post via ``a``. diff --git a/README.rst b/README.rst index b97cb76..cb9406b 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,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. -When finished, "catch-up" via ``c`` to flush the unread threads. Gnus will not show comments for them. +The signal-to-noise of the hackernews firehose is such that I often "catch-up" via ``c`` to flush the unread threads. Create a post via ``a``. -- 2.34.1 From 74982b3515af0019671489da4b583e86ba39dfbd Mon Sep 17 00:00:00 2001 From: dickmao Date: Wed, 20 Nov 2019 15:14:59 -0500 Subject: [PATCH 2/4] global gnus-summary-buffer being # is highly problematic --- nnhackernews.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nnhackernews.el b/nnhackernews.el index 5253170..745c472 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -553,7 +553,9 @@ 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) + (gnus-summary-exit t t) + (gnus-kill-buffer (gnus-summary-buffer-name gnus-newsgroup-name)) + (setq gnus-summary-buffer (default-value 'gnus-summary-buffer)) (add-function :after (symbol-function 'gnus-summary-exit) (symbol-function 'nnhackernews--score-pending))) @@ -598,6 +600,7 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'." (save-window-excursion (let ((gnus-auto-select-subject nil) (gnus-summary-next-group-on-exit nil) + (gnus-summary-buffer gnus-summary-buffer) (unread (length (gnus-list-of-unread-articles group)))) (if (zerop unread) (gnus-message 7 "nnhackernews--rescore: skipping %s no unread" -- 2.34.1 From a29537edc8660cef5e6aefd536b4771ae7336bde Mon Sep 17 00:00:00 2001 From: dickmao Date: Thu, 21 Nov 2019 23:07:28 -0500 Subject: [PATCH 3/4] avoid npe --- nnhackernews.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nnhackernews.el b/nnhackernews.el index 745c472..fdc4165 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -555,7 +555,6 @@ Originally written by Paul Issartel." (symbol-function 'nnhackernews--score-pending)) (gnus-summary-exit t t) (gnus-kill-buffer (gnus-summary-buffer-name gnus-newsgroup-name)) - (setq gnus-summary-buffer (default-value 'gnus-summary-buffer)) (add-function :after (symbol-function 'gnus-summary-exit) (symbol-function 'nnhackernews--score-pending))) @@ -600,7 +599,6 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'." (save-window-excursion (let ((gnus-auto-select-subject nil) (gnus-summary-next-group-on-exit nil) - (gnus-summary-buffer gnus-summary-buffer) (unread (length (gnus-list-of-unread-articles group)))) (if (zerop unread) (gnus-message 7 "nnhackernews--rescore: skipping %s no unread" @@ -610,7 +608,9 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'." (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. -- 2.34.1 From ad62d473d41ba0512e1a277aee6f1bec7bde6ec1 Mon Sep 17 00:00:00 2001 From: dickmao Date: Sat, 23 Nov 2019 09:57:04 -0500 Subject: [PATCH 4/4] do not assume the requisite set-buffer's --- features/rpc.feature | 4 +--- nnhackernews.el | 49 +++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 24 deletions(-) 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 fdc4165..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,10 +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 t t) - (gnus-kill-buffer (gnus-summary-buffer-name gnus-newsgroup-name)) - (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." @@ -597,15 +601,16 @@ 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) @@ -634,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." @@ -1548,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)) -- 2.34.1