Snippet tweaking

This commit is contained in:
capitaomorte 2010-02-01 10:36:42 +00:00
parent 9f8fab6bc6
commit b589d4434a
5 changed files with 37 additions and 6 deletions

1
extras/imported/c++-mode Symbolic link
View File

@ -0,0 +1 @@
c-mode/

View File

@ -3,8 +3,8 @@
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: main() # name: main()
# -- # --
int main (int argc, char const${TM_C_POINTER: *}argv[]) int main (int argc, char const *argv[])
{ {
${0:/* code */} ${1:/* code */$(when yas/modified-p (yas/exit-snippet (first (yas/snippets-at-point))) (yas/field-value 1))}$0
return 0; return 0;
} }

View File

@ -8,6 +8,9 @@
yas/ruby-snippet-close-paren yas/ruby-snippet-close-paren
yas/ruby-snippet-open-paren)) yas/ruby-snippet-open-paren))
(defvar yas/ruby-shebang-args " -wKU"
"Arguments for the ruby shebang line.")
(defun yas/ruby-infer-class-name () (defun yas/ruby-infer-class-name ()
"Infer the class name from the buffer. Thanks to hitesh <hitesh.jasani@gmail.com>" "Infer the class name from the buffer. Thanks to hitesh <hitesh.jasani@gmail.com>"
(let ((fn (capitalize (file-name-nondirectory (let ((fn (capitalize (file-name-nondirectory
@ -17,10 +20,31 @@
((string-match "_" fn) (replace-match "" nil nil fn)) ((string-match "_" fn) (replace-match "" nil nil fn))
(t fn)))) (t fn))))
(defun yas/ruby-toggle-single-multi-line-block ()
(interactive)
(save-excursion
(let* ((block-start (progn (ruby-beginning-of-block) (point)))
(block-end (progn (ruby-end-of-block) (forward-word)(point))))
(when (and block-start
block-end)
(goto-char block-start)
(cond ((not (eq (line-number-at-pos block-end)
(line-number-at-pos block-start)))
(when (looking-at ".*[^\w]\\(do\\)[^\w]\\(|.*|\\)?")
(goto-char block-end)
(insert "}")
(goto-char block-start)
(replace-regexp "do" "{" t block-start (line-end-position))))
(t
(replace-regexp "\\(.*\\){[^w]\\(|.*|\\)" "\1do \2\n" nil block-start block-end)))))))
;; conditions ;; conditions
;; ;;
(yas/define-condition-cache yas/ruby-in-interpolated-string-p (eq (fourth (syntax-ppss)) ?\")) (yas/define-condition-cache yas/ruby-in-interpolated-string-p (member (fourth (syntax-ppss)) (list ?\" ?\`)))
(yas/define-condition-cache yas/ruby-in-comment-p (fifth (syntax-ppss))) (yas/define-condition-cache yas/ruby-in-comment-p (fifth (syntax-ppss)))
(yas/define-condition-cache yas/ruby-in-string-p (fourth (syntax-ppss))) (yas/define-condition-cache yas/ruby-in-string-p (fourth (syntax-ppss)))
(yas/define-condition-cache yas/ruby-end-is-block-end-p
(save-excursion
(ruby-backward-sexp)
(not (eq (point) (point-min)))))

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# key: #
# contributor: Translated from TextMate Snippet
# name: Add # => marker
# --
# =>