Dev #14

Merged
dickmao merged 4 commits from dev into master 2019-12-19 19:07:23 +00:00
5 changed files with 38 additions and 6 deletions

View File

@ -17,7 +17,7 @@
:target: http://melpa-stable.milkbox.net/#/ein :target: http://melpa-stable.milkbox.net/#/ein
:alt: MELPA stable version :alt: MELPA stable version
.. image:: screenshot.png .. image:: screenshot.gif
Install Install
======= =======
@ -72,4 +72,9 @@ From the summary buffer, ``/o`` redisplays articles already read. ``x`` undispl
Gnus beginners may find the interface bewildering. In particular, groups with no unread articles do not display. Use ``L`` to bring them out of hiding. Gnus beginners may find the interface bewildering. In particular, groups with no unread articles do not display. Use ``L`` to bring them out of hiding.
Gnus For a New Generation
=========================
The Gnus software that the author himself uses is at https://github.com/dickmao/gnus.
His changes include non-blocking fetch, and fixing threads sorting.
.. _Getting started: http://melpa.org/#/getting-started .. _Getting started: http://melpa.org/#/getting-started

View File

@ -17,7 +17,7 @@ A Gnus backend for Hacker News.
:target: http://melpa-stable.milkbox.net/#/ein :target: http://melpa-stable.milkbox.net/#/ein
:alt: MELPA stable version :alt: MELPA stable version
.. image:: screenshot.png .. image:: screenshot.gif
Install Install
======= =======
@ -72,4 +72,9 @@ From the summary buffer, ``/o`` redisplays articles already read. ``x`` undispl
Gnus beginners may find the interface bewildering. In particular, groups with no unread articles do not display. Use ``L`` to bring them out of hiding. Gnus beginners may find the interface bewildering. In particular, groups with no unread articles do not display. Use ``L`` to bring them out of hiding.
Gnus For a New Generation
=========================
The Gnus software that the author himself uses is at https://github.com/dickmao/gnus.
His changes include non-blocking fetch, and fixing threads sorting.
.. _Getting started: http://melpa.org/#/getting-started .. _Getting started: http://melpa.org/#/getting-started

View File

@ -617,20 +617,27 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'."
(aif (gnus-group-name-at-point) (aif (gnus-group-name-at-point)
(nnhackernews--rescore it)))) (nnhackernews--rescore it))))
(defun nnhackernews-extant-summary-buffer (group)
"Return main thread's summary buffer for GROUP if extant."
(let* ((args (when (and (boundp 'gnus-threaded-get-unread-articles)
gnus-threaded-get-unread-articles)
'(t)))
(name (apply #'gnus-summary-buffer-name group args)))
(gnus-buffer-live-p name)))
(defun nnhackernews--score-unread (group) (defun nnhackernews--score-unread (group)
"Filter unread messages for GROUP now. "Filter unread messages for GROUP now.
Otherwise *Group* buffer annoyingly overrepresents unread." Otherwise *Group* buffer annoyingly overrepresents unread."
(nnhackernews--with-group group (nnhackernews--with-group group
(let ((extant (get-buffer (gnus-summary-buffer-name gnus-newsgroup-name)))) (unless (nnhackernews-extant-summary-buffer gnus-newsgroup-name)
(unless extant (nnhackernews--rescore gnus-newsgroup-name t))))
(nnhackernews--rescore gnus-newsgroup-name t)))))
(defun nnhackernews--mark-scored-as-read (group) (defun nnhackernews--mark-scored-as-read (group)
"If a root article (story) is scored in GROUP, that means we've already read it." "If a root article (story) is scored in GROUP, that means we've already read it."
(nnhackernews--with-group group (nnhackernews--with-group group
(let ((preface (format "nnhackernews--mark-scored-as-read: %s not rescoring " group)) (let ((preface (format "nnhackernews--mark-scored-as-read: %s not rescoring " group))
(extant (get-buffer (gnus-summary-buffer-name gnus-newsgroup-name))) (extant (nnhackernews-extant-summary-buffer gnus-newsgroup-name))
(unread (gnus-group-unread gnus-newsgroup-name))) (unread (gnus-group-unread gnus-newsgroup-name)))
(cond ((or (not (numberp unread)) (<= unread 0)) (cond ((or (not (numberp unread)) (<= unread 0))
(gnus-message 7 (concat preface "(unread %s)") unread)) (gnus-message 7 (concat preface "(unread %s)") unread))
@ -1460,6 +1467,10 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).")
(fset 'gnus-user-format-function-S (fset 'gnus-user-format-function-S
(symbol-function 'nnhackernews--format-time-elapsed)) (symbol-function 'nnhackernews--format-time-elapsed))
(defun nnhackernews-sort-by-number-of-articles-in-thread (t1 t2)
"Whichever of the T1 or T2 has the most articles."
(> (gnus-summary-number-of-articles-in-thread t1)
(gnus-summary-number-of-articles-in-thread t2)))
(let ((custom-defaults (let ((custom-defaults
;; For now, revert any user overrides that I can't predict. ;; For now, revert any user overrides that I can't predict.
@ -1491,6 +1502,10 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).")
(gnus-summary-line-format "%3t%U%R%uS %I%(%*%-10,10f %s%)\n") (gnus-summary-line-format "%3t%U%R%uS %I%(%*%-10,10f %s%)\n")
(gnus-auto-extend-newsgroup nil) (gnus-auto-extend-newsgroup nil)
(gnus-add-timestamp-to-message t) (gnus-add-timestamp-to-message t)
(gnus-thread-sort-functions (quote (nnhackernews-sort-by-number-of-articles-in-thread)))
(gnus-summary-thread-gathering-function
(quote gnus-gather-threads-by-references))
(gnus-subthread-sort-functions (quote (gnus-thread-sort-by-number)))
(gnus-summary-display-article-function (gnus-summary-display-article-function
(quote ,(symbol-function 'nnhackernews--display-article))) (quote ,(symbol-function 'nnhackernews--display-article)))
(gnus-header-button-alist (gnus-header-button-alist

BIN
screencast.gif 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

View File

@ -34,6 +34,13 @@
(require 'ert) (require 'ert)
(require 'message) (require 'message)
(mapc (lambda (key-params)
(when (string-match-p (car key-params) "nnhackernews")
(let ((params (cdr key-params)))
(setq params (assq-delete-all 'gnus-thread-sort-functions params))
(setcdr key-params params))))
gnus-parameters)
(defun nnhackernews-test-wait-for (predicate &optional predargs ms interval continue) (defun nnhackernews-test-wait-for (predicate &optional predargs ms interval continue)
"Wait until PREDICATE function returns non-`nil'. "Wait until PREDICATE function returns non-`nil'.
PREDARGS is argument list for the PREDICATE function. PREDARGS is argument list for the PREDICATE function.