aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-12-26 17:34:37 -0500
committerSean Allred <code@seanallred.com>2014-12-26 17:34:37 -0500
commit970acd6f7e5920ed6492a4a74e65eae9e29838b6 (patch)
tree732bc67d03226721844cec434504e51fa1141912
parentd732176007abdcc3395f7188dc918981d9ff2801 (diff)
Add some explanatory comments
-rw-r--r--sx.el21
1 files changed, 16 insertions, 5 deletions
diff --git a/sx.el b/sx.el
index 19c5f12..c460f62 100644
--- a/sx.el
+++ b/sx.el
@@ -328,19 +328,24 @@ If ALIST doesn't have a `site' property, one is created using the
(defun sx--link-to-data (link)
"Convert string LINK into data that can be displayed."
(let ((result (list (cons 'site (sx--site link)))))
+ ;; Try to strip a question or answer ID
(when (or
;; Answer
(and (or (string-match
+ ;; From 'Share' button
(rx "/a/"
- ;; Answer ID
+ ;; Question ID
(group (1+ digit))
- "/"
- (1+ digit)
+ ;; User ID
+ "/" (1+ digit)
+ ;; Answer ID
(group (or (sequence "#" (0+ any)) ""))
string-end) link)
(string-match
+ ;; From URL
(rx "/questions/" (1+ digit) "/"
(1+ (not (any "/"))) "/"
+ ;; User ID
(group digit)
(optional "/")
(group (or (sequence "#" (0+ any)) ""))
@@ -348,13 +353,19 @@ If ALIST doesn't have a `site' property, one is created using the
(push '(type . answer) result))
;; Question
(and (or (string-match
+ ;; From 'Share' button
(rx "/q/"
- (group (1+ digit)) "/"
- (1+ digit)
+ ;; Question ID
+ (group (1+ digit))
+ ;; User ID
+ "/" (1+ digit)
+ ;; Answer or Comment ID
(group (or (sequence "#" (0+ any)) ""))
string-end) link)
(string-match
+ ;; From URL
(rx "/questions/"
+ ;; Question ID
(group (1+ digit))
"/") link))
(push '(type . question) result)))