aboutsummaryrefslogtreecommitdiff
path: root/README.org
blob: 6e41a4b4575e774dd224281bcea074db3c414840 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#+STARTUP:    align fold hidestars oddeven indent 
#+TITLE: Emacs hnreader - Read Hacker News in Emacs
[[http://spacemacs.org][file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg]]

Front page:

[[file:docs/screenshot.png]]

Comments:

[[file:docs/screenshot2.png]]

[[file:docs/screencast.gif]]

* Intro
This package renders hackernews website at https://news.ycombinator.com/ in an
org buffer. Almost everything works. 

The org-mode buffer feature interactive links similar to html.

Features that are not supported are account related features. You cannot add
comment, downvote or upvote.

* Install
Manual: TBD

Melpa

[[https://melpa.org/#/hnreader][file:https://melpa.org/packages/hnreader-badge.svg]]

Spacemacs layer:

https://github.com/thanhvg/spacemacs-eos

* Dependencies
~promise~ and ~request~ are required.
User must have ~org-mode~ 9.2 or later installed also.

* Commands
- ~hnreader-news~: Load news page.
- ~hnreader-past~: Load past page.
- ~hnreader-ask~: Load ask page.
- ~hnreader-show~: Load show page.
- ~hnreader-newest~: Load new link page.
- ~hnreader-more~: Load more.
- ~hnreader-back~: Go back to previous page.
- ~hnreader-comment~: read an HN item url such as
  https://news.ycombinator.com/item?id=1 this is handy when you have the link
  and want to read it in emacs, takes url as param
- ~hnreader-org-insert-hn-link~: insert hn link to org buffer, take url as param
* Remarks
Listing buffer is called ~*HN*~
Command buffer is called ~*HNComments*~

Most of links in Hacker News buffer will run elsip commands on clicking, by default
org-mode will ask you for confirmation. You can disable org confirm message on
clicking
#+begin_example elsip
(setq org-confirm-elisp-link-function nil)
#+end_example

But it is not recommended by the org-mode guide: just change it to ‘y-or-n-p’ if
you want to confirm with a single keystroke rather than having to type "yes".
* Recommended settings for eww
eww can be used to view story. You may want to set these settings for web page
display inside Emacs:

#+begin_example elsip
(setq shr-width 75)
(setq shr-use-fonts nil)
#+end_example

When displaying pictures srolling over them is jumpy. You can try this hack in
your config:
#+begin_src elisp
(with-eval-after-load "shr"
    (defun shr-put-image (spec alt &optional flags)
      "Insert image SPEC with a string ALT.  Return image.
SPEC is either an image data blob, or a list where the first
element is the data blob and the second element is the content-type.
Hack to use `insert-sliced-image' to avoid jerky image scrolling."
      (if (display-graphic-p)
          (let* ((size (cdr (assq 'size flags)))
                 (data (if (consp spec)
                           (car spec)
                         spec))
                 (content-type (and (consp spec)
                                    (cadr spec)))
                 (start (point))
                 (image (cond
                         ((eq size 'original)
                          (create-image data nil t :ascent 100
                                        :format content-type))
                         ((eq content-type 'image/svg+xml)
                          (create-image data 'svg t :ascent 100))
                         ((eq size 'full)
                          (ignore-errors
                            (shr-rescale-image data content-type
                                               (plist-get flags :width)
                                               (plist-get flags :height))))
                         (t
                          (ignore-errors
                            (shr-rescale-image data content-type
                                               (plist-get flags :width)
                                               (plist-get flags :height)))))))
            (when image
              (let* ((image-pixel-cons (image-size image t))
                     (image-pixel-width (car image-pixel-cons))
                     (image-pixel-height (cdr image-pixel-cons))
                     (image-scroll-rows (round (/ image-pixel-height (default-font-height)))))
                ;; When inserting big-ish pictures, put them at the
                ;; beginning of the line.
                (when (and (> (current-column) 0)
                           (> (car (image-size image t)) 400))
                  (insert "\n"))

                (insert-sliced-image image (or alt "*") nil image-scroll-rows 1)
                ;; (if (eq size 'original)
                ;;     (insert-sliced-image image (or alt "*") nil image-scroll-rows 1)
                ;;   (insert-image image (or alt "*")))

                (put-text-property start (point) 'image-size size)
                (when (and shr-image-animate
                           (cond ((fboundp 'image-multi-frame-p)
                                  ;; Only animate multi-frame things that specify a
                                  ;; delay; eg animated gifs as opposed to
                                  ;; multi-page tiffs.  FIXME?
                                  (cdr (image-multi-frame-p image)))
                                 ((fboundp 'image-animated-p)
                                  (image-animated-p image))))
                  (image-animate image nil 60))))
            image)
        (insert (or alt "")))))
#+end_src