mirror of
https://github.com/joaotavora/yasnippet.git
synced 2026-02-04 14:32:26 +00:00
tweaking the ruby-mode snippets slightly
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
((string-match "_" fn) (replace-match "" nil nil fn))
|
||||
(t fn))))
|
||||
|
||||
(defun yas/ruby-in-interpolated-string-p ()
|
||||
(eq (fourth (syntax-ppss))
|
||||
?\"))
|
||||
|
||||
(defun yas/ruby-in-comment-p ()
|
||||
(fifth (syntax-ppss)))
|
||||
;; conditions
|
||||
;;
|
||||
(yas/define-condition-cache yas/ruby-in-interpolated-string-p (eq (fourth (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)))
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: {
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# assumes some sort of autopairing of the braces such as autopair.el or ruby electric
|
||||
# that would have added the closing brace.
|
||||
# name: Insert { |variable| … }
|
||||
## condition: "source.ruby - string - comment"
|
||||
# condition: (not (or (yas/ruby-in-comment-p) (yas/ruby-in-string-p)))
|
||||
# --
|
||||
{ ${1:$(if (string= yas/text "") "" "|")}${1:variable}${1:$(if (string= yas/text "") "" "|")}${2:`yas/selected-text`}
|
||||
(yas/expand-snippet (concat
|
||||
"{ ${1:$(if (string= yas/text \"\") \"\" \"|\")}${1:variable}${1:$(if (string= yas/text \"\") \" \" \"| \")}`yas/selected-text`$0"
|
||||
(save-excursion (if (search-forward-regexp "}" (line-end-position) t)
|
||||
"" "}"))))
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
# name: New Block
|
||||
## condition: "source.ruby"
|
||||
# --
|
||||
`[[ $TM_LINE_INDEX != 0 ]] && echo; echo`=begin rdoc
|
||||
`(if (save-restriction (widen) (eq 1 (line-number-at-pos))) "\n\n" "\n")`=begin rdoc
|
||||
$0
|
||||
=end
|
||||
@@ -2,6 +2,6 @@
|
||||
# key: y
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: :yields:
|
||||
## condition: "source.ruby comment"
|
||||
# condition: (yas/ruby-in-comment-p)
|
||||
# --
|
||||
:yields: ${0:arguments}
|
||||
:yields: ${1:arguments}
|
||||
Reference in New Issue
Block a user