Initial Draft (December 25, 2014): The following is a revised initial draft. It incorporates a lesson learned from @tarsius as to using a let-bound default-directory
with start-process
( https://emacs.stackexchange.com/a/5739/2287 ) [i.e., it must have a trailing forward slash]; and, a lesson learned from @legoscia regarding using lexical-let
to penetrate the set-process-sentinel
hierarchy with a temporary variable value ( https://stackoverflow.com/a/24549625/2112489 ); and, a prior discovery of mine regarding using recursive-edit
to temporarily hold off going through the remainder of a function until the sub-processes have finished ( https://stackoverflow.com/questions/23237869/fine-tuning-set-process-sentinel-set-process-filter-start-process ).
EDIT (December 29, 2014): Removed default-directory
from lexical-let
and also from the let-bound wrap around of the start-process
statement -- said code was not needed. recursive-edit
is now a part of the mapcar
section of code relating to file creation -- exiting occurs each time a new file has been created.
(let* (
(proposed-directories '(
"0.pdd_fdd" "0.oah" "0.c" "0.c_b" "0.o" "0.o_b" "0.f" "0.discovery"
"0.docs" "0.deeds" "0.pleadings" "0.invoices"))
(proposed-filenames '("1add.txt" "0.invoices/bill.txt"))
(default-directory (file-name-as-directory ;; ensure there is a trailing forward slash
(read-string "Set the temporary default directory: " default-directory))) )
(mapcar
(lambda (x) (make-directory x t))
proposed-directories)
(mapcar
(lambda (x)
(lexical-let ((x x))
(set-process-sentinel
(start-process "touch-file" nil "touch" x)
(lambda (p e)
(when (= 0 (process-exit-status p))
(message "Created: %s" x)
(throw 'exit nil)))))
(recursive-edit))
proposed-filenames)
(when (eq major-mode 'dired-mode)
(revert-buffer)))