 
   (dolist (new-file new-files)
     (message (concat "path: " dirname ", file:" new-file)))
-;    (add-to-list 'all-files-and-dirs (concat (file-name-as-directory dirname) new-file)))
-;    (add-to-list 'all-files-and-dirs (concat 
     (add-to-list 'all-files-and-dirs `((dir . ,dirname) (file . ,new-files)))
 
-;(message "stored everything")
+  all-files-and-dirs))
+
+(setq dir-project-root (find-next-settings-file))
+(setq dir-inbox (concat dir-project-root "inbox/"))
+(setq dirs-and-files (find-files-and-directories dir-inbox))
 
 
-;    (message all-files-and-dirs)
-  all-files-and-dirs))
+(defun create-file-selection-form (files-and-dirs)
+  (switch-to-buffer "*Inbox Selection*")
+  (kill-all-local-variables)
+  (setq buffer-read-only nil)
+  (let ((inhibit-read-only t))
+    (erase-buffer))
+  (remove-overlays)
+
+  ;; write the names of all directories and files into the buffer
+  (while files-and-dirs
+    (setq cur-entry (car files-and-dirs))
+    (message (cdr (assoc 'dir cur-entry)))
+    (setq cur-dirname (assoc 'dir cur-entry))
+    (setq cur-files (cdr (assoc 'file cur-entry)))
+
+    (insert (cdr (assoc 'dir cur-entry)))
+    (insert "\n")
+    (insert (make-string 20 ?-))
+    (insert "\n")
+
+    ;; add the files to the current dir
+    (while cur-files
+      (setq cur-file (car cur-files))
+      (insert cur-file)
+
+      (setq cur-files (cdr cur-files))
+
+      (if cur-files
+	  (insert "\n")))
+
+    (setq files-and-dirs (cdr files-and-dirs))
+    (if files-and-dirs
+	(insert (make-string 2 ?\n))))
+
+  (setq buffer-read-only t)
+
+  (interactive "p")
+  (use-local-map rc-menu-mode-map))
+
+(create-file-selection-form (find-files-and-directories dir-inbox))
 
 
 
-
-
-(setq dir-project-root (find-next-settings-file))
-(setq dir-inbox (concat dir-project-root "inbox/"))
-;(print-elements-of-list (find-files-and-directories dir-inbox))
-(setq dirs-and-files (find-files-and-directories dir-inbox))
-
-;(print-elements-of-list (cdr (car dirs-and-files)))
-
-
-
-
-

(require 'json)

(setq debug-on-error t)

(defun print-elements-of-list (list)
  "Print each element of LIST on a line of its own."
  (if list

    (setq list (cdr list)))
  (message "the list is empty.")))


;; function to find the path to the next (upwards in the directory tree)
;; settings file.
(defun find-next-settings-file ()
  (setq cur-dir (buffer-file-name))

  (setq idx-sep  (length cur-dir))
  (setq b-stop-looping nil)
  (while (and (> idx-sep 0) (not b-stop-looping))
    ;; find the last path seperator in the path string
    (setq idx-sep 0)
    (setq read-pos 0)
    
    (while (< read-pos (- (length cur-dir) 1))
      (if (string= (substring cur-dir read-pos (+ read-pos 1)) path-seperator)
	  (setq idx-sep read-pos))

      (setq read-pos (1+ read-pos)))

    (setq cur-pos idx-sep)
    (setq cur-dir (substring cur-dir 0 (1+ idx-sep)))
    (setq candidate-path (concat cur-dir settings-file-name))
    (when (file-exists-p candidate-path)
      (setq b-stop-looping t)))

  (if b-stop-looping cur-dir nil))


(defun read-settings-file (filepath)
  (setq settings (json-read-file filepath)))

(defun print-alist (list)
  (while list
    (setq cur-element (car list))
    (setq cur-key (car cur-element))
    (setq cur-value (cdr cur-element))
    (message (format "%10s: %s" cur-key cur-value))
    (setq list (cdr list))))


(defun find-all-inbox-entries ()
  ;; get the project directory
  (setq dir-project-root (find-next-settings-file))
  (setq dir-inbox (concat dir-project-root "inbox/"))
  (message dir-inbox)

  ;; traverse through the subdirectories
  (message (directory-files-and-attributes dir-inbox)))


(defun find-files-and-directories (dirname)
  (let (cur-files '() all-files-and-dirs '())
