public
Description: Phil Hagelberg's personal dotfiles collection: the product of years of accumulated obsessive minor tweaks. Mostly Emacs Lisp.
Homepage: http://technomancy.us
Clone URL: git://github.com/technomancy/dotfiles.git
init fixes and document find-file-in-project
technomancy (author)
Fri May 02 09:30:32 -0700 2008
commit  7ef088cbd9b4335bd33ffae26d3f380295b8ec42
tree    0fa233c291e64407ab14d7d343764fe4317325c6
parent  b924b85bb01e964402e857a24dfc496203803418
0
...
224
225
226
 
 
 
 
 
227
228
229
...
224
225
226
227
228
229
230
231
232
233
234
0
@@ -224,6 +224,11 @@
0
 ;; pcomplete for: kill/killall, git, apt-get
0
 ;; unify statuses in twitter and jabber
0
 
0
+;; start using ditz
0
+;; - move issue db to ~/.bugs; allow it to be autoconfigured
0
+
0
+;; Make my face customizations stick around with other color themes.
0
+
0
 ;;; Minor
0
 
0
 ;; find a better dark-on-light color scheme
...
1
2
 
 
 
3
...
 
1
2
3
4
5
0
@@ -1 +1,3 @@
0
-;; This is just here so my home dir gets treated like a project.
0
\ No newline at end of file
0
+;; This is just here so my home dir gets treated like a project.
0
+;;
0
+;; maybe put some stuff in here about making find-file-in-project look only for elisp?
0
\ No newline at end of file
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
6
7
8
9
10
 
11
12
13
14
15
16
17
 
 
 
18
19
20
21
22
23
24
25
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
 
 
 
 
28
29
30
...
34
35
36
37
 
 
38
39
40
41
42
43
44
...
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
 
71
72
73
74
75
76
 
 
77
78
79
80
 
 
 
 
 
 
 
 
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
118
119
120
 
121
122
123
124
 
 
125
126
127
0
@@ -1,30 +1,114 @@
0
-;;; extracted from rinari
0
-;; by Phil Hagelberg and Doug Alcorn
0
-;; refactored to work with project-local-variables.el
0
+;;; find-file-in-project.el --- Find files in a project quickly.
0
+
0
+;; Copyright (C) 2006, 2007, 2008 Phil Hagelberg and Doug Alcorn
0
+
0
+;; Author: Phil Hagelberg and Doug Alcorn
0
+;; URL: http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject
0
+;; Version: 2.0
0
+;; Created: 2008-03-18
0
+;; Keywords: project, convenience
0
+;; EmacsWiki: FindFileInProject
0
+
0
+;; This file is NOT part of GNU Emacs.
0
+
0
+;;; License:
0
+
0
+;; This program is free software; you can redistribute it and/or modify
0
+;; it under the terms of the GNU General Public License as published by
0
+;; the Free Software Foundation; either version 3, or (at your option)
0
+;; any later version.
0
+;;
0
+;; This program is distributed in the hope that it will be useful,
0
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0
+;; GNU General Public License for more details.
0
+;;
0
+;; You should have received a copy of the GNU General Public License
0
+;; along with GNU Emacs; see the file COPYING. If not, write to the
0
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0
+;; Boston, MA 02110-1301, USA.
0
+
0
+;;; Commentary:
0
+
0
+;; This file provides a method for quickly finding any file in a given
0
+;; project. Projects are defined as per the `project-local-variables'
0
+;; library, by the presence of a `.emacs-project' file in a directory.
0
+
0
+;; By default, it looks only for files whose names match
0
+;; `ffip-regexp', but it's understood that that variable will be
0
+;; overridden locally. This can be done either with a mode hook:
0
+
0
+;; (add-hook 'emacs-lisp-mode-hook (lambda (setl ffip-regexp ".*\\.el")))
0
+
0
+;; or by setting it in your .emacs-project file, in which case it will
0
+;; get set locally by the project-local-variables library.
0
+
0
+;; You can also be a bit more specific about what files you want to
0
+;; find. For instance, in a Ruby on Rails project, you may be
0
+;; interested in all .rb files that don't exist in the "vendor"
0
+;; directory. In that case you could locally set `ffip-find-options'
0
+;; to "" from within a hook or your .emacs-project file. The options
0
+;; accepted in that variable are passed directly to the Unix `find'
0
+;; command, so any valid arguments for that program are acceptable.
0
+
0
+;; If `ido-mode' is enabled, the menu will use `ido-completing-read'
0
+;; instead of `completing-read'.
0
+
0
+;; Recommended binding:
0
+;; (global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
0
+
0
+;;; TODO:
0
+
0
+;; Performance testing with large projects
0
+;; Switch to using a hash table if it's too slow
0
+
0
+;;; Code:
0
 
0
 (require 'project-local-variables)
0
 
0
 (defvar ffip-regexp
0
   (concat ".*\\.\\(" (mapconcat (lambda (x) x) '("rb" "rhtml" "el") "\\|") "\\)")
0
- "Regexp of things to look for when using find-file-in-project.
0
-For Rails projects, a good value is \".*\\.\\(rb\\|rhtml\\)\"")
0
+ "Regexp of things to look for when using find-file-in-project.")
0
 
0
 (defvar ffip-find-options
0
   ""
0
   "Extra options to pass to `find' when using find-file-in-project.")
0
 
0
-;; TODO: deal with files with the same name but different paths like
0
-;; the version in rinari does (without being slow)
0
+(defvar ffip-project-root nil
0
+ "If non-nil, overrides the project root directory location.")
0
+
0
 (defun ffip-project-files ()
0
- "Return an assoc-list of all filenames and their path."
0
- (mapcar (lambda (file) (cons
0
- (file-name-nondirectory file)
0
- file))
0
- (split-string (shell-command-to-string (concat "find . -type f -regex \""
0
- ffip-regexp
0
- "\" " ffip-find-options)))))
0
-
0
+ "Return an alist of all filenames in the project and their path.
0
+
0
+Files with duplicate filenames are suffixed with the name of the
0
+directory they are found in so that they are unique."
0
+ (let ((file-alist nil))
0
+ (mapcar (lambda (file)
0
+ (let ((file-cons (cons (file-name-nondirectory file)
0
+ (expand-file-name file))))
0
+ (when (assoc (car file-cons) file-alist)
0
+ (ffip-uniqueify (assoc (car file-cons) file-alist))
0
+ (ffip-uniqueify file-cons))
0
+ (add-to-list 'file-alist file-cons)
0
+ file-cons))
0
+ (split-string (shell-command-to-string (concat "find " (or ffip-project-root
0
+ (ffip-project-root))
0
+ " -type f -regex \""
0
+ ffip-regexp
0
+ "\" " ffip-find-options))))))
0
+
0
+(defun ffip-uniqueify (file-cons)
0
+ "Set the car of the argument to include the directory name plus the file name."
0
+ (setcar file-cons
0
+ (concat (car file-cons) ": "
0
+ (cadr (reverse (split-string (cdr file-cons) "/"))))))
0
+
0
 (defun find-file-in-project ()
0
+ "Prompt with a completing list of all files in the project to find one.
0
+
0
+The project's scope is defined as the first directory containing
0
+an `.emacs-project' file. You can override this by locally
0
+setting the `ffip-project-root' variable."
0
   (interactive)
0
   (let* ((project-files (ffip-project-files))
0
    (file (if (functionp 'ido-completing-read)
0
@@ -34,10 +118,9 @@ For Rails projects, a good value is \".*\\.\\(rb\\|rhtml\\)\"")
0
          (mapcar 'car project-files)))))
0
     (find-file (cdr (assoc file project-files)))))
0
 
0
-(defun project-root (&optional dir)
0
+(defun ffip-project-root (&optional dir)
0
+ "Find the root of the project defined by presence of `.emacs-project'."
0
   (file-name-nondirectory (plv-find-project-file default-directory "")))
0
 
0
-(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
0
-
0
 (provide 'find-file-in-project)
0
 ;;; find-file-in-project.el ends here
0
\ No newline at end of file
...
29
30
31
 
32
33
34
...
29
30
31
32
33
34
35
0
@@ -29,6 +29,7 @@
0
 (global-set-key (kbd "C-x C-b") 'bs-show)
0
 (global-set-key (kbd "C-c C-r") 'revert-buffer)
0
 (global-set-key "\C-c\C-t" 'toggle-buffer)
0
+(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
0
 
0
 ;;; Window management
0
 
...
39
40
41
42
43
44
45
46
47
48
...
39
40
41
 
 
 
 
42
43
44
0
@@ -39,10 +39,6 @@
0
 
0
 ;; It has not been tested in versions of Emacs prior to 22.
0
 
0
-;;; Todo:
0
-
0
-;; test more
0
-
0
 (defvar plv-project-file ".emacs-project"
0
   "Name prefix for project files.
0
  Emacs appends name of major mode and looks for such a file in
...
40
41
42
 
43
44
45
...
40
41
42
43
44
45
46
0
@@ -40,6 +40,7 @@
0
           (any "ocruby" junk)
0
           (any "emacs-devel" "emacs-devel")
0
           (any "bus-scheme" "bus-scheme")
0
+ (any "ruby-core" "ruby-core")
0
 
0
           (any "cron" junk)
0
           (to "phil@localhost" "feeds")
...
24
25
26
 
27
28
29
30
...
24
25
26
27
28
29
30
31
0
@@ -24,6 +24,7 @@
0
 - ZenTest
0
 - json
0
 - rcodetools
0
+- roastbeef
0
 - heckle
0
 - railroad
0
 - twitter
0
\ No newline at end of file
...
5
6
7
8
9
10
11
12
13
14
15
16
 
 
 
 
 
 
 
 
 
 
17
18
19
...
28
29
30
31
 
32
...
5
6
7
 
 
 
 
 
 
 
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
...
29
30
31
 
32
33
0
@@ -5,15 +5,16 @@ if [ `/usr/bin/whoami` != "root" ] ; then
0
     exit 1
0
 fi
0
 
0
-# enable universe
0
-cp /etc/apt/sources.list /etc/apt/sources.list.orig
0
-# Enable all disabled sources
0
-sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
0
-# TODO: this doesn't enable multiverse. figure how to do this from the CLI
0
-# We don't want backports though
0
-sed -i -e "s/^.*backports.*$//g" /etc/apt/sources.list
0
-sed -i -e "s/^.*cdrom.*$//g" /etc/apt/sources.list
0
-apt-get update
0
+if [ ! -r /etc/apt/sources.list.orig ] ; then
0
+ # enable universe
0
+ cp /etc/apt/sources.list /etc/apt/sources.list.orig
0
+ # Enable all disabled sources
0
+ sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
0
+ # We don't want backports though
0
+ sed -i -e "s/^.*backports.*$//g" /etc/apt/sources.list
0
+ sed -i -e "s/^.*cdrom.*$//g" /etc/apt/sources.list
0
+ apt-get update
0
+fi
0
 
0
 # get the minimum
0
 apt-get install git-core ruby ruby1.8 zile
0
@@ -28,5 +29,5 @@ fi
0
 
0
 ruby install.rb
0
 chown -R $USER $HOME
0
-su $USER ruby user-setup.rb # TODO: this breaks... huh?
0
+sudo -u $USER ruby user-setup.rb # TODO: this breaks... huh?
0
 exit 0
...
1
2
 
 
 
 
 
 
3
4
5
6
7
 
8
9
...
 
 
1
2
3
4
5
6
7
 
 
 
 
8
9
10
0
@@ -1,9 +1,10 @@
0
-system "mv ~/dotfiles/* ~"
0
-system "mv ~/dotfiles/.* ~"
0
+["mv ~/dotfiles/* ~",
0
+ "mv ~/dotfiles/.* ~",
0
+ "mkdir ~/.ssh",
0
+ "cp ~/.sshconfig ~/.ssh/config",
0
+ "ln -s /usr/lib/ruby/gems/1.8/gems ~/gems",
0
+ "ruby ~/bin/gconf.rb"].map{ |c| system c rescue nil }
0
 
0
-system "cp ~/.sshconfig ~/.ssh/config"
0
-system "ln -s /usr/lib/ruby/gems/1.8/gems ~/gems"
0
-
0
-system "ruby ~/bin/gconf.rb"
0
+# TODO: set up proper gconf panel and keyboard options
0
 
0
 %w(Music Examples Desktop Pictures Public Templates Videos Documents).each { |d| system "rm -rf ~/#{d}" }

Comments

    No one has commented yet.