Skip to content

Commit

Permalink
Add option to fill window with stories
Browse files Browse the repository at this point in the history
If hackernews-items-per-page is nil, the number of stories is three
less than the window height. It isn't the full window height because
that includes the status bar and the minibuffer, and it's annoying to
have to scroll down to see the last few stories.
  • Loading branch information
nickdrozd committed May 7, 2018
1 parent 309c60c commit 848eeca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hackernews.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
'hackernews-items-per-page "0.4.0")

(defcustom hackernews-items-per-page 20
"Default number of stories to retrieve in one go."
"Default number of stories to retrieve in one go.
If nil, the stories will fill the window."
:package-version '(hackernews . "0.4.0")
:group 'hackernews
:type 'integer)
Expand Down Expand Up @@ -471,6 +472,11 @@ Objects are decoded as alists and arrays as vectors.")
(aset items i (hackernews--read-contents
(hackernews--item-url (aref ids (+ offset i))))))))

(defun hackernews--calculate-story-count ()
"Return hackernews-items-per-page or enough to fill the window."
(or hackernews-items-per-page
(- (window-height) 3)))

(defun hackernews--load-stories (feed n &optional append)
"Retrieve and render at most N items from FEED.
Create and setup corresponding hackernews buffer if necessary.
Expand Down Expand Up @@ -507,7 +513,7 @@ rendered at the end of the hackernews buffer."
(max 0 (min (- (length ids) offset)
(if n
(prefix-numeric-value n)
hackernews-items-per-page)))
(hackernews--calculate-story-count))))
()))

(hackernews--retrieve-items)
Expand Down

0 comments on commit 848eeca

Please sign in to comment.