Coder Social home page Coder Social logo

hackernews.el's Introduction

Simple Hacker News Emacs Client

Build MELPA MELPA Stable

It's simple because it doesn't actually interact with Hacker News. It uses a HTTP API to get the data.

Interface

Version 0.7.0 of the hackernews package is able to fetch stories from six different Hacker News feeds, namely top, new, best, ask, show and job stories. The default feed is top stories, which corresponds to the Hacker News homepage.

The score, title, and comments count of each story is presented on a line of its own (see screenshot below), though this format is customizable. Both the title and comments count strings are hyperlinked to the Hacker News page for the item (the one with the comments), unless the story links to an external page, in which case the title is hyperlinked to that instead.

Clicking or typing RET on a link opens it with the command browse-url, which selects a browser based on the user option browse-url-browser-function. This defaults to the system's default browser.

Typing t on a link first tries to open it in eww, if available, and otherwise passes it to the command browse-url-text-emacs, which consults the user option browse-url-text-browser. This defaults to running lynx within Emacs. Keep in mind that some websites do not render well in text mode.

A future hackernews version may support upvoting and interacting with comments.

Keymap

Key Description
RET Open link in default (external) browser
t Open link in text-based browser within Emacs
r Mark link as visited
R Mark link as unvisited
n Move to next title link
p Move to previous title link
TAB Move to next comments count link
S-TAB Move to previous comments count link
m Load more stories
g Reload stories
f Prompt user for a feed to switch to
q Quit

All feed re/loading commands accept an optional numeric prefix argument denoting how many stories to act on. For example, M-50g refreshes the feed of the current hackernews buffer and fetches its top 50 stories. With no prefix argument, the value of the user option hackernews-items-per-page is used instead.

Screenshot

screenshot

Installation

Using the built-in package manager

Those who like the built-in package manager package.el need only point it to a MELPA repository, which can be achieved by adding the following code to your user-init-file:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

Note that this will follow the bleeding edge of hackernews development. Though hackernews contributors make every effort to keep the latest snapshot usable and bug-free, to err is human. If this thought scares you, a more stable experience can be achieved by replacing:

'("melpa" . "https://melpa.org/packages/")

in the example above with:

'("melpa-stable" . "https://stable.melpa.org/packages/")

or equivalent. See https://melpa.org/#/getting-started/ for more on this.

Once package.el is configured, you can run M-xpackage-installREThackernewsRET.

Manual download

Place the hackernews.el file into a directory on your load-path and add the following code to your user-init-file:

(autoload 'hackernews "hackernews" nil t)

Alternatively, if you always want the package loaded at startup (this slows down startup):

(require 'hackernews)

Usage

Just run M-xhackernewsRET. This reads the feed specified by the user option hackernews-default-feed, which defaults to top stories, i.e. the Hacker News homepage. A direct command for each supported feed is also supported, e.g. M-xhackernews-top-storiesRET or M-xhackernews-ask-storiesRET. These direct commands are not autoloaded, however, so to use them before hackernews has been loaded, you should autoload them yourself, e.g. by adding the following to your user-init-file:

(autoload 'hackernews-ask-stories "hackernews" nil t)

Customization

You can list and modify all custom faces and variables by typing M-xcustomize-groupREThackernewsRET.

All hackernews buffers are displayed using the pop-to-buffer function for increased compatibility and customizability in how windows and frames are re/used. This function displays buffers in a new window by default. The simplest way to instead reuse the current window for hackernews buffers is to customize one of the user options same-window-buffer-names, same-window-regexp or in Emacs 24 and subsequent versions, display-buffer-alist via M-xcustomize-groupRETwindowsRET.

If you prefer to roll out your own Elisp, you could add to your user-init-file something as simple as:

(push '("\\`\\*hackernews .*\\*\\'" display-buffer-same-window)
      display-buffer-alist)

;; ...or equivalently, starting with Emacs 30:

(push '((category . hackernews) display-buffer-same-window)
      display-buffer-alist)

Troubleshooting

In general, errors and misbehavior pertaining to network retrieval and JSON parsing are probably due to bugs in older Emacsen. The minimum recommended Emacs version for hackernews is 25. Emacs 24 should work, but suffers from network security vulnerabilities that were fixed in version 25. Emacs 23 is no longer officially supported as of 2018-06-08, i.e. since hackernews version 0.5.0.

In any case, please report any problems on the project's issue tracker, so that the possibility for mitigation can be investigated.

License

Copyright (C) 2012-2024 The Hackernews.el Authors

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

hackernews.el's People

Contributors

aborn avatar ataylor284 avatar basil-conto avatar bitdeli-chef avatar clarete avatar davorb avatar fabacino avatar jonashelgemo avatar matthew-piziak avatar matthijsk avatar novakboskov avatar radford avatar shassard avatar sjbalaji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hackernews.el's Issues

Improve Org-mode Integration with Emacs for Hacker News Content

I'd like to propose an enhancement to the Org-mode support by integrating it with Emacs org-mode buffer. Currently, the content appears to be displayed in an independent buffer. It would be advantageous to have it displayed in an Emacs org-mode buffer instead.

With this integration, we could use folding and unfolding features to show the news titles and their content. Additionally, if displaying comments is deemed necessary, users could jump to the comment section and view the first few comments within the discussion.

In cases where users find a topic particularly interesting, they could call a function like "Hacker News Save to org-mode." This function would nicely format all the information, titles, and discussions into org-roam, making it easy to incorporate the content into one's personal knowledge base.

Compilation warning when installing package

A compilation warning is thrown when installing the hackernews package.

On Emacs 24.3.1 installed via homebrew.

Steps taken:
M-x install-package RET hackernews RET

What happens:
A *Compile-Log* buffer pops up with:

Leaving directory `/Users/felideon/.emacs.d/elpa/hackernews-20130220.2042'

Compiling file /Users/felideon/.emacs.d/elpa/hackernews-20130220.2042/hackernews-pkg.el at Fri Oct 18 15:00:03 2013
Entering directory `/Users/felideon/.emacs.d/elpa/hackernews-20130220.2042/'

Compiling file /Users/felideon/.emacs.d/elpa/hackernews-20130220.2042/hackernews.el at Fri Oct 18 15:00:03 2013

In hackernews-retrieve:
hackernews.el:109:19:Warning: Use `with-current-buffer' rather than
    save-excursion+set-buffer

Feature Request: Showing the news as org mode links

Hey it would be really nice if you can make it show the news articles as org mode links. One of the advantage would be to open the news article using browse-url-text-emacs or browse-url-w3. One need not leave the emacs to read the news article!!

Waiting to hear from you about the same !!

  • Balaji

Drop support for Emacs 23

Debian 7 "Wheezy", the current OldOldStable distribution and the last one to ship Emacs 23, has reached its end-of-life: https://lists.debian.org/debian-announce/2018/msg00001.html. As a Debian Testing/Sid user, I am already unable to build Emacs 23 and will now no longer be able to install it, either. By extension, I will no longer be able to maintain Emacs 23 support for hackernews.

Dropping support for Emacs 23 was already discussed to an extent in #42. I will now wait a week and, if there are no objections in the meantime, will freely drop support for Emacs 23 in subsequent hackernews updates.

TODO

Theming

Hello,

As is it currently stands, hackernews.el doesn't expose defcustom(s) for the font color, and on light themes it is unreadable and "hard" to change (not newbie-friendly at least).

I could try and make a patch if you think it'd be a nice thing to have as well.

Regards,
Louis "baboon" Kottmann

Support for viewing comments

I searched for previous issues but couldn't find anything.

I know hackernews.el currently supports viewing the news-stories list, and was
wondering whether support for the comment page is being worked on?

I began looking how to implement this myself, but figured I'd ask in case this
was already on the roadmap.

Thanks in advance for the great work on this mode.

Keep track of visited links

It would be nice to:

  • Optionally keep track of visited item IDs.
  • Differentiate visited links with faces, e.g. link/link-visited.

TODO

  • Define "visited" variations of current article and comment faces and buttons.
  • Mark visited links as such for the current session.
    • Make this behaviour optional and enabled by default.
  • Persist set of visited item IDs across sessions by writing to and reading from a user file.
    • Make this behaviour optional and enabled by default.

"Bad news, bro: stringp"

Hey,
It seems like it's not working, I keep getting the error "Bad news, bro: stringp" while displaying the news "[132]".
Hope you're still have time to maintain the project, otherwise I'll try to have a look when I get some spare time.
Cheers!

Add support for lobste.rs

This news client is rather awesome, and I wish I could use it to read news from https://lobste.rs/ as well as hackernews. Does anybody else feel like it'd be a good idea to support another feed in our humble little client?

Method Not Allowed: https://hacker-news.firebaseio.com/v0/beststories.json

Today I get the following when I try to use M-x hackernews-best-stories:

url-insert-file-contents: https://hacker-news.firebaseio.com/v0/beststories.json: Method not allowed`

Could be an upstream breakage, but as far as I can tell I can curl that URL just fine.

I'm using hackernews.el 0.6.1, GCC-nativecomp Emacs 28.0.50, on NixOS.

Support asynchronous retrieval

It should be possible to continue using Emacs whilst news are fetched (and rendered), either optionally or by default. This would be especially nice for fetching large numbers of articles in one go.

I think something like the man.el user option Man-notify-method would be the best way for users to choose how finalised hackernews buffers are notified/presented.

If #39 is implemented, a uniform asynchronous interface to both url.el and subprocess invocations could in theory be straightforward, given the correspondence of url.el callbacks to process sentinels.

links from the frontpage to hackernews itself are relative, and causes incomplete links

from the frontpage right now, a snipped json string:

{"title":"Why we revert to original titles",
 "url":"/comments/6572466",
 "id":6572466,
 "commentCount":170,
 "points":269,
 "postedAgo":"4 hours ago",
 "postedBy":"pg"}

The link generated in the client will be /comments/6572466 causing the browser to open file:///comments/6572466

Now, prefixing the relative url will not work, since the correct address (at the moment) will be https://news.ycombinator.com/item?id=6572466

The transformation rule is relatively clear, though.

Support alternatives to url.el for retrieval

This issue is inspired by Chris Wellons' article on using cURL in Elfeed, which see.

In my tests on Emacs 27, url.el is as fast if not faster than calling curl or wget in a subprocess, which is a pleasant surprise. :) Perhaps the overhead of subprocesses and their I/O can be blamed.

Either way, some users could conceivably like to use external tools like these for fetching news. Would this be a worthwhile feature?

Add AUTHORS file

The significant recent contribution of @matthew-piziak in #48 for tracking visited links made we wonder whether we should maintain a list of authors along with a brief description of their contributions, as per (maintain) Recording Contributors.

Drawing heavily from etc/AUTHORS in GNU Emacs, we could write something like the following:

Several people have contributed code and documentation to the
hackernews.el Hacker News client for GNU Emacs.  To show our
appreciation for their public spirit, we list here in alphabetical
order a condensed list of their contributions.

...

Matthew Piziak: added support for tracking visited links to
  hackernews.el

...

WDYT? @clarete?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.