diff --git a/extras/imported/c++-mode b/extras/imported/c++-mode new file mode 120000 index 0000000..fe00db6 --- /dev/null +++ b/extras/imported/c++-mode @@ -0,0 +1 @@ +c-mode/ \ No newline at end of file diff --git a/extras/imported/c-mode/Idioms/010 main() (main).yasnippet b/extras/imported/c-mode/Idioms/010 main() (main).yasnippet index e129b4d..8908f59 100644 --- a/extras/imported/c-mode/Idioms/010 main() (main).yasnippet +++ b/extras/imported/c-mode/Idioms/010 main() (main).yasnippet @@ -3,8 +3,8 @@ # contributor: Translated from TextMate Snippet # 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; } \ No newline at end of file diff --git a/extras/imported/c-mode/printf .. (printf).yasnippet b/extras/imported/c-mode/printf .. (printf).yasnippet index 556590b..1d6f0ba 100644 --- a/extras/imported/c-mode/printf .. (printf).yasnippet +++ b/extras/imported/c-mode/printf .. (printf).yasnippet @@ -3,4 +3,4 @@ # name: printf (...) # -- printf ("${1:%s}\\n"${1:$(if (string-match "%[^%]" text) "," "\);") -}$2${1:$(if (string-match "%" text) "\);" "")} +}$2${1:$(if (string-match "%" text) "\);" "")} \ No newline at end of file diff --git a/extras/imported/ruby-mode/.yas-setup.el b/extras/imported/ruby-mode/.yas-setup.el index 2ae1fb2..e7f34c1 100644 --- a/extras/imported/ruby-mode/.yas-setup.el +++ b/extras/imported/ruby-mode/.yas-setup.el @@ -8,6 +8,9 @@ yas/ruby-snippet-close-paren yas/ruby-snippet-open-paren)) +(defvar yas/ruby-shebang-args " -wKU" + "Arguments for the ruby shebang line.") + (defun yas/ruby-infer-class-name () "Infer the class name from the buffer. Thanks to hitesh " (let ((fn (capitalize (file-name-nondirectory @@ -17,10 +20,31 @@ ((string-match "_" fn) (replace-match "" nil nil 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 ;; -(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-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))))) \ No newline at end of file diff --git a/extras/imported/ruby-mode/add evaluation marker.yasnippet b/extras/imported/ruby-mode/add evaluation marker.yasnippet new file mode 100644 index 0000000..1c36bdc --- /dev/null +++ b/extras/imported/ruby-mode/add evaluation marker.yasnippet @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# key: # +# contributor: Translated from TextMate Snippet +# name: Add # => marker +# -- +# => \ No newline at end of file