                              (cond
                               ((and (listp symbol) (imenu--subalist-p symbol))
                                (addsymbols symbol))
-                              
+
                               ((listp symbol)
                                (setq name (car symbol))
                                (setq position (cdr symbol)))
-                              
+
                               ((stringp symbol)
                                (setq name symbol)
                                (setq position (get-text-property 1 'org-imenu-marker symbol))))
-                             
+
                              (unless (or (null position) (null name))
                                (add-to-list 'symbol-names name)
                                (add-to-list 'name-and-pos (cons name position))))))))

;;; Commentary:

;; This minor mode exists to mimick TextMate's awesome
;; features. 

;;    ⌘T - Go to File
;;  ⇧⌘T - Go to Symbol

  (setq *textmate-project-files* nil)
  (message "textmate-mode cache cleared."))

(defun textmate-toggle-camel-case ()
  "Toggle current sexp between camelCase and snake_case, like TextMate C-_."
  (interactive)
  (if (thing-at-point 'word)
      (progn
	(unless (looking-at "\\<") (backward-sexp))
	(let ((case-fold-search nil)
	      (start (point))
	      (end (save-excursion (forward-sexp) (point))))
	  (if (and (looking-at "[a-z0-9_]+") (= end (match-end 0))) ; snake-case
	      (progn
		(goto-char start)
		(while (re-search-forward "_[a-z]" end t)
		  (goto-char (1- (point)))
		  (delete-char -1)
		  (upcase-region (point) (1+ (point)))
		  (setq end (1- end))))
	    (downcase-region (point) (1+ (point)))
	    (while (re-search-forward "[A-Z][a-z]" end t)
	      (forward-char -2)
	      (insert "_")
	      (downcase-region (point) (1+ (point)))
	      (forward-char 1)
	      (setq end (1+ end)))
	    (downcase-region start end)
	    )))))

;;; Utilities

(defun textmate-also-ignore (pattern)
  "Also ignore PATTERN in project files."
  (setq *textmate-gf-exclude*
    (concat *textmate-gf-exclude* "|" pattern)))

(defun textmate-project-root-type (root)
  (cond ((member ".git" (directory-files root)) "git")
        ((member ".hg" (directory-files root)) "hg")
        (t "ls")
        (t "unknown")
   ))

(defun textmate-project-files (root)
  (let ((type (textmate-project-root-type root)))
    (message "SEARCHING FILES")
    (cond ((string= type "git") (split-string
                           (shell-command-to-string
                            (concat "cd " root " && git ls-files")) "\n" t))
          ((string= type "hg") (split-string
                                (shell-command-to-string
                           (concat "cd " root " && hg manifest")) "\n" t))
          ((string= type "ls") (split-string
                                (shell-command-to-string
                                 (concat 
                                  "find " root " -type f  | grep -vE '" 
                                  *textmate-gf-exclude* 
                                  "' | sed 's:" 
                                  *textmate-project-root* 
                                  "/::'")) "\n" t))
          ((string= type "unknown") (textmate-cached-project-files-find root)))))

(defun textmate-project-files-find (root)
  (split-string
    (shell-command-to-string
     (concat
      "find "
      root
      " -type f  | grep -vE '"
      *textmate-gf-exclude*
      "' | sed 's:"
      *textmate-project-root*
      "/::'")) "\n" t))

(defun textmate-cached-project-files-find (&optional root)
  (cond
   ((null textmate-use-file-cache) (textmate-project-files root))
   ((equal (textmate-project-root) (car *textmate-project-files*))
    (cdr *textmate-project-files*))
   (t (cdr (setq *textmate-project-files*
                 `(,root . ,(textmate-project-files root)))))))

(defun textmate-project-root ()
  (when (or
         (null *textmate-project-root*)
         (not (string-match *textmate-project-root* default-directory)))
    (let ((root (textmate-find-project-root)))
      (if root
