;;; em-pred.el --- argument predicates and modifiers (ala zsh) -*- lexical-binding:t -*-
-;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
(function
(lambda (str)
(eshell-stringify
- (car (eshell-parse-argument str))))) lst)))
+ (car (eshell-parse-argument str)))))
+ lst)))
(?L . #'(lambda (lst) (mapcar 'downcase lst)))
(?U . #'(lambda (lst) (mapcar 'upcase lst)))
(?C . #'(lambda (lst) (mapcar 'capitalize lst)))
OWNERSHIP:
U owned by effective uid
- u(UID|'user') owned by UID/user
- g(GID|'group') owned by GID/group
+ u(UID|\\='user\\=') owned by UID/user
+ g(GID|\\='group\\=') owned by GID/group
FILE ATTRIBUTES:
l[+-]N +/-/= N links
- a[Mwhms][+-](N|'FILE') access time +/-/= N months/weeks/hours/mins/secs
+ a[Mwhms][+-](N|\\='FILE\\=') access time +/-/= N months/weeks/hours/mins/secs
(days if unspecified) if FILE specified,
- use as comparison basis; so a+'file.c'
+ use as comparison basis; so a+\\='file.c\\='
shows files accessed before file.c was
last accessed
- m[Mwhms][+-](N|'FILE') modification time...
- c[Mwhms][+-](N|'FILE') change time...
+ m[Mwhms][+-](N|\\='FILE\\=') modification time...
+ c[Mwhms][+-](N|\\='FILE\\=') change time...
L[kmp][+-]N file size +/-/= N Kb/Mb/blocks
EXAMPLES:
***/*~f*(-/) recursively (though not traversing symlinks),
find all directories (or symlinks referring to
directories) whose names do not begin with f.
- e*(*Lk+50) executables 50k or larger beginning with 'e'")
+ e*(*Lk+50) executables 50k or larger beginning with `e'")
(defvar eshell-modifier-help-string
"Eshell modifier quick reference:
(defun eshell-parse-modifiers ()
"Parse value modifiers and predicates at point.
-If ALLOW-PREDS is non-nil, predicates will be parsed as well.
Return a cons cell of the form
(PRED-FUNC-LIST . MOD-FUNC-LIST)
-NEW-STRING is STRING minus any modifiers. PRED-FUNC-LIST is a list of
-predicate functions. MOD-FUNC-LIST is a list of result modifier
-functions. PRED-FUNCS take a filename and return t if the test
-succeeds; MOD-FUNCS take any string and preform a modification,
-returning the resultant string."
+PRED-FUNC-LIST is a list of predicate functions. MOD-FUNC-LIST
+is a list of result modifier functions. PRED-FUNCS take a
+filename and return t if the test succeeds; MOD-FUNCS take any
+list of strings and perform a modification, returning the
+resultant list of strings."
(let (negate follow preds mods)
(condition-case nil
(while (not (eobp))
(if (and func (functionp func))
(setq preds (eshell-add-pred-func func preds
negate follow))
- (error "Invalid function predicate '%s'"
+ (error "Invalid function predicate `%s'"
(eshell-stringify func))))
(error "Invalid function predicate")))
((eq char ?^)
(cons `(lambda (lst)
(mapcar (function ,func) lst))
mods))
- (error "Invalid function modifier '%s'"
+ (error "Invalid function modifier `%s'"
(eshell-stringify func))))
(error "Invalid function modifier")))
((eq char ?:)
(forward-char)
(let ((mod (assq (char-after) eshell-modifier-alist)))
(if (not mod)
- (error "Unknown modifier character '%c'" (char-after))
+ (error "Unknown modifier character `%c'" (char-after))
(forward-char)
(setq mods (cons (eval (cdr mod)) mods)))))
(t
(let ((pred (assq char eshell-predicate-alist)))
(if (not pred)
- (error "Unknown predicate character '%c'" char)
+ (error "Unknown predicate character `%c'" char)
(forward-char)
(setq preds
(eshell-add-pred-func (eval (cdr pred)) preds
(defun eshell-pred-file-type (type)
"Return a test which tests that the file is of a certain TYPE.
TYPE must be a character, and should be one of the possible options
-that 'ls -l' will show in the first column of its display. "
+that `ls -l' will show in the first column of its display. "
(when (eq type ?%)
(setq type (char-after))
(if (memq type '(?b ?c))