2

Is there a template to create a group of directories and files for a new project?

Example:

  • List of predefined directories: (.c .c_b .o .o_b .docs .invoices)

  • List of predefined blank files: (1add.txt .../invoices/costs.txt)

M-x template-setup

(read-string "Please select your project root directory: " default-directory)

  • If file or directory already exists, then skip and keep on going creating the remainder.
lawlist
  • 18,826
  • 5
  • 37
  • 118
  • 1
    I believe http://cedet.sourceforge.net/srecode.shtml is the tool used by EDE, but it may be a bit too much, if you are just looking for something simple. – wvxvw Dec 25 '14 at 15:31
  • 1
    Not sure what you're looking for. But (with [**Bookmark+**](http://www.emacswiki.org/BookmarkPlus) you can bookmark any set of files and directories. And the bookmark can use Dired, thus recording markings, omission set, and subdir inclusions. – Drew Dec 25 '14 at 16:49

2 Answers2

4

The package skeletor allows one to create projects based on predefined templates. It also allows you to define custom project templates. You might want to try it out.

Iqbal Ansari
  • 7,468
  • 1
  • 28
  • 31
2

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)))
lawlist
  • 18,826
  • 5
  • 37
  • 118