Hackernews is an emacs package delivering daily sets of rss links, much like the elfeed package. You can program your emacs configuration to load hackernews at start up so you can scan for the latest relevant links.

The code throws an error, however, if emacs starts when the internet is disconnected.

One fix is to have emacs check the internet connection and load hackersnews only if it's live.

You need your connection checking code to load before hackernews code. You can put it in a section called 'net-utils.'

IP Check Windows


;return to ip-yes "" if there is an internet connection or "noip\n", if there is not
(if (eq 'windows-nt system-type)
(setq ip-yes (shell-command-to-string "ping 37-your-ip-address-9 -n 1 -w 3 > nul || echo noip"))
)

IP Check Linux


;return to ip-yes "" if there is an internet connection or "noip\n", if there is not
(if check-linux
(setq ip-yes(shell-command-to-string "ping 37-your-ip-address-9 -c 1 -w 3 > /dev/null && echo \"\" || echo \"noip\""))
)

IP Check WSL



;return to ip-yes "" if there is an internet connection or "noip\n", if there is not
(if check-wsl
(setq ip-yes(shell-command-to-string "ping 37-your-ip-address-9 -c 1 -w 3 > /dev/null && echo \"\" || echo \"noip\""))
)

Hackernews

The hackernews package comes with some functions you can explore.

You can wrap them in a function and call it at start-up.


(use-package hackernews 
;:commands (hackernews hackernews-mode hackernews-button-browse-internal) 

:init
(ignore-errors (hackernews))

:config
(defun random-hackernews()
(interactive)
(random t)
(let ((rh (random 4)))
(cond
((equal rh 0) (hackernews-new-stories 20))
((equal rh 1) (hackernews-best-stories 20))
((equal rh 2) (hackernews-top-stories 20))
((equal rh 3) (hackernews-job-stories 20))
)));end random-hackernews

(if (equal "" ip-yes)
(random-hackernews));if there is an internet connection, get news from hackernews

); end hackernews

Notes

As you can see, function 'random-hackernews' is called if ip-yes equals "".

Also, hackernews code initializes at start-up because the ':commands' directive, which defers loading use-package code until listed commands are called, is commented out.

That’s all for now…