comparison .elisp/textmate.el @ 49:60dbe5b005cc

Fix a bug in shell quoting.
author Augie Fackler <durin42@gmail.com>
date Wed, 11 Feb 2009 10:27:43 -0600
parents 43e751bdedeb
children 26450200777a
comparison
equal deleted inserted replaced
48:bc63fd9e6d64 49:60dbe5b005cc
93 ,(kbd "A-/") [(control c)(control k)]) 93 ,(kbd "A-/") [(control c)(control k)])
94 (textmate-goto-file 94 (textmate-goto-file
95 ,(kbd "A-t") [(meta t)]) 95 ,(kbd "A-t") [(meta t)])
96 (textmate-goto-symbol 96 (textmate-goto-symbol
97 ,(kbd "A-T") [(meta T)]) 97 ,(kbd "A-T") [(meta T)])
98 (textmate-toggle-camel-case 98 (textmate-toggle-camel-case
99 ,(kbd "C-_") [(control _)]))) 99 ,(kbd "C-_") [(control _)])))
100 100
101 (defvar *textmate-project-root-p* 101 (defvar *textmate-project-root-p*
102 #'(lambda (coll) (or (member ".git" coll) 102 #'(lambda (coll) (or (member ".git" coll)
103 (member ".hg" coll) 103 (member ".hg" coll)
104 )) 104 ))
219 " ; " 219 " ; "
220 (cond ((string= type "git") "git ls-files") 220 (cond ((string= type "git") "git ls-files")
221 ((string= type "hg") "hg manifest")) 221 ((string= type "hg") "hg manifest"))
222 " | xargs grep -nR " 222 " | xargs grep -nR "
223 (if pattern (concat " --include='" pattern "' ") "") 223 (if pattern (concat " --include='" pattern "' ") "")
224 "'" re "'")) 224 (shell-quote-argument re)))
225 (t (concat "cd " root "; egrep -nR --exclude='" 225 (t (concat "cd " root "; egrep -nR --exclude='"
226 *textmate-gf-exclude* 226 *textmate-gf-exclude*
227 "' --include='" 227 "' --include='"
228 incpat 228 incpat
229 "' '" 229 "' "
230 re 230 (shell-quote-argument re)
231 "' . | grep -vE '" 231 " . | grep -vE '"
232 *textmate-gf-exclude* 232 *textmate-gf-exclude*
233 "' | sed s:./::" 233 "' | sed s:./::"
234 ))))) 234 )))))
235 (compilation-start command 'grep-mode))) 235 (compilation-start command 'grep-mode)))
236 ))) 236 )))
244 (defun textmate-toggle-camel-case () 244 (defun textmate-toggle-camel-case ()
245 "Toggle current sexp between camelCase and snake_case, like TextMate C-_." 245 "Toggle current sexp between camelCase and snake_case, like TextMate C-_."
246 (interactive) 246 (interactive)
247 (if (thing-at-point 'word) 247 (if (thing-at-point 'word)
248 (progn 248 (progn
249 (unless (looking-at "\\<") (backward-sexp)) 249 (unless (looking-at "\\<") (backward-sexp))
250 (let ((case-fold-search nil) 250 (let ((case-fold-search nil)
251 (start (point)) 251 (start (point))
252 (end (save-excursion (forward-sexp) (point)))) 252 (end (save-excursion (forward-sexp) (point))))
253 (if (and (looking-at "[a-z0-9_]+") (= end (match-end 0))) ; snake-case 253 (if (and (looking-at "[a-z0-9_]+") (= end (match-end 0))) ; snake-case
254 (progn 254 (progn
255 (goto-char start) 255 (goto-char start)
256 (while (re-search-forward "_[a-z]" end t) 256 (while (re-search-forward "_[a-z]" end t)
257 (goto-char (1- (point))) 257 (goto-char (1- (point)))
258 (delete-char -1) 258 (delete-char -1)
259 (upcase-region (point) (1+ (point))) 259 (upcase-region (point) (1+ (point)))
260 (setq end (1- end)))) 260 (setq end (1- end))))
261 (downcase-region (point) (1+ (point))) 261 (downcase-region (point) (1+ (point)))
262 (while (re-search-forward "[A-Z][a-z]" end t) 262 (while (re-search-forward "[A-Z][a-z]" end t)
263 (forward-char -2) 263 (forward-char -2)
264 (insert "_") 264 (insert "_")
265 (downcase-region (point) (1+ (point))) 265 (downcase-region (point) (1+ (point)))
266 (forward-char 1) 266 (forward-char 1)
267 (setq end (1+ end))) 267 (setq end (1+ end)))
268 (downcase-region start end) 268 (downcase-region start end)
269 ))))) 269 )))))
270 270
271 ;;; Utilities 271 ;;; Utilities
272 272
273 (defun textmate-also-ignore (pattern) 273 (defun textmate-also-ignore (pattern)
274 "Also ignore PATTERN in project files." 274 "Also ignore PATTERN in project files."