X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/233ba4d924933cb56129bd7511e6137b7c0b8e3e..db2ed6b798960f4067bbf2c7415f34b95b982818:/lisp/find-cmd.el diff --git a/lisp/find-cmd.el b/lisp/find-cmd.el index 8b0c1eb522..7230761f65 100644 --- a/lisp/find-cmd.el +++ b/lisp/find-cmd.el @@ -1,6 +1,6 @@ ;;; find-cmd.el --- Build a valid find(1) command with sexps -;; Copyright (C) 2008-2011 Free Software Foundation, Inc. +;; Copyright (C) 2008-2015 Free Software Foundation, Inc. ;; Author: Philip Jackson ;; Version: 0.6 @@ -39,6 +39,8 @@ ;;; Code: +(require 'grep) + (defconst find-constituents '((and . find-and) (not . find-not) @@ -63,6 +65,7 @@ (cnewer . (1)) (ctime . (1)) (empty . (0)) + (executable . (0)) (false . (0)) (fstype . (1)) (gid . (1)) @@ -70,37 +73,43 @@ (ilname . (1)) (iname . (1)) (inum . (1)) - (iwholename . (1)) + (ipath . (1)) (iregex . (1)) + (iwholename . (1)) (links . (1)) (lname . (1)) (mmin . (1)) (mtime . (1)) (name . (1)) (newer . (1)) - (nouser . (0)) (nogroup . (0)) + (nouser . (0)) (path . (1)) (perm . (0)) + (readable . (0)) (regex . (1)) - (wholename . (1)) + (samefile . (1)) (size . (1)) (true . (0)) (type . (1)) (uid . (1)) (used . (1)) (user . (1)) + (wholename . (1)) + (writable . (0)) (xtype . (nil)) ;; normal options (always true) + (daystart . (0)) (depth . (0)) (maxdepth . (1)) (mindepth . (1)) (mount . (0)) (noleaf . (0)) - (xdev . (0)) (ignore_readdir_race . (0)) (noignore_readdir_race . (0)) + (regextype . (1)) + (xdev . (0)) ;; actions (delete . (0)) @@ -138,13 +147,15 @@ For example: `default-directory' is used as the initial search path. The result is a string that should be ready for the command line." - (concat - "find " (shell-quote-argument (expand-file-name default-directory)) " " - (cond - ((cdr subfinds) - (mapconcat 'find-to-string subfinds "")) - (t - (find-to-string (car subfinds)))))) + ;; FIXME: Provide a version that returns a list of strings (ready to pass to + ;; call-process). + (concat find-program " " + (shell-quote-argument (expand-file-name default-directory)) " " + (cond + ((cdr subfinds) + (mapconcat #'find-to-string subfinds "")) + (t + (find-to-string (car subfinds)))))) (defun find-and (form) "And FORMs together, so: @@ -154,7 +165,7 @@ will produce: (if (< (length form) 2) (find-to-string (car form)) (concat "\\( " - (mapconcat 'find-to-string form "-and ") + (mapconcat #'find-to-string form "-and ") "\\) "))) (defun find-or (form) @@ -165,7 +176,7 @@ will produce: (if (< (length form) 2) (find-to-string (car form)) (concat "\\( " - (mapconcat 'find-to-string form "-or ") + (mapconcat #'find-to-string form "-or ") "\\) "))) (defun find-not (form) @@ -176,7 +187,7 @@ will produce: If you wanted the FORMs -and(ed) together instead then this would suffice: \(not \(and \(mtime \"+1\"\) \(name \"something\"\)\)\)" - (concat "-not " (find-or (mapcar 'find-to-string form)))) + (concat "-not " (find-or (mapcar #'find-to-string form)))) (defun find-prune (form) "-or together FORMs postfix '-prune' and then -or that with a @@ -187,7 +198,7 @@ will produce (unwrapped): -prune -or -true \\\) -and -name '*.pm' \\\)" (find-or (list - (concat (find-or (mapcar 'find-to-string form)) (find-generic "prune")) + (concat (find-or (mapcar #'find-to-string form)) (find-generic "prune")) (find-generic "true")))) (defun find-generic (option &optional oper argcount args dont-quote)