diff options
Diffstat (limited to '.emacs.d/lisp/my/my-hnreader.el')
-rw-r--r-- | .emacs.d/lisp/my/my-hnreader.el | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/.emacs.d/lisp/my/my-hnreader.el b/.emacs.d/lisp/my/my-hnreader.el deleted file mode 100644 index 4176f8b..0000000 --- a/.emacs.d/lisp/my/my-hnreader.el +++ /dev/null @@ -1,106 +0,0 @@ -;;; my-hnreader.el -- Extensions to hnreader -*- lexical-binding: t -*- - -;; Copyright (C) 2023 Free Software Foundation. - -;; Author: Yuchen Pei <id@ypei.org> -;; Thanh Vuong <thanhvg@gmail.com> -;; Maintainer: Yuchen Pei <id@ypei.org> -;; Package-Requires: ((emacs "28.2")) - -;; This file is part of dotfiles. - -;; dotfiles is free software: you can redistribute it and/or modify it under -;; the terms of the GNU Affero General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; dotfiles 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 Affero General -;; Public License for more details. - -;; You should have received a copy of the GNU Affero General Public -;; License along with dotfiles. If not, see <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Extensions to hnreader. - -;;; Code: - -;; To override `hnreader--print-frontpage-item' -(defun my-hnreader--print-frontpage-item (thing subtext) - "Print THING dom and SUBTEXT dom." - (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) [[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 - url - (dom-text (last (dom-by-tag subtext 'a))))) - )) - - -;; To override `hnreader--print-frontpage' -(defun my-hnreader--print-frontpage (dom buf url) - "Print raw DOM and URL on BUF." - (let ((things (dom-by-class dom "^athing$")) - (subtexts (dom-by-class dom "^subtext$"))) - (with-current-buffer buf - (read-only-mode -1) - (erase-buffer) - (insert "#+STARTUP: overview indent\n") - (hnreader--print-header) - (insert (hnreader--get-route-top-info dom)) - (cl-mapcar #'hnreader--print-frontpage-item things subtexts) - ;; (setq-local org-confirm-elisp-link-function nil) - (if hnreader--history - (insert "\n* "(format "[[elisp:(hnreader-back)][< Back]]" ) " | ") - (insert "\n* ")) - (insert (hnreader--get-morelink dom) " | ") - (insert (format "[[elisp:(hnreader-read-page-back \"%s\")][Reload]]" url) ) - (org-mode) - (goto-char (point-min)) - (forward-line 2)))) - -;; To override `hnreader--print-comments' -(defun my-hnreader--print-comments (dom url) - "Print DOM comment and URL to buffer." - (let ((comments (dom-by-class dom "^athing comtr$")) - (title (hnreader--get-title dom)) - (info (hnreader--get-post-info dom)) - (more-link (dom-by-class dom "morelink"))) - (with-current-buffer (hnreader--get-hn-comment-buffer) - (read-only-mode -1) - (erase-buffer) - (insert "-*-Org-*-\n") - (insert "#+TITLE: " (car title)) - (insert (format "\n%s\n" (cdr title))) - (insert (car info)) - (when (cdr info) - (insert "\n") - (shr-insert-document (cdr info))) - (dolist (comment comments) - (insert (format "%s %s\n" - (hnreader--get-indent - (hnreader--get-img-tag-width comment)) - (hnreader--get-comment-owner 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))))) - (insert "\n* " (format "[[elisp:(hnreader-comment \"%s\")][Reload]]" url)) - (org-mode) - ;; (org-shifttab 3) - (goto-char (point-min)) - (forward-line 2)))) - -(provide 'my-hnreader) -;;; my-hnreader.el ends here |