mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
* Finished commiting Rob Christie's patches to the ruby snippets (add
setup.el, delete the # => snippet) * Tweaked some ruby snippets * Disabled bindings for some TextMate text-mode snippets
This commit is contained in:
parent
deb0755824
commit
57c150b42d
@ -1,6 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: #
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Add ‘# =>’ Marker
|
||||
# --
|
||||
# =>
|
@ -2,11 +2,16 @@
|
||||
# key: begin
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: begin … rescue … end
|
||||
## binding: "^W"
|
||||
## condition: "source.ruby - comment"
|
||||
## binding: "C-c C-w"
|
||||
# condition: (not (yas/ruby-in-comment-p))
|
||||
# --
|
||||
begin
|
||||
`(or yas/selected-text (car kill-ring))`$3
|
||||
`(or yas/selected-text
|
||||
(and cua-mode
|
||||
(prog1
|
||||
(get-register ?0)
|
||||
(set-register ?0 nil)))
|
||||
(car kill-ring))`$3
|
||||
rescue ${1:Exception}${2:$(if (string= yas/text "") "" " => ")}${2:e}
|
||||
$0
|
||||
end
|
||||
|
@ -1,7 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Embedded Code — #{…}
|
||||
## binding: "C-#"
|
||||
## condition: "(string.quoted.double.ruby|string.interpolated.ruby) - string source"
|
||||
# binding: "#"
|
||||
# condition: (yas/ruby-in-interpolated-string-p)
|
||||
# expand-env: ((yas/wrap-around-region t))
|
||||
# --
|
||||
{${1:`yas/selected-text`}}
|
||||
#{$0}
|
27
extras/imported/ruby-mode/setup.el
Normal file
27
extras/imported/ruby-mode/setup.el
Normal file
@ -0,0 +1,27 @@
|
||||
(defvar yas/ruby-snippet-open-paren " "
|
||||
"The open parenthesis used in ruby-mode snippets. Normally blank but could be (")
|
||||
(defvar yas/ruby-snippet-close-paren " "
|
||||
"The close parenthesis used in ruby-mode snippets. Normally blank but could be )")
|
||||
(defun yas/ruby-snippet-paren (&optional arg)
|
||||
"Defaults to returning the open paren. If arg equals t then shows close paren."
|
||||
(if arg
|
||||
yas/ruby-snippet-close-paren
|
||||
yas/ruby-snippet-open-paren))
|
||||
|
||||
(defun yas/ruby-infer-class-name ()
|
||||
"Infer the class name from the buffer. Thanks to hitesh <hitesh.jasani@gmail.com>"
|
||||
(let ((fn (capitalize (file-name-nondirectory
|
||||
(file-name-sans-extension
|
||||
(buffer-file-name))))))
|
||||
(cond
|
||||
((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)))
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Continue Bullet
|
||||
# binding: ""
|
||||
## binding: ""
|
||||
# --
|
||||
|
||||
•
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Continue Light Bullet
|
||||
# binding: ""
|
||||
## binding: ""
|
||||
# --
|
||||
|
||||
·
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Continue Star Bullet
|
||||
# binding: ""
|
||||
## binding: ""
|
||||
# --
|
||||
|
||||
*
|
@ -1449,6 +1449,11 @@ TEMPLATES is a list of `yas/template'."
|
||||
(defun yas/load-directory-1 (directory &optional parents no-hierarchy-parents making-groups-sym)
|
||||
"Recursively load snippet templates from DIRECTORY."
|
||||
;; TODO: Rewrite this horrible, horrible monster I created
|
||||
;; TODO: Temp hack, load a setup.el file if its exists
|
||||
(let ((file (concat directory "/" "setup.el")))
|
||||
(when (file-exists-p file)
|
||||
(load file)))
|
||||
|
||||
(unless (file-exists-p (concat directory "/" ".yas-skip"))
|
||||
(let* ((major-mode-and-parents (unless making-groups-sym
|
||||
(yas/compute-major-mode-and-parents (concat directory "/dummy")
|
||||
|
Loading…
x
Reference in New Issue
Block a user