aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGia Thanh Vuong <thanhvg@gmail.com>2019-08-20 16:49:05 -0600
committerGia Thanh Vuong <thanhvg@gmail.com>2019-08-20 16:49:05 -0600
commitc9b8bc6437badf95361c3c0565795c60c0108ce0 (patch)
treecd6173ae969b21a87b9965278dd178f935291004
parent365c44296a3f2b078d2a1599785766a5b34e7ad3 (diff)
wip
-rw-r--r--TODOs.org52
-rw-r--r--hnreader.el39
2 files changed, 70 insertions, 21 deletions
diff --git a/TODOs.org b/TODOs.org
index ec73f77..fba0745 100644
--- a/TODOs.org
+++ b/TODOs.org
@@ -20,7 +20,7 @@ child
* TODO show number of child comments
https://emacs.stackexchange.com/questions/10245/counting-sub-headings-in-org-mode-using-elisp
or recursive on dom will be just fine
-* DONE run eslip on org link
+* TODO run eslip on org link
#+begin_example org-mode
[[elisp:(find-function 'describe-function)]]
@@ -30,9 +30,55 @@ or recursive on dom will be just fine
;; (setq-local org-confirm-elisp-link-function nil)
+ user org-add-link-type to avoid confirm message
+
+ (org-add-link-type
+ "grep" 'endless/follow-grep-link)
+
+(defun endless/follow-grep-link (regexp)
+ "Run `rgrep' with REGEXP as argument."
+ (grep-compute-defaults)
+ (rgrep regexp "*" (expand-file-name "./")))
+https://endlessparentheses.com/use-org-mode-links-for-absolutely-anything.html
+
+use this one
+
+(org-link-set-parameters TYPE &rest PARAMETERS)
+
+Set link TYPE properties to PARAMETERS.
+ PARAMETERS should be :key val pairs.
+how can i register this handler?
+autoload?
+
+just a private flag on running
+
* DONE comment page show main link and intro text
* TODO display page takes page number
* TODO reload page
* TODO frontpage has next page link
-* remove * in text
-find and replace raw htlm '< *' with '< -'
+* DONE remove * in text
+CLOSED: [2019-08-20 Tue 13:39]
+find and replace raw htlm '>*' with '>-'
+* add eww link
+* INPROGRESS long links are cut off
+(get-text-property (point) 'shr-url)
+(get-text-property (point) 'htmlize-link)
+(text-properties-at (point))
+
+(font-lock-multiline t htmlize-link (:uri "elisp:(hnreader-comment 20751164)")
+help-echo "LINK: elisp:(hnreader-comment 20751164)" keymap (keymap (follow-link
+. mouse-face) (mouse-3 . org-find-file-at-mouse) (mouse-2 . org-open-at-mouse))
+mouse-face highlight face org-link wrap-prefix #(" " 0 2 (face org-indent))
+line-prefix #(" " 0 2 (face org-indent)) fontified t)
+
+https://emacs.stackexchange.com/questions/16909/how-can-i-get-all-file-links-in-one-org-mode-file
+Assuming the current buffer is an org-mode buffer, the following code collects paths of file links in the current buffer.
+
+#+begin_example elisp
+(org-element-map (org-element-parse-buffer) 'link
+ (lambda (link)
+ (when (string= (org-element-property :type link) "file")
+ (org-element-property :path link))))
+#+end_example
+
+In an org buffer, (org-element-parse-buffer) returns the parse tree of the current buffer. And you can map over it with org-element-map.
diff --git a/hnreader.el b/hnreader.el
index 7f54cf8..4dfc91f 100644
--- a/hnreader.el
+++ b/hnreader.el
@@ -43,7 +43,7 @@ third one is 80.")
"Print MSG message and prepare window for BUF buffer."
(when (not (equal (window-buffer) buf))
(switch-to-buffer-other-window buf))
- ;; (display-buffer buf '(display-buffer-use-some-window (inhibit-same-window . t))))
+ ;; (display-buffer buf '(display-buffer-use-some-window (inhibit-same-window . t))))
(with-current-buffer buf
(read-only-mode -1)
(erase-buffer)
@@ -54,22 +54,24 @@ third one is 80.")
(defun hnreader--print-frontpage-item (thing subtext)
"Print THING dom and SUBTEXT dom."
- (insert (format "\n* %s %s (%s) [%s]\n"
- ;; rank
- (dom-text (dom-by-class thing "^rank$"))
- ;; title
- (dom-text (dom-by-class thing "^storylink$"))
- ;; points
- (dom-text (dom-by-class subtext "^score$"))
- ;; comments
- (dom-text (last (dom-by-tag subtext 'a)))))
- ;; (setq thanh subtext)
- ;; link
- (insert (dom-attr (dom-by-class thing "^storylink$") 'href) "\n" )
- ;; comment link
- (insert (format "[[elisp:(hnreader-comment %s)][https://news.ycombinator.com/item?id=%s]]"
- (dom-attr thing 'id)
- (dom-attr thing 'id))))
+ (let ((id (dom-attr thing 'id))
+ (story-link (dom-attr (dom-by-class thing "^storylink$") 'href)))
+ (insert (format "\n* %s %s (%s) [%s]\n"
+ ;; rank
+ (dom-text (dom-by-class thing "^rank$"))
+ ;; title
+ (dom-text (dom-by-class thing "^storylink$"))
+ ;; 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" story-link story-link))
+ ;; comment link
+ (insert (format "[[elisp:(hnreader-comment %s)][https://news.ycombinator.com/item?id=%s]]"
+ id
+ id)) ))
(defun hnreader--print-frontpage (dom buf)
"Print raw DOM on BUF."
@@ -98,7 +100,8 @@ third one is 80.")
(erase-buffer)
(insert "#+STARTUP: indent\n")
(insert "#+TITLE: " (car title))
- (insert "\n" (cdr title))
+ (insert (format "\n%s\n[[eww:%s][view story in eww]]\n" (cdr title) (cdr title)))
+ ;; (insert "\n" (cdr title))
(dolist (comment comments)
;; (setq thanh comment)
(insert (format "%s %s\n"