annotate .elisp/textmate.el @ 474:e71b87fa8ea1

hg: enable absorb
author Augie Fackler <raf@durin42.com>
date Fri, 28 Dec 2018 11:54:30 -0500
parents f86c1048a46d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 ;; textmate.el --- TextMate minor mode for Emacs
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
3 ;; Copyright (C) 2008, 2009 Chris Wanstrath <chris@ozmm.org> and others
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 ;; Licensed under the same terms as Emacs.
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 ;; Keywords: textmate osx mac
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 ;; Created: 22 Nov 2008
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
9 ;; Author: Chris Wanstrath <chris@ozmm.org> and others
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 ;; This file is NOT part of GNU Emacs.
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 ;;; Commentary:
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 ;; This minor mode exists to mimick TextMate's awesome
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 ;; features.
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 ;; ⌘T - Go to File
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 ;; ⇧⌘T - Go to Symbol
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 ;; ⌘L - Go to Line
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 ;; ⌘/ - Comment Line (or Selection/Region)
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
22 ;; ⌘] - Shift Right
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
23 ;; ⌘[ - Shift Left
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 ;; ⌥⌘] - Align Assignments
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 ;; ⌥⌘[ - Indent Line
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 ;; ⌘RET - Insert Newline at Line's End
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
27 ;; ⌥⌘T - Reset File Cache (for Go to File, cache unused if using git/hg root,
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
28 ;; but resets cached root location, useful if roots
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
29 ;; are nested)
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 ;; A "project" in textmate-mode is determined by the presence of
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
32 ;; a .git directory, an .hg directory, a Rakefile, or a Makefile.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
33
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
34 ;; You can configure what makes a project root by appending a file
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
35 ;; or directory name onto the `*textmate-project-roots*' list.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
36
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
37 ;; If no project root indicator is found in your current directory,
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
38 ;; textmate-mode will traverse upwards until one (or none) is found.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
39 ;; The directory housing the project root indicator (e.g. a .git or .hg
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
40 ;; directory) is presumed to be the project's root.
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 ;; In other words, calling Go to File from
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 ;; ~/Projects/fieldrunners/app/views/towers/show.html.erb will use
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 ;; ~/Projects/fieldrunners/ as the root if ~/Projects/fieldrunners/.git
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 ;; exists.
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
47 ;; In the event that the project root was defined by either .git or .hg,
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
48 ;; fast file-listing with no caching is provided by the version control
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
49 ;; system.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
50
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
51 ;; Not bound to keys, but available are textmate-find-in-project and
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
52 ;; textmate-find-in-project-type, which use grep, the file listing,
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
53 ;; and grep-mode to provide excellent (and blindingly fast with git and
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
54 ;; hg!) grep integration with emacs and your project.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
55
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
56 ;; Also available (and unbound) is textmate-compile, which is like
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
57 ;; compile but prepends a cd to the project root to the command. It is
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
58 ;; used to build the find-in-project commands, but has other possible
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
59 ;; uses as well (eg, a test runner or some kind of compile command).
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
60
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 ;;; Installation
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 ;; $ cd ~/.emacs.d/vendor
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 ;; $ git clone git://github.com/defunkt/textmate.el.git
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 ;;
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 ;; In your emacs config:
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 ;;
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 ;; (add-to-list 'load-path "~/.emacs.d/vendor/textmate.el")
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 ;; (require 'textmate)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 ;; (textmate-mode)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 ;;; Depends on imenu
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 (require 'imenu)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
75 ;;; Needed for flet
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
76 (eval-when-compile
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
77 (require 'cl))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
78
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 ;;; Minor mode
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
81 (defvar *textmate-gf-exclude*
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
82 "/\\.|vendor|fixtures|tmp|log|build|\\.xcodeproj|\\.nib|\\.framework|\\.app|\\.pbproj|\\.pbxproj|\\.xcode|\\.xcodeproj|\\.bundle|\\.pyc"
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
83 "Regexp of files to exclude from `textmate-goto-file'.")
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
84
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
85 (defvar *textmate-project-roots*
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
86 '(".git" ".hg" "Rakefile" "Makefile" "README" "build.xml")
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
87 "The presence of any file/directory in this list indicates a project root.")
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
88
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 (defvar textmate-use-file-cache t
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
90 "Should `textmate-goto-file' keep a local cache of files?")
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 (defvar textmate-completing-library 'ido
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
93 "The library `textmade-goto-symbol' and `textmate-goto-file' should use for
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
94 completing filenames and symbols (`ido' by default)")
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 (defvar *textmate-completing-function-alist* '((ido ido-completing-read)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 (icicles icicle-completing-read)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 (none completing-read))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 "The function to call to read file names and symbols from the user")
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 (defvar *textmate-completing-minor-mode-alist*
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 `((ido ,(lambda (a) (progn (ido-mode a) (setq ido-enable-flex-matching t))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 (icicles ,(lambda (a) (icy-mode a)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 (none ,(lambda (a) ())))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 "The list of functions to enable and disable completing minor modes")
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
107 (defvar *textmate-mode-map*
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
108 (let ((map (make-sparse-keymap)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
109 (cond ((featurep 'aquamacs)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
110 (define-key map [A-return] 'textmate-next-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
111 (define-key map (kbd "A-M-t") 'textmate-clear-cache)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
112 (define-key map (kbd "A-M-]") 'align)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
113 (define-key map (kbd "A-M-[") 'indent-according-to-mode)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
114 (define-key map (kbd "A-]") 'textmate-shift-right)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
115 (define-key map (kbd "A-[") 'textmate-shift-left)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
116 (define-key map (kbd "A-/") 'comment-or-uncomment-region-or-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
117 (define-key map (kbd "A-t") 'textmate-goto-file)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
118 (define-key map (kbd "A-T") 'textmate-goto-symbol))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
119 ((and (featurep 'mac-carbon) (eq window-system 'mac) mac-key-mode)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
120 (define-key map [(alt meta return)] 'textmate-next-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
121 (define-key map [(alt meta t)] 'textmate-clear-cache)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
122 (define-key map [(alt meta \])] 'align)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
123 (define-key map [(alt meta \[)] 'indent-according-to-mode)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
124 (define-key map [(alt \])] 'textmate-shift-right)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
125 (define-key map [(alt \[)] 'textmate-shift-left)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
126 (define-key map [(meta /)] 'comment-or-uncomment-region-or-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
127 (define-key map [(alt t)] 'textmate-goto-file)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
128 (define-key map [(alt shift t)] 'textmate-goto-symbol))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
129 ((featurep 'ns) ;; Emacs.app
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
130 (define-key map [(super meta return)] 'textmate-next-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
131 (define-key map [(super meta t)] 'textmate-clear-cache)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
132 (define-key map [(super meta \])] 'align)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
133 (define-key map [(super meta \[)] 'indent-according-to-mode)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
134 (define-key map [(super \])] 'textmate-shift-right)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
135 (define-key map [(super \[)] 'textmate-shift-left)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
136 (define-key map [(super /)] 'comment-or-uncomment-region-or-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
137 (define-key map [(super t)] 'textmate-goto-file)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
138 (define-key map [(super shift t)] 'textmate-goto-symbol))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
139 (t ;; Any other version
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
140 (define-key map [(meta return)] 'textmate-next-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
141 (define-key map [(control c)(control t)] 'textmate-clear-cache)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
142 (define-key map [(control c)(control a)] 'align)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
143 (define-key map [(control tab)] 'textmate-shift-right)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
144 (define-key map [(control shift tab)] 'textmate-shift-left)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
145 (define-key map [(control c)(control k)] 'comment-or-uncomment-region-or-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
146 (define-key map [(meta t)] 'textmate-goto-file)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
147 (define-key map [(meta shift t)] 'textmate-goto-symbol)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
148 map))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
149
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
150 (defvar *textmate-project-root* nil
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
151 "Used internally to cache the project root.")
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
152 (defvar *textmate-project-files* '()
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
153 "Used internally to cache the files in a project.")
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
154
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
155 (defvar *textmate-vcs-exclude* nil
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
156 "string to give to grep -V to exclude some VCS paths from being grepped."
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
157 )
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158
473
f86c1048a46d emacs: hack up my textmate.el some more to add searching config
Augie Fackler <raf@durin42.com>
parents: 438
diff changeset
159 (defvar *textmate-grep-command* "egrep --color=never -n" "Base grep command.")
f86c1048a46d emacs: hack up my textmate.el some more to add searching config
Augie Fackler <raf@durin42.com>
parents: 438
diff changeset
160
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
161 (defvar *textmate-find-in-project-default* nil)
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
162
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
163 (defvar *textmate-find-in-project-type-default* nil)
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
164
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
165 (defvar *textmate-compile-default* nil)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
166
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 ;;; Bindings
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 (defun textmate-ido-fix ()
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 "Add up/down keybindings for ido."
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 (define-key ido-completion-map [up] 'ido-prev-match)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 (define-key ido-completion-map [down] 'ido-next-match))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 (defun textmate-completing-read (&rest args)
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
175 "Uses `*textmate-completing-function-alist*' to call the appropriate completing
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
176 function."
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
177 (let ((reading-fn
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
178 (cadr (assoc textmate-completing-library
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
179 *textmate-completing-function-alist*))))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180 (apply (symbol-function reading-fn) args)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
182 ;;; allow-line-as-region-for-function adds an "-or-line" version of
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
183 ;;; the given comment function which (un)comments the current line is
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
184 ;;; the mark is not active. This code comes from Aquamac's osxkeys.el
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
185 ;;; and is licensed under the GPL
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
186
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
187 (defmacro allow-line-as-region-for-function (orig-function)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
188 `(defun ,(intern (concat (symbol-name orig-function) "-or-line"))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
189 ()
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
190 ,(format "Like `%s', but acts on the current line if mark is not active." orig-function)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
191 (interactive)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
192 (if mark-active
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
193 (call-interactively (function ,orig-function))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
194 (save-excursion
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
195 ;; define a region (temporarily) -- so any C-u prefixes etc. are preserved.
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
196 (beginning-of-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
197 (set-mark (point))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
198 (end-of-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
199 (call-interactively (function ,orig-function))))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
200
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
201 (defun textmate-define-comment-line ()
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
202 "Add or-line (un)comment function if not already defined"
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
203 (unless (fboundp 'comment-or-uncomment-region-or-line)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
204 (allow-line-as-region-for-function comment-or-uncomment-region)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
205
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
206 ;;; Commands
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
208 (defun textmate-next-line ()
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
209 "Inserts an indented newline after the current line and moves the point to it."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210 (interactive)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 (end-of-line)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 (newline-and-indent))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 ;; http://chopmo.blogspot.com/2008/09/quickly-jumping-to-symbols.html
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 (defun textmate-goto-symbol ()
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
216 "Update the imenu index and then use ido to select a symbol to navigate to.
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
217 Symbols matching the text at point are put first in the completion list."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
218 (interactive)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 (imenu--make-index-alist)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 (let ((name-and-pos '())
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
221 (symbol-names '()))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 (flet ((addsymbols (symbol-list)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223 (when (listp symbol-list)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 (dolist (symbol symbol-list)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
225 (let ((name nil) (position nil))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226 (cond
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
227 ((and (listp symbol) (imenu--subalist-p symbol))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228 (addsymbols symbol))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
230 ((listp symbol)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231 (setq name (car symbol))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
232 (setq position (cdr symbol)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
234 ((stringp symbol)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235 (setq name symbol)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 (setq position (get-text-property 1 'org-imenu-marker symbol))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
237
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
238 (unless (or (null position) (null name))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
239 (add-to-list 'symbol-names name)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 (add-to-list 'name-and-pos (cons name position))))))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 (addsymbols imenu--index-alist))
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
242 ;; If there are matching symbols at point, put them at the beginning of `symbol-names'.
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
243 (let ((symbol-at-point (thing-at-point 'symbol)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
244 (when symbol-at-point
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
245 (let* ((regexp (concat (regexp-quote symbol-at-point) "$"))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
246 (matching-symbols (delq nil (mapcar (lambda (symbol)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
247 (if (string-match regexp symbol) symbol))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
248 symbol-names))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
249 (when matching-symbols
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
250 (sort matching-symbols (lambda (a b) (> (length a) (length b))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
251 (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
252 matching-symbols)))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
253 (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
254 (position (cdr (assoc selected-symbol name-and-pos))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
255 (goto-char position))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
257 (defun textmate-goto-file ()
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
258 "Uses your completing read to quickly jump to a file in a project."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259 (interactive)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 (let ((root (textmate-project-root)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 (when (null root)
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
262 (error
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
263 (concat
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
264 "Can't find a suitable project root ("
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
265 (string-join " " *textmate-project-roots* )
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
266 ")")))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
267 (find-file
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
268 (concat
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
269 (expand-file-name root) "/"
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
270 (textmate-completing-read
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
271 "Find file: "
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
272 (textmate-project-files root))))))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
273
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
274 (defun textmate-find-in-project-type ()
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
275 "Run grep over project files of a specific type and put the results
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
276 in a grep-mode buffer."
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
277 (interactive)
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
278 (let ((pat (read-string (concat "Suffix"
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
279 (if *textmate-find-in-project-type-default*
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
280 (format " [\"%s\"]" *textmate-find-in-project-type-default*)
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
281 "")
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
282 ": "
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
283 ) nil nil *textmate-find-in-project-type-default*)))
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
284 (setq *textmate-find-in-project-type-default* pat)
473
f86c1048a46d emacs: hack up my textmate.el some more to add searching config
Augie Fackler <raf@durin42.com>
parents: 438
diff changeset
285 (textmate-find-in-project (concat ".*\\." pat "$"))))
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
286
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
287 (defun textmate-start-compile-in-root (command &optional mode
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
288 name-function
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
289 highlight-regexp)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
290 "Idential to compilation-start, except it automatically changes to the
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
291 project root directory before starting the command."
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
292 (let ((root (textmate-project-root)))
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
293 (when (null root)
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
294 (error "Not in a project area."))
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
295 (let ((default-directory root))
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
296 (compilation-start command mode name-function highlight-regexp))))
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
297
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
298 (defun textmate-compile ()
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
299 "Run a command in compilation-mode rooted at the project root."
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
300 (interactive)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
301 (let* ((default *textmate-compile-default*)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
302 (command (read-string
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
303 (concat "Command"
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
304 (if default (format " [\"%s\"]" default) "")
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
305 ": ") nil 'textmate-compile-history default)))
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
306 (setq *textmate-compile-default* command)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
307 (textmate-start-compile-in-root command)))
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
308
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
309 (defun textmate-find-in-project (&optional pattern)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
310 "Run grep over project files with results in grep-mode.
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
311
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
312 Takes an optional argument (see also textmate-find-in-project-type)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
313 of a file extension to limit the search. Useful for finding results in only a
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
314 specific type of file."
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
315 (interactive)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
316 (let* ((default *textmate-find-in-project-default*)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
317 (re (read-string (concat "Search for "
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
318 (if (and default (> (length default) 0))
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
319 (format "[\"%s\"]" default)) ": ")
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
320 nil 'textmate-find-in-project-history default))
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
321 (type (textmate-project-root-type (textmate-project-root)))
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
322 (command
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
323 (cond ((not (string= type "unknown"))
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
324 (concat (cond ((string= type "git") "git ls-files")
331
ecb85d3ba960 textmate.el: use hg locate for speed
Augie Fackler <raf@durin42.com>
parents: 330
diff changeset
325 ((string= type "hg") "hg locate 'set:added() or modified() or clean()'"))
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
326 (if *textmate-vcs-exclude*
330
629b500e1276 textmate.el: disable color on use of egrep
Augie Fackler <durin42@gmail.com>
parents: 329
diff changeset
327 (concat " | egrep --color=never -v "
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
328 (shell-quote-argument *textmate-vcs-exclude*))
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
329 "")
473
f86c1048a46d emacs: hack up my textmate.el some more to add searching config
Augie Fackler <raf@durin42.com>
parents: 438
diff changeset
330 (if pattern (concat " | egrep '" pattern "' "))
f86c1048a46d emacs: hack up my textmate.el some more to add searching config
Augie Fackler <raf@durin42.com>
parents: 438
diff changeset
331 " | xargs " *textmate-grep-command* " "
99
26450200777a Latest textmate.el
Augie Fackler <durin42@gmail.com>
parents: 49
diff changeset
332 " -- "
49
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
333 (shell-quote-argument re)))
330
629b500e1276 textmate.el: disable color on use of egrep
Augie Fackler <durin42@gmail.com>
parents: 329
diff changeset
334 (t (concat "egrep --color=never -nR --exclude='"
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
335 *textmate-gf-exclude*
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
336 "' --include='"
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
337 incpat
99
26450200777a Latest textmate.el
Augie Fackler <durin42@gmail.com>
parents: 49
diff changeset
338 "' -- "
49
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
339 (shell-quote-argument re)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
340 " . | grep -vE '"
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
341 *textmate-gf-exclude*
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
342 "' | sed s:./::"
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
343 )))))
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
344 (setq *textmate-find-in-project-default* re)
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
345 (textmate-start-compile-in-root command 'grep-mode)))
28
260deb14fbc8 Add textmate-find-in-project.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
346
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
347 (defun textmate-clear-cache ()
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
348 "Clears the project root and project files cache. Use after adding files."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 (interactive)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
350 (setq *textmate-project-root* nil)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 (setq *textmate-project-files* nil)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
352 (message "textmate-mode cache cleared."))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
353
24
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
354 (defun textmate-toggle-camel-case ()
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
355 "Toggle current sexp between camelCase and snake_case, like TextMate C-_."
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
356 (interactive)
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
357 (if (thing-at-point 'word)
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
358 (progn
49
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
359 (unless (looking-at "\\<") (backward-sexp))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
360 (let ((case-fold-search nil)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
361 (start (point))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
362 (end (save-excursion (forward-sexp) (point))))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
363 (if (and (looking-at "[a-z0-9_]+") (= end (match-end 0))) ; snake-case
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
364 (progn
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
365 (goto-char start)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
366 (while (re-search-forward "_[a-z]" end t)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
367 (goto-char (1- (point)))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
368 (delete-char -1)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
369 (upcase-region (point) (1+ (point)))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
370 (setq end (1- end))))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
371 (downcase-region (point) (1+ (point)))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
372 (while (re-search-forward "[A-Z][a-z]" end t)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
373 (forward-char -2)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
374 (insert "_")
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
375 (downcase-region (point) (1+ (point)))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
376 (forward-char 1)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
377 (setq end (1+ end)))
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
378 (downcase-region start end)
60dbe5b005cc Fix a bug in shell quoting.
Augie Fackler <durin42@gmail.com>
parents: 30
diff changeset
379 )))))
24
d6fd2964258c New version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 22
diff changeset
380
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
381 ;;; Utilities
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
382
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
383 (defun textmate-project-root-type (root)
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
384 (cond ((member ".git" (directory-files root)) "git")
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
385 ((member ".hg" (directory-files root)) "hg")
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
386 (t "unknown")
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
387 ))
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
388
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
389 (defun textmate-project-files (root)
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
390 "Finds all files in a given project using either hg, git, or find."
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
391 (let ((type (textmate-project-root-type root))
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
392 (default-directory root))
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
393 (cond ((string= type "git") (split-string
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
394 (shell-command-to-string
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
395 "git ls-files") "\n" t))
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
396 ((string= type "hg")
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
397 (split-string
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
398 (shell-command-to-string
438
13c11127a79e textmate.el: make sure hg is run with HGPLAIN
Augie Fackler <raf@durin42.com>
parents: 437
diff changeset
399 "HGPLAIN=1 hg locate 'set:not(ignored() or removed() or unknown())'")
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
400 "\n" t))
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
401 ((string= type "unknown") (textmate-cached-project-files-find root))
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
402 )))
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
403
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
404 (defun textmate-project-files-find (root)
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
405 "Finds all files in a given project using find."
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
406 (let ((default-directory root))
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
407 (split-string
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
408 (shell-command-to-string
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
409 (concat
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
410 "find . -type f | grep -vE '"
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
411 *textmate-gf-exclude*
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
412 "' | sed 's:"
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
413 *textmate-project-root*
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
414 "/::'")) "\n" t)))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
415
29
e5f414619ea7 Latest version of textmate.el
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
416 (defun textmate-cached-project-files-find (&optional root)
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
417 "Finds and caches all files in a given project using find."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
418 (cond
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
419 ((null textmate-use-file-cache) (textmate-project-files root))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420 ((equal (textmate-project-root) (car *textmate-project-files*))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
421 (cdr *textmate-project-files*))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
422 (t (cdr (setq *textmate-project-files*
134
fe9d358b9fe8 textmate.el: Fix an infinite recursion bug when not using a supported VCS
Augie Fackler <durin42@gmail.com>
parents: 99
diff changeset
423 `(,root . ,(textmate-project-files-find root)))))))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
424
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
425 (defun textmate-project-root ()
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
426 "Returns the current project root."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
427 (when (or
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
428 (null *textmate-project-root*)
171
2f865a7f84e6 textmate: do not trust cached project root of $HOME
Augie Fackler <durin42@gmail.com>
parents: 161
diff changeset
429 (not (string-match *textmate-project-root* default-directory))
2f865a7f84e6 textmate: do not trust cached project root of $HOME
Augie Fackler <durin42@gmail.com>
parents: 161
diff changeset
430 (not (string-match *textmate-project-root* (getenv "HOME"))))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431 (let ((root (textmate-find-project-root)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 (if root
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 (setq *textmate-project-root* (expand-file-name (concat root "/")))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 (setq *textmate-project-root* nil))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
435 *textmate-project-root*)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
436
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
437 (defun root-match(root names)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
438 (member (car names) (directory-files root)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
439
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
440 (defun root-matches(root names)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
441 (if (root-match root names)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
442 (root-match root names)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
443 (if (eq (length (cdr names)) 0)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
444 'nil
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
445 (root-matches root (cdr names))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
446 )))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
447
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
448 (defun textmate-find-project-root (&optional root)
152
a24d5587386f textmate.el: update to latest version
Augie Fackler <durin42@gmail.com>
parents: 141
diff changeset
449 "Determines the current project root by recursively searching for an indicator."
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 (when (null root) (setq root default-directory))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 (cond
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
452 ((root-matches root *textmate-project-roots*)
437
b460b464f9d2 textmate.el: set default-directory instead of adding a 'cd' command
Augie Fackler <raf@durin42.com>
parents: 404
diff changeset
453 (expand-file-name root))
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
454 ((equal (expand-file-name root) "/") nil)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
455 (t (textmate-find-project-root (concat (file-name-as-directory root) "..")))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
456
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
457 (defun textmate-shift-right (&optional arg)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
458 "Shift the line or region to the ARG places to the right.
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
459
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
460 A place is considered `tab-width' character columns."
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
461 (interactive)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
462 (let ((deactivate-mark nil)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
463 (beg (or (and mark-active (region-beginning))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
464 (line-beginning-position)))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
465 (end (or (and mark-active (region-end)) (line-end-position))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
466 (indent-rigidly beg end (* (or arg 1) tab-width))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
467
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
468 (defun textmate-shift-left (&optional arg)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
469 "Shift the line or region to the ARG places to the left."
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
470 (interactive)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
471 (textmate-shift-right (* -1 (or arg 1))))
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
472
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
473 ;;;###autoload
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
474 (define-minor-mode textmate-mode "TextMate Emulation Minor Mode"
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
475 :lighter " mate" :global t :keymap *textmate-mode-map*
141
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
476 (add-hook 'ido-setup-hook 'textmate-ido-fix)
e30655eb7050 textmate.el: synced with upstream
Augie Fackler <durin42@gmail.com>
parents: 134
diff changeset
477 (textmate-define-comment-line)
22
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
478 ; activate preferred completion library
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
479 (dolist (mode *textmate-completing-minor-mode-alist*)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
480 (if (eq (car mode) textmate-completing-library)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
481 (funcall (cadr mode) t)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
482 (when (fboundp
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
483 (cadr (assoc (car mode) *textmate-completing-function-alist*)))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
484 (funcall (cadr mode) -1)))))
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
485
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
486 (provide 'textmate)
8715ccb6f61b Start using textmate.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
487 ;;; textmate.el ends here