aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2023-05-20 22:20:07 +1000
committerYuchen Pei <id@ypei.org>2023-06-17 16:30:03 +1000
commitb51a68104325f98e056160e87c9efa0e041c49a1 (patch)
tree94faebd4b8d57b22a40ae44285e0f745845bc707
parent8481681c9b2f3bd1ddab12a657f5f3827e288ad7 (diff)
My changesHEADmaster
Slight adjustment of styles Insert mode indicating line at the beginning of the buffer Remove hnreader--print-node Customization of shr-* is pointless
-rw-r--r--hnreader.el31
1 files changed, 9 insertions, 22 deletions
diff --git a/hnreader.el b/hnreader.el
index f576c7b..4660fc4 100644
--- a/hnreader.el
+++ b/hnreader.el
@@ -161,22 +161,18 @@ third one is 80.")
(let* ((url (format "https://news.ycombinator.com/item?id=%s" (dom-attr thing 'id)))
(a-node (dom-child-by-tag (dom-by-class thing "^titleline$") 'a))
(title-link (dom-attr a-node 'href)))
- (insert (format "\n* %s %s (%s) [%s]\n"
+ (insert (format "\n* %s [[%s][%s]] (%s) [[elisp:(hnreader-comment \"%s\")][%s]]"
;; rank
(dom-text (dom-by-class thing "^rank$"))
+ title-link
;; title
(dom-text a-node)
;; points
(dom-text (dom-by-class subtext "^score$"))
;; comments
- (dom-text (last (dom-by-tag subtext 'a)))))
- ;; (setq thanh subtext)
- ;; link
- (insert (format "%s\n[[eww:%s][view story in eww]]\n" title-link title-link))
- ;; comment link
- (insert (format "[[elisp:(hnreader-comment \"%s\")][%s]]"
url
- url))))
+ (dom-text (last (dom-by-tag subtext 'a)))))
+ ))
(defun hnreader--get-morelink (dom)
"Get more link from DOM."
@@ -229,7 +225,7 @@ third one is 80.")
(with-current-buffer buf
(read-only-mode -1)
(erase-buffer)
- (insert "#+STARTUP: overview indent\n")
+ (insert "-*-Org-*-\n")
(hnreader--print-header)
(insert (hnreader--get-route-top-info dom))
(cl-mapcar #'hnreader--print-frontpage-item things subtexts)
@@ -258,8 +254,6 @@ third one is 80.")
(intro (if (= (length tr-tag) 6)
(nth 3 tr-tag)
nil)))
- ;; (setq thanh tr-tag)
- ;; (setq thanh-fat fat-item)
(cons
(format "%s | by %s | %s\n"
(dom-text score)
@@ -267,12 +261,6 @@ third one is 80.")
(dom-text comment-count))
intro)))
-(defun hnreader--print-node (node)
- "Print the NODE with extra options."
- (let ((shr-width 80)
- (shr-use-fonts nil))
- (shr-insert-document node)))
-
(defun hnreader--print-comments (dom url)
"Print DOM comment and URL to buffer."
(let ((comments (dom-by-class dom "^athing comtr$"))
@@ -282,20 +270,19 @@ third one is 80.")
(with-current-buffer (hnreader--get-hn-comment-buffer)
(read-only-mode -1)
(erase-buffer)
- (insert "#+STARTUP: overview indent\n")
+ (insert "-*-Org-*-\n")
(insert "#+TITLE: " (car title))
- (insert (format "\n%s\n[[eww:%s][view story in eww]]\n" (cdr title) (cdr title)))
+ (insert (format "\n%s\n" (cdr title)))
(insert (car info))
(when (cdr info)
(insert "\n")
- (hnreader--print-node (cdr info)))
+ (shr-insert-document (cdr info)))
(dolist (comment comments)
- ;; (setq thanh comment)
(insert (format "%s %s\n"
(hnreader--get-indent
(hnreader--get-img-tag-width comment))
(hnreader--get-comment-owner comment)))
- (hnreader--print-node (hnreader--get-comment comment)))
+ (shr-insert-document (hnreader--get-comment comment)))
(when more-link
(insert "\n* " (format "[[elisp:(hnreader-comment \"%s\")][More]]" (concat "https://news.ycombinator.com/"
(dom-attr more-link 'href)))))