From b51a68104325f98e056160e87c9efa0e041c49a1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 20 May 2023 22:20:07 +1000 Subject: My changes Slight adjustment of styles Insert mode indicating line at the beginning of the buffer Remove hnreader--print-node Customization of shr-* is pointless --- hnreader.el | 31 +++++++++---------------------- 1 file 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))))) -- cgit v1.2.3