1. Mike Steder
  2. dotfiles


dotfiles / emacs.d / msproject.el

;;; msproject.el

;; About:

;; This module describes project-wide functionality
;; for Textura projects and others.

;;; Ideas for functionality:

;; 1. find-in-project to recursively grep from the project root down
;; independent of where the grep started.
;; 2. ...
;; ?. Build and locate TAGS files?

(defvar msproject-root-files
  "File(s) that identify the project root"

;; Depending on the type of project
;; we may use one of many possible files
;; as the project root.
;; For example:
;;   - CPM: tconsole.py
;;   - arbitrary django project: manage.py
;;   - arbitrary twisted project: twisted (twisted plugin directory?)

(defun msproject-project-root ()
  (let (root)
    (setq root
          (car (delq nil (mapcar (lambda (f) (locate-dominating-file (if buffer-file-name buffer-file-name ".") f)) msproject-root-files)))
    (if (eq root nil)

(defun msproject-show-project-root ()
  (message "project-root: %s" (msproject-project-root))

(defun msproject-grep-find-command ()
  "modifies grep-find-command to point at the root directory"
  (concat (combine-and-quote-strings
   (cons "find" (cons (msproject-project-root) (cdr (cdr (split-string grep-find-command))))))
          " ")

(defun find-in-project (command-args)
  "Run grep via find, with user-specified args COMMAND-ARGS.
Collect output in a buffer.
While find runs asynchronously, you can use the \\[next-error] command
to find the text that grep hits refer to.

This command uses a special history list for its arguments, so you can
easily repeat a find command."
     (if grep-find-command
	 (list (read-shell-command "Run find (like this): "
                               (msproject-grep-find-command) 'grep-find-history))
       ;; No default was set
        "compile.el: No `grep-find-command' command available. Press RET.")
       (list nil))))
  (when command-args
    (let ((null-device nil))		; see grep
      (grep command-args))))

(defun msproject-get-ctags-path ()

(defun msproject-create-tags-in-directory (dir-name)
  "Create tags file."
  (interactive "DDirectory: ")
  ; -e is for emacs!
   (format "%s -f %s/TAGS -e --recurse %s" (msproject-get-ctags-path) dir-name dir-name)))

(defun msproject-create-tags ()
  (msproject-create-tags-in-directory (msproject-project-root))