aboutsummaryrefslogtreecommitdiff
path: root/sx.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-16 13:30:58 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-16 13:30:58 -0200
commit006c85d3a241e20b6b03ab4499dbc467f8431ddd (patch)
tree4799ce852da6e4308080669aa577906ef56f8bbc /sx.el
parentbed5191a0137cb115656baf6ae3535b2a646d0b2 (diff)
parent389e433953bba4003b102748dbbf5f8a9b421a51 (diff)
Merge branch 'master' into tag-buttons
Conflicts: sx-question.el
Diffstat (limited to 'sx.el')
-rw-r--r--sx.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/sx.el b/sx.el
index 36ecfca..a385a84 100644
--- a/sx.el
+++ b/sx.el
@@ -259,6 +259,20 @@ whenever BODY evaluates to nil."
:filter (lambda (&optional _)
(when (progn ,@body) ,def)))))
+(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))
+ `(progn
+ ;; In using `defalias', the macro supports both function
+ ;; symbols and lambda expressions.
+ (defun ,name (a b)
+ ,doc
+ (funcall ,compare-func
+ (funcall ,get-func a)
+ (funcall ,get-func b)))))
+
;;; Printing request data
(defvar sx--overlays nil
@@ -354,13 +368,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,