Logo

dev-resources.site

for different kinds of informations.

Read Hackernews and Reddit the Emacs way

Published at
5/11/2023
Categories
emacs
elisp
reddit
productivity
Author
dorneanu
Categories
4 categories in total
emacs
open
elisp
open
reddit
open
productivity
open
Author
8 person written this
dorneanu
open
Read Hackernews and Reddit the Emacs way

Motivation

Usually when I consume my daily news feeds, I prefer to keep context switching to a minimum. Whether you’re a busy professional or just someone who values their time, you might want to streamline your online reading experience as much as possible. For me, this means sticking to Emacs and using tools like elfeed and pocket-reader to stay on top of my reading list.

Unfortunately, this approach doesn’t work with content served within comments at Hackernews or Reddit, where you usually have lots of comments and discussion threads. This is where I began to struggle, as I found myself bouncing back and forth between Emacs and my browser in order to stay on top of the conversation.

Luckily, I’ve found hnreader and reddigg which have changed the way I consume content on these platforms. These packages are specifically designed to help you navigate and read through Hackernews and Reddit threads directly from within Emacs, saving you from the hassle of constantly switching between different apps and tabs.

In my opinion these are the most underrated packages and in this post I’d like to show you how they can help you improve your reading experience. By the end of this post, you’ll have a better understanding of how to use hnreader and reddiggto read and navigate through even the most complex Hackernews and Reddit threads, all without ever having to leave the comfort of Emacs.

hnreader

Without any customizations you can use hnreader straightaway. Currently you have following options:

image

Invoking each function will return a buffer with the latest 30 posts in that category:

image

Let’s have a look how we can add customized behaviour.

Basic functions

The easiest way to show comments for a thread ID is to use

(hnreader-readpage-promise "https://news.ycombinator.com/item?id=34482433")
Enter fullscreen mode Exit fullscreen mode

This will create a new buffer and load the readpage for that specific HN URL

image

(hnreader-promise-comment "https://news.ycombinator.com/item?id=34482433")
Enter fullscreen mode Exit fullscreen mode

This will create a new buffer and load all comments from this specific Hackernews thread:

image

elfeed integrations

Whenever you have a Hackernews specific link inside your buffer you may want to open it using:

(defun my/elfeed-hn-show-comments-at-point ()
  "Show HN comments for an URL at point"
  (interactive)
  (setq-local hnreader-view-comments-in-same-window t)
  (hnreader-comment (format "%s" (url-get-url-at-point))))

Enter fullscreen mode Exit fullscreen mode
Show HN comments for an URL at point

You can of course call a function from the elfeed-search buffer to show the HN threads:

(defun my/elfeed-hn-show-commments (&optional link)
  (interactive)
  (let* ((entry (if (eq major-mode 'elfeed-show-mode)
                    elfeed-show-entry
                  (elfeed-search-selected :ignore-region)))
         (link (if link link (elfeed-entry-link entry))))
    (setq-local hnreader-view-comments-in-same-window nil)
    (hnreader-promise-comment (format "%s" link))))

Enter fullscreen mode Exit fullscreen mode
Opens new buffer when called from the elfeed-search buffer

And these are my elfeed related keybindings:

(map! :map elfeed-search-mode-map
      :after elfeed-search
      [remap kill-this-buffer] "q"
      [remap kill-buffer] "q"
      :n doom-leader-key nil
      ;; ...
      :n "H" #'my/elfeed-hn-show-commments
      ;; ...)

Enter fullscreen mode Exit fullscreen mode
Key bindings for elfeed-search-mode
(map! :map elfeed-search-mode-map
      :after elfeed-show
      [remap kill-this-buffer] "q"
      [remap kill-buffer] "q"
      :n doom-leader-key nil
      ;; ...
      :n "H" #'my/elfeed-hn-show-comments-at-point
      ;; ...)

Enter fullscreen mode Exit fullscreen mode
Key bindings for elfeed-show-mode

reddigg

reddigg is the similar solution for reddit. When invoked directly you have these options:

image

After invoking reddigg-view-frontpage you’ll get a new buffer with the last posts:

image

(defun my/elfeed-reddit-show-commments (&optional link)
  (interactive)
  (let* ((entry (if (eq major-mode 'elfeed-show-mode)
                    elfeed-show-entry
                  (elfeed-search-selected :ignore-region)))
         (link (if link link (elfeed-entry-link entry))))
    (reddigg-view-comments link)))

Enter fullscreen mode Exit fullscreen mode

elfeed integration

We can also use reddigg to show reddit threads from within an elfeed buffer

(defun my/elfeed-reddit-show-commments (&optional link)
  (interactive)
  (let* ((entry (if (eq major-mode 'elfeed-show-mode)
                    elfeed-show-entry
                  (elfeed-search-selected :ignore-region)))
         (link (if link link (elfeed-entry-link entry))))
    (reddigg-view-comments link)))

Enter fullscreen mode Exit fullscreen mode
Show reddit comments from within elfeed

And my related keybindings:

(map! :map elfeed-search-mode-map
      :after elfeed-search
      [remap kill-this-buffer] "q"
      [remap kill-buffer] "q"
      :n doom-leader-key nil
      ;; ...
      :n "R" #'my/elfeed-reddit-show-commments
      ;; ...

Enter fullscreen mode Exit fullscreen mode
Key bindings for reddigg

When invoked you’ll get an ORG mode styled buffer with all the comments for a specific reddit thread:

image

Conclusion

I hope you’re as enthusiastic as I am. And if you have any better alternatives, please don’t hesitate to let me know in the comments.

reddit Article's
30 articles in total
Favicon
How to mass delete Reddit comments (2024)
Favicon
Reddit Content Cleaner
Favicon
Making Money on Reddit: Your Step-by-Step Guide to Turning Time into Dollars
Favicon
p2p services radar, peoples around you, services around you
Favicon
The Unfolding Drama of $Early: A Meme Coin Saga with an Unstoppable Community
Favicon
Building Subreddit Signals: The Tool I Needed to Conquer Reddit Lead Generation
Favicon
Lambdas, Loops, and Dota2 Feels
Favicon
How to Post to Reddit Using Python
Favicon
Why the upvote system is a pyramid scheme
Favicon
Building a Node.js Wrapper for Reddit API: A Step-by-Step Guide
Favicon
Join the NBA YoungBoy Merch Community on Reddit!
Favicon
Sarcasm Detection AI Model (97% Accuracy) Trained With Reddit Comments - Part 1
Favicon
How to Automatically Approve All Posts in Your Reddit Subreddit
Favicon
Self-promote on Reddit without getting banned
Favicon
I parsed 968 launches from /r/SideProject and analyzed them with Claude 3 Opus
Favicon
Reddit content deal with Google boosts its IPO plans
Favicon
How to mass import YouTube videos into a Reddit subreddit [Python]
Favicon
Introducing ReddAPI, Your Ultimate Programmable Gateway
Favicon
Reddit: Action
Favicon
How to Scrape Reddit data
Favicon
Using golang to filter through reddit posts
Favicon
Collection of tools to view, search and create Reddit archives
Favicon
A Community-Driven Data Exploration Journey: Airbnb Property Data & Bright Data
Favicon
How to run a Nostr relay with nostream
Favicon
What type of College Degree is Necessary for using Reddit today?
Favicon
InterviewBible - Reddit community about Interviewing
Favicon
Read Hackernews and Reddit the Emacs way
Favicon
Analyzing My Reddit Usage: a data-driven approach to achieving my New Year’s Resolution of reducing my online time
Favicon
Visualizing and Analyzing Reddit in Real-Time With Kafka and Memgraph
Favicon
Reddit Social Listening with Python

Featured ones: