revert-buffer-function #'kubed-display-resource-revert
bookmark-make-record-function #'kubed-display-resource-make-bookmark)))
+(defun kubed-list-filter-lt-operator (v s)
+ "Return non-nil if S is less than V as a number or as a string."
+ (let ((l (string-to-number s)) (r (string-to-number v)))
+ (if (= l r) (string< s v) (< l r))))
+
+(defun kubed-list-filter-gt-operator (v s)
+ "Return non-nil if S is greater than V as a number or as a string."
+ (let ((l (string-to-number s)) (r (string-to-number v)))
+ (if (= l r) (string> s v) (> l r))))
+
(defcustom kubed-list-filter-operator-alist
- '((= . string=)
- (~ . string-match-p))
+ `((= . string=)
+ (~ . string-match-p)
+ (< . kubed-list-filter-lt-operator)
+ (> . kubed-list-filter-gt-operator))
"Association list of filter operators and functions that implement them.
-Element of this list are cons cells (OP . FN), where OP is a symbol that
+Elements of the list are cons cells (OP . FN), where OP is a symbol that
is used as a filter operator and FN is a function that implements OP.
FN takes two arguments, a string STR and a parameter VAL. FN should
return non-nil if STR and VAL are related according to OP: to determine
if a line in which column COL is STR satisfies the filter (OP COL VAL),
-Kubed checks if the form (FN STR VAL) evaluates to non-nil."
+Kubed checks if the form (FN VAL STR) evaluates to non-nil."
:type '(alist :key-type (symbol :tag "Operator") :value-type function))
(defun kubed-list-interpret-atomic-filter (atom)
Filters can be simple (@dfn{atomic filters}) or complex (@dfn{composed
filters}). In the simple case, you enter a filter in the minibuffer
in the format @w{@samp{@var{op} @var{col} @var{val}}}, where @var{op}
-is a comparison operator, either @samp{=} or @samp{~}, @var{col} is a
-column name, and @var{val} is a value to compare to values of
-@var{col} with @var{op}.
+is a comparison operator, one of @samp{=}, @samp{~}, @samp{<} and
+@samp{>}; @var{col} is a column name; and @var{val} is a value to
+compare to values of @var{col} with @var{op}.
If @var{op} is @samp{=}, it says to keep only lines whose @var{col}
equals @var{val}. If @var{op} is @samp{~}, it says to keep lines
-whose @var{col} matches the @var{val} as a regular expression. For
+whose @var{col} matches the @var{val} as a regular expression.
+@samp{<} and @samp{>} compare column values to numeric values. For
example, the filter @samp{= Name foobar} keeps only resources whose
name is @samp{foobar}. To include whitespace in @var{val}, wrap
@var{val} in double quotes: @samp{= Name "foo bar"}.