;;; find-cmd.el --- Build a valid find(1) command with sexps
-;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2015 Free Software Foundation, Inc.
;; Author: Philip Jackson <phil@shellarchive.co.uk>
;; Version: 0.6
;;; Code:
+(require 'grep)
+
(defconst find-constituents
'((and . find-and)
(not . find-not)
`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:
(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)
(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)
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
-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)