comparison .elisp/textmate.el @ 24:d6fd2964258c

New version of textmate.el
author Augie Fackler <durin42@gmail.com>
date Tue, 16 Dec 2008 11:30:55 -0600
parents 8715ccb6f61b
children c7ff220bba9f
comparison
equal deleted inserted replaced
23:e1caf3e773a8 24:d6fd2964258c
92 (comment-or-uncomment-region-or-line 92 (comment-or-uncomment-region-or-line
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
99 ,(kbd "C-_") [(control _))))
98 100
99 (defvar *textmate-project-root-p* 101 (defvar *textmate-project-root-p*
100 #'(lambda (coll) (or (member ".git" coll) 102 #'(lambda (coll) (or (member ".git" coll)
101 (member ".hg" coll) 103 (member ".hg" coll)
102 )) 104 ))
183 (defun textmate-clear-cache () 185 (defun textmate-clear-cache ()
184 (interactive) 186 (interactive)
185 (setq *textmate-project-root* nil) 187 (setq *textmate-project-root* nil)
186 (setq *textmate-project-files* nil) 188 (setq *textmate-project-files* nil)
187 (message "textmate-mode cache cleared.")) 189 (message "textmate-mode cache cleared."))
190
191 (defun textmate-toggle-camel-case ()
192 "Toggle current sexp between camelCase and snake_case, like TextMate C-_."
193 (interactive)
194 (if (thing-at-point 'word)
195 (progn
196 (unless (looking-at "\\<") (backward-sexp))
197 (let ((case-fold-search nil)
198 (start (point))
199 (end (save-excursion (forward-sexp) (point))))
200 (if (and (looking-at "[a-z0-9_]+") (= end (match-end 0))) ; snake-case
201 (progn
202 (goto-char start)
203 (while (re-search-forward "_[a-z]" end t)
204 (goto-char (1- (point)))
205 (delete-char -1)
206 (upcase-region (point) (1+ (point)))
207 (setq end (1- end))))
208 (downcase-region (point) (1+ (point)))
209 (while (re-search-forward "[A-Z][a-z]" end t)
210 (forward-char -2)
211 (insert "_")
212 (downcase-region (point) (1+ (point)))
213 (forward-char 1)
214 (setq end (1+ end)))
215 (downcase-region start end)
216 )))))
188 217
189 ;;; Utilities 218 ;;; Utilities
190 219
191 (defun textmate-also-ignore (pattern) 220 (defun textmate-also-ignore (pattern)
192 "Also ignore PATTERN in project files." 221 "Also ignore PATTERN in project files."