From 295972897fdf133c512b667a8f78825aff4d22fc Mon Sep 17 00:00:00 2001 From: capitaomorte Date: Thu, 19 Nov 2009 17:09:01 +0000 Subject: [PATCH] a little bit more work done --- extras/imported/rails-mode/.yas-setup.el | 16 +++++++--------- .../Table column(s) rename.yasnippet | 2 +- .../t_rename (tre).yasnippet | 2 +- .../Columns/Add 3A Remove Column.yasnippet | 8 ++++++++ ...d 3A Remove Several Columns (marcc).yasnippet | 8 ++++++++ .../Add 3A Remove Several Columns.yasnippet | 8 ++++++++ ...me 3A Rename Several Columns (mncc).yasnippet | 8 ++++++++ .../Rename 3A Rename Several Columns.yasnippet | 8 ++++++++ .../rails-mode/Columns/Rename Column.yasnippet | 8 ++++++++ .../Create binary column.yasnippet | 2 +- .../Create boolean column.yasnippet | 2 +- .../Create date column.yasnippet | 2 +- .../Create datetime column.yasnippet | 2 +- .../Create decimal column.yasnippet | 2 +- .../Create float column.yasnippet | 2 +- .../Create integer column.yasnippet | 2 +- .../Create lock_version column.yasnippet | 2 +- .../Create references column.yasnippet | 2 +- .../Create string column.yasnippet | 2 +- .../Create text column.yasnippet | 2 +- .../Create time column.yasnippet | 2 +- .../Create timestamp column.yasnippet | 2 +- .../Create timestamps columns.yasnippet | 2 +- .../Tables/Change Change Table.yasnippet | 8 ++++++++ .../Tables/Create 3A Drop Table.yasnippet | 8 ++++++++ .../rails-mode/Tables/Rename Table.yasnippet | 8 ++++++++ 26 files changed, 95 insertions(+), 25 deletions(-) create mode 100644 extras/imported/rails-mode/Columns/Add 3A Remove Column.yasnippet create mode 100644 extras/imported/rails-mode/Columns/Add 3A Remove Several Columns (marcc).yasnippet create mode 100644 extras/imported/rails-mode/Columns/Add 3A Remove Several Columns.yasnippet create mode 100644 extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns (mncc).yasnippet create mode 100644 extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns.yasnippet create mode 100644 extras/imported/rails-mode/Columns/Rename Column.yasnippet create mode 100644 extras/imported/rails-mode/Tables/Change Change Table.yasnippet create mode 100644 extras/imported/rails-mode/Tables/Create 3A Drop Table.yasnippet create mode 100644 extras/imported/rails-mode/Tables/Rename Table.yasnippet diff --git a/extras/imported/rails-mode/.yas-setup.el b/extras/imported/rails-mode/.yas-setup.el index 74eac2a..e249de8 100644 --- a/extras/imported/rails-mode/.yas-setup.el +++ b/extras/imported/rails-mode/.yas-setup.el @@ -1,17 +1,16 @@ (defvar yas/rails-root-cache nil) -(make-local-variable 'yas/rails-root-cache) ;; stolen from rinari-mode's rinari-root (defun yas/rails-root (&optional dir) + (or dir (setq dir default-directory)) (or yas/rails-root-cache - (or dir (setq dir default-directory)) (if (file-exists-p (expand-file-name "environment.rb" (expand-file-name "config" dir))) - (setq yas/rails-root-cache dir) + (set (make-local-variable 'yas/rails-root-cache) dir) (let ((new-dir (expand-file-name (file-name-as-directory "..") dir))) ;; regexp to match windows roots, tramp roots, or regular posix roots (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir) - (rinari-root new-dir)))))) + (yas/rails-root new-dir)))))) ;; stolen from rinari-mode's rinari-extract-partial (defun yas/rails-extract-partial (begin end partial-name) @@ -135,10 +134,9 @@ (and (yas/rails-root) (string-match "db/migrate/" default-directory))) - -(defadvice cd (after yas/rails-on-cd-activate) - "Active/Deactive rinari-merb-minor-node when changing into and out -of raills project directories." +(defadvice cd (after yas/rails-on-cd-activate activate) + "Set `yas/mode-symbol' to `rails-mode' so that rails snippets +are recognized" (setq yas/rails-root-cache nil) (when (yas/rails-root) - (setq (make-local-variable 'yas/mode-symbol) 'rails-mode))) + (set (make-local-variable 'yas/mode-symbol) 'rails-mode))) diff --git a/extras/imported/rails-mode/Change columns helpers/Table column(s) rename.yasnippet b/extras/imported/rails-mode/Change columns helpers/Table column(s) rename.yasnippet index 9722830..48036a4 100644 --- a/extras/imported/rails-mode/Change columns helpers/Table column(s) rename.yasnippet +++ b/extras/imported/rails-mode/Change columns helpers/Table column(s) rename.yasnippet @@ -2,7 +2,7 @@ # key: tre # contributor: Translated from TextMate Snippet # name: Table column(s) rename -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.rename(:${1:old_column_name}, :${2:new_column_name}) $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Change columns t. drop-down list/t_rename (tre).yasnippet b/extras/imported/rails-mode/Change columns t. drop-down list/t_rename (tre).yasnippet index 09302e3..888ed82 100644 --- a/extras/imported/rails-mode/Change columns t. drop-down list/t_rename (tre).yasnippet +++ b/extras/imported/rails-mode/Change columns t. drop-down list/t_rename (tre).yasnippet @@ -2,7 +2,7 @@ # key: t. # contributor: Translated from TextMate Snippet # name: t.rename (tre) -# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table)) +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table) (yas/rails-in-change-table-p))) # -- t.rename(:${1:old_column_name}, :${2:new_column_name}) t.$0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Columns/Add 3A Remove Column.yasnippet b/extras/imported/rails-mode/Columns/Add 3A Remove Column.yasnippet new file mode 100644 index 0000000..a958602 --- /dev/null +++ b/extras/imported/rails-mode/Columns/Add 3A Remove Column.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mcol +# contributor: Translated from TextMate Snippet +# name: Add / Remove Column +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :add_remove_column) diff --git a/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns (marcc).yasnippet b/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns (marcc).yasnippet new file mode 100644 index 0000000..ae4ff1a --- /dev/null +++ b/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns (marcc).yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: marcc +# contributor: Translated from TextMate Snippet +# name: Add / Remove Several Columns (marcc) +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :add_remove_column_continue) \ No newline at end of file diff --git a/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns.yasnippet b/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns.yasnippet new file mode 100644 index 0000000..4b60f0f --- /dev/null +++ b/extras/imported/rails-mode/Columns/Add 3A Remove Several Columns.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mcol +# contributor: Translated from TextMate Snippet +# name: Add / Remove Several Columns +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :add_remove_column_continue) diff --git a/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns (mncc).yasnippet b/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns (mncc).yasnippet new file mode 100644 index 0000000..260b57f --- /dev/null +++ b/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns (mncc).yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mncc +# contributor: Translated from TextMate Snippet +# name: Rename / Rename Several Columns (mncc) +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :rename_column_continue) diff --git a/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns.yasnippet b/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns.yasnippet new file mode 100644 index 0000000..8cf16d7 --- /dev/null +++ b/extras/imported/rails-mode/Columns/Rename 3A Rename Several Columns.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mcol +# contributor: Translated from TextMate Snippet +# name: Rename / Rename Several Columns +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :rename_column_continue) diff --git a/extras/imported/rails-mode/Columns/Rename Column.yasnippet b/extras/imported/rails-mode/Columns/Rename Column.yasnippet new file mode 100644 index 0000000..2acc5e0 --- /dev/null +++ b/extras/imported/rails-mode/Columns/Rename Column.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mcol +# contributor: Translated from TextMate Snippet +# name: Rename / Rename Column +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :rename_column) diff --git a/extras/imported/rails-mode/Create columns helpers/Create binary column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create binary column.yasnippet index 9a90743..3622c4b 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create binary column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create binary column.yasnippet @@ -2,7 +2,7 @@ # key: tcbi # contributor: Translated from TextMate Snippet # name: Table column binary -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create boolean column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create boolean column.yasnippet index 6b51f30..5204f8e 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create boolean column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create boolean column.yasnippet @@ -2,7 +2,7 @@ # key: tcb # contributor: Translated from TextMate Snippet # name: Table column boolean -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.boolean :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create date column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create date column.yasnippet index 2deb669..b93ee82 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create date column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create date column.yasnippet @@ -2,7 +2,7 @@ # key: tcda # contributor: Translated from TextMate Snippet # name: Table column date -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.date :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create datetime column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create datetime column.yasnippet index 25f28af..8a2d2c9 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create datetime column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create datetime column.yasnippet @@ -2,7 +2,7 @@ # key: tcdt # contributor: Translated from TextMate Snippet # name: Table column datetime -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.datetime :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create decimal column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create decimal column.yasnippet index 062fc3b..6d84bad 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create decimal column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create decimal column.yasnippet @@ -2,7 +2,7 @@ # key: tcd # contributor: Translated from TextMate Snippet # name: Table column decimal -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create float column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create float column.yasnippet index ec048f8..d874d50 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create float column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create float column.yasnippet @@ -2,7 +2,7 @@ # key: tcf # contributor: Translated from TextMate Snippet # name: Table column float -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.float :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create integer column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create integer column.yasnippet index 48e38e5..a4e8930 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create integer column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create integer column.yasnippet @@ -2,7 +2,7 @@ # key: tci # contributor: Translated from TextMate Snippet # name: Table column integer -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.integer :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create lock_version column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create lock_version column.yasnippet index dcb2014..bf8a6c8 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create lock_version column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create lock_version column.yasnippet @@ -2,7 +2,7 @@ # key: tcl # contributor: Translated from TextMate Snippet # name: Table column lock_version -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.integer :lock_version, :null => false, :default => 0 $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create references column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create references column.yasnippet index ba5de28..be34175 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create references column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create references column.yasnippet @@ -2,7 +2,7 @@ # key: tcr # contributor: Translated from TextMate Snippet # name: Table column(s) references -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create string column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create string column.yasnippet index 2befb63..12ac6f8 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create string column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create string column.yasnippet @@ -2,7 +2,7 @@ # key: tcs # contributor: Translated from TextMate Snippet # name: Table column string -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.string :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create text column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create text column.yasnippet index bc8d833..18dd3a5 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create text column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create text column.yasnippet @@ -2,7 +2,7 @@ # key: tct # contributor: Translated from TextMate Snippet # name: Table column text -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.text :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create time column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create time column.yasnippet index f76f3f3..d5e0ec1 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create time column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create time column.yasnippet @@ -2,7 +2,7 @@ # key: tcti # contributor: Translated from TextMate Snippet # name: Table column time -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.time :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create timestamp column.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create timestamp column.yasnippet index 88909ff..2af52ae 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create timestamp column.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create timestamp column.yasnippet @@ -2,7 +2,7 @@ # key: tcts # contributor: Translated from TextMate Snippet # name: Table column timestamp -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.timestamp :${1:title} $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Create columns helpers/Create timestamps columns.yasnippet b/extras/imported/rails-mode/Create columns helpers/Create timestamps columns.yasnippet index bb887b7..2a0aa99 100644 --- a/extras/imported/rails-mode/Create columns helpers/Create timestamps columns.yasnippet +++ b/extras/imported/rails-mode/Create columns helpers/Create timestamps columns.yasnippet @@ -2,7 +2,7 @@ # key: tctss # contributor: Translated from TextMate Snippet # name: Table column timestamps -## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table" +# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p))) # -- t.timestamps $0 \ No newline at end of file diff --git a/extras/imported/rails-mode/Tables/Change Change Table.yasnippet b/extras/imported/rails-mode/Tables/Change Change Table.yasnippet new file mode 100644 index 0000000..1d344a6 --- /dev/null +++ b/extras/imported/rails-mode/Tables/Change Change Table.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mtab +# contributor: Translated from TextMate Snippet +# name: Change / Change Table +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :change_change_table) \ No newline at end of file diff --git a/extras/imported/rails-mode/Tables/Create 3A Drop Table.yasnippet b/extras/imported/rails-mode/Tables/Create 3A Drop Table.yasnippet new file mode 100644 index 0000000..209d6da --- /dev/null +++ b/extras/imported/rails-mode/Tables/Create 3A Drop Table.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mtab +# contributor: Translated from TextMate Snippet +# name: Create / Drop Table +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :add_remove_column) \ No newline at end of file diff --git a/extras/imported/rails-mode/Tables/Rename Table.yasnippet b/extras/imported/rails-mode/Tables/Rename Table.yasnippet new file mode 100644 index 0000000..d269c29 --- /dev/null +++ b/extras/imported/rails-mode/Tables/Rename Table.yasnippet @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# type: command +# key: mtab +# contributor: Translated from TextMate Snippet +# name: Rename / Rename Table +# condition: (yas/rails-intelligent-migration-snippet-condition-p) +# -- +(yas/rails-intelligent-migration-snippet :rename_table) \ No newline at end of file