Skip to content

Commit

Permalink
feat: show title instead of url when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Ragone committed Sep 4, 2019
1 parent 13a691c commit 9d76d6a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions asx.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
;; Created: 24 August 2019
;; Homepage: https://github.com/ragone/asx
;; Keywords: convenience
;; Version: 0.1.0
;; Version: 0.1.1
;; Package-Requires: ((request "0.3.0") (org "9.2.5") (seq "2") (emacs "25"))

;; This file is not part of GNU Emacs.
Expand Down Expand Up @@ -143,7 +143,6 @@ Otherwise show the first post."

(defun asx--request (url callback)
"Request URL with CALLBACK."
(message "Loading %s" url)
(let ((request-curl-options (list (format "-A %s" (asx--get-user-agent)))))
(request url
:parser (lambda () (libxml-parse-html-region (point-min) (point-max)))
Expand All @@ -152,6 +151,11 @@ Otherwise show the first post."
:success (cl-function (lambda (&key data &allow-other-keys)
(funcall callback data))))))

(defun asx--request-post (post)
"Request POST."
(message "Loading: %s" (car post))
(asx--request (cdr post) #'asx--insert-post-dom))

(defun asx--get-user-agent ()
"Return random user-agent from `asx--user-agents'."
(seq-random-elt asx--user-agents))
Expand All @@ -171,8 +175,7 @@ Otherwise show the first post."
:test #'equal
:key #'car))
0))
(asx--request (cdr (asx--get-current-post))
#'asx--insert-post-dom))
(asx--request-post (asx--get-current-post)))

(defun asx--extract-links (dom)
"Extract links from DOM."
Expand Down Expand Up @@ -352,8 +355,7 @@ Otherwise show the first post."
"Jump N steps in `asx--posts' and insert the post."
(setq asx--current-post-index
(mod (+ n asx--current-post-index) (length asx--posts)))
(asx--request (cdr (asx--get-current-post))
#'asx--insert-post-dom))
(asx--request-post (asx--get-current-post)))

;;;; Footer

Expand Down

0 comments on commit 9d76d6a

Please sign in to comment.