aboutsummaryrefslogtreecommitdiff
path: root/sx.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:19:05 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:19:05 -0300
commit7df79a35edcb79e7caca4a0d50fcec54d5f68fef (patch)
treecc2bcb61f4350dce6a5b5ecba12218f25645275f /sx.el
parent83538b215f75256b86987b999504a2d87d0db307 (diff)
parentf4ba0e2a11581477e412c276080a049d19351361 (diff)
Merge branch 'master' into question-mode-line
Diffstat (limited to 'sx.el')
-rw-r--r--sx.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/sx.el b/sx.el
index fc0af92..e5e9c3e 100644
--- a/sx.el
+++ b/sx.el
@@ -195,6 +195,11 @@ If ALIST doesn't have a `site' property, one is created using the
;;; Utility Functions
+(defun sx--split-string (string &optional separators)
+ "Split STRING into substrings bounded by matches for SEPARATORS."
+ (mapcar (lambda (s) (replace-regexp-in-string "\\` +\\| +\\'" "" s))
+ (split-string string separators 'omit-nulls)))
+
(defun sx-completing-read (&rest args)
"Like `completing-read', but possibly use ido.
All ARGS are passed to `completing-read' or `ido-completing-read'."
@@ -341,6 +346,12 @@ GET-FUNC and performs the actual comparison."
"Return STRING with consecutive whitespace squashed together."
(replace-regexp-in-string "[ \r\n]+" " " string))
+(defun sx--invert-predicate (predicate)
+ "Return PREDICATE function with arguments inverted.
+For instance (sx--invert-predicate #'<) is the same as #'>.
+Note this is not the same as negating PREDICATE."
+ (lambda (&rest args) (apply predicate (reverse args))))
+
;;; Printing request data
(defvar sx--overlays nil