aboutsummaryrefslogtreecommitdiff
path: root/sx.el
diff options
context:
space:
mode:
Diffstat (limited to 'sx.el')
-rw-r--r--sx.el33
1 files changed, 18 insertions, 15 deletions
diff --git a/sx.el b/sx.el
index 785e0c4..33b36b6 100644
--- a/sx.el
+++ b/sx.el
@@ -4,7 +4,7 @@
;; Author: Sean Allred <code@seanallred.com>
;; URL: https://github.com/vermiculus/sx.el/
-;; Version: 0.1
+;; Version: 0.2
;; Keywords: help, hypermedia, tools
;; Package-Requires: ((emacs "24.1") (cl-lib "0.5") (json "1.3") (markdown-mode "2.0") (let-alist "1.0.3"))
@@ -28,7 +28,7 @@
;;; Code:
(require 'tabulated-list)
-(defconst sx-version "0.1" "Version of the `sx' package.")
+(defconst sx-version "0.2" "Version of the `sx' package.")
(defgroup sx nil
"Customization group for the `sx' package."
@@ -148,12 +148,7 @@ with a `link' property)."
;; From URL
(string-match (rx "/questions/"
;; Question ID
- (group-n 1 (+ digit)) "/"
- ;; Optional question title
- (optional (+ (not (any "/"))) "/")
- ;; Garbage at the end
- (optional (and (any "?#") (* any)))
- string-end)
+ (group-n 1 (+ digit)) "/")
link))
(push '(type . question) result)))
(push (cons 'id (string-to-number (match-string-no-properties 1 link)))
@@ -325,6 +320,21 @@ ID is an integer."
(when (looking-at-p "$")
(forward-char 1)))))
+(defmacro sx--create-comparator (name doc compare-func get-func)
+ "Define a new comparator called NAME with documentation DOC.
+COMPARE-FUNC is a function that takes the return value of
+GET-FUNC and performs the actual comparison."
+ (declare (indent 1) (doc-string 2))
+ `(defun ,name (a b)
+ ,doc
+ (funcall ,compare-func
+ (funcall ,get-func a)
+ (funcall ,get-func b))))
+
+(defun sx--squash-whitespace (string)
+ "Return STRING with consecutive whitespace squashed together."
+ (replace-regexp-in-string "[ \r\n]+" " " string))
+
;;; Printing request data
(defvar sx--overlays nil
@@ -420,13 +430,6 @@ Run after `sx-init--internal-hook'."
This is used internally to set initial values for variables such
as filters.")
-(defun sx--< (property x y &optional predicate)
- "Non-nil if PROPERTY attribute of alist X is less than that of Y.
-With optional argument PREDICATE, use it instead of `<'."
- (funcall (or predicate #'<)
- (cdr (assoc property x))
- (cdr (assoc property y))))
-
(defmacro sx-init-variable (variable value &optional setter)
"Set VARIABLE to VALUE using SETTER.
SETTER should be a function of two arguments. If SETTER is nil,