Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
basil-conto committed Jan 12, 2024
1 parent dcb3121 commit 1aa6f35
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 11 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build
on:
pull_request:
paths:
- '!**'
- '.github/workflows/build.yml'
- 'Makefile'
- 'hackernews.el'
push:
paths:
- '!**'
- '.github/workflows/build.yml'
- 'Makefile'
- 'hackernews.el'
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
emacs_version:
- 23.4
- 24.1
- 24.2
- 24.3
- 24.4
- 24.5
- 25.1
- 25.2
- 25.3
- 26.1
- 26.2
- 26.3
- 27.1
- 27.2
- 28.1
- 28.2
- 29.1
- release-snapshot
- snapshot
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}
- name: Byte-compile
run: make
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Simple Hacker News Emacs Client

[![Build](https://github.com/clarete/hackernews.el/actions/workflows/build.yml/badge.svg)](https://github.com/clarete/hackernews.el/actions/workflows/build.yml)
[![MELPA](https://melpa.org/packages/hackernews-badge.svg)](https://melpa.org/#/hackernews)
[![MELPA Stable](https://stable.melpa.org/packages/hackernews-badge.svg)](https://stable.melpa.org/#/hackernews)

Expand All @@ -9,7 +10,7 @@ News](https://news.ycombinator.com/). It uses a HTTP

## Interface

Version 0.6.1 of the `hackernews` package is able to fetch stories
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.
Expand Down Expand Up @@ -172,7 +173,7 @@ possibility for mitigation can be investigated.

## License

Copyright (C) 2012-2023 The Hackernews.el Authors
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
Expand Down
33 changes: 24 additions & 9 deletions hackernews.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
;;; hackernews.el --- Hacker News Client for Emacs -*- lexical-binding: t -*-

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

;; Author: Lincoln de Sousa <[email protected]>
;; Maintainer: Basil L. Contovounesios <[email protected]>
;; Keywords: comm hypermedia news
;; Version: 0.6.1
;; Homepage: https://github.com/clarete/hackernews.el
;; Version: 0.7.0
;; URL: https://github.com/clarete/hackernews.el

;; 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
Expand Down Expand Up @@ -383,7 +383,8 @@ On error, display a warning for the user and return nil."
(condition-case err
(with-temp-buffer
(insert-file-contents hackernews-visited-links-file)
(read (current-buffer)))
(unless (eobp)
(read (current-buffer))))
(error
(ignore
(lwarn 'hackernews :error
Expand Down Expand Up @@ -421,6 +422,18 @@ risks being overwritten next time Emacs is killed."
(puthash k newv table))))
(cdr entry)))))

(defalias 'hackernews--prin1
(if (condition-case nil
(with-no-warnings (prin1 t #'ignore ()))
(wrong-number-of-arguments))
#'prin1
(lambda (object &optional printcharfun _overrides)
(let ((print-length nil)
(print-level nil))
(prin1 object printcharfun))))
"Compatibility shim for default `prin1' overrides in Emacs < 29.
\n(fn OBJECT &optional PRINTCHARFUN OVERRIDES)")

(defun hackernews-save-visited-links ()
"Write visited links to `hackernews-visited-links-file'."
(when hackernews-visited-links-file
Expand All @@ -430,7 +443,7 @@ risks being overwritten next time Emacs is killed."
;; Ensure any parent directories exist
(when dir (make-directory dir t)))
(hackernews-load-visited-links)
(prin1 hackernews--visited-ids (current-buffer)))
(hackernews--prin1 hackernews--visited-ids (current-buffer) t))
(error (lwarn 'hackernews :error
"Could not write `hackernews-visited-links-file': %s"
(error-message-string err))))))
Expand Down Expand Up @@ -489,7 +502,7 @@ which see."
;; earlier versions can't return the result of `make-text-button'.
;; Emacs 28.1 started modifying a copy of BEG when it's a string, so
;; subsequent versions must return the result of `make-text-button'.
(if (version< "24.3" emacs-version)
(if (version<= "24.4" emacs-version)
#'make-text-button
(lambda (beg end &rest properties)
(apply #'make-text-button beg end properties)
Expand Down Expand Up @@ -614,14 +627,16 @@ Official major mode key bindings:

;;;; Retrieval

;; At top level for Emacs < 24.4.
(defvar json-array-type)
(defvar json-object-type)
(declare-function json-read "json" ())

(defalias 'hackernews--parse-json
(if (fboundp 'json-parse-buffer)
(lambda ()
(json-parse-buffer :object-type 'alist))
(require 'json)
(defvar json-array-type)
(defvar json-object-type)
(declare-function json-read "json")
(lambda ()
(let ((json-array-type 'vector)
(json-object-type 'alist))
Expand Down

0 comments on commit 1aa6f35

Please sign in to comment.