* Start again the textmate snippet importations, with better

textmate_import.rb and yasnippet.el
This commit is contained in:
capitaomorte
2010-04-01 11:41:19 +00:00
parent 6b07c4b1d6
commit 5d9f7fb6b4
939 changed files with 0 additions and 7031 deletions

View File

@@ -1 +0,0 @@
text-mode

View File

@@ -1,83 +0,0 @@
(defvar yas/html-default-tag "p")
(defvar yas/html-xhtml-attr "")
(defvar yas/html-just-like-tm nil
"Html-mode snippets behave as close to TextMate as possible.")
(defun yas/html-remove-preceding-word ()
(interactive)
(let (word-begin
word-end
(line-beginning-position (line-beginning-position))
(orig-point (point))
retval)
(save-excursion
(when (and (forward-word -1)
(setq word-begin (point))
(forward-word 1)
(setq word-end (point))
(< word-begin orig-point)
(>= word-end orig-point)
(<= (line-beginning-position) word-begin)
;; (not (string-match "^[\s\t]+$" " "))
)
(setq retval
(cons
(buffer-substring-no-properties word-begin orig-point)
(buffer-substring-no-properties word-end orig-point)))
(delete-region word-begin word-end)
retval))))
(defun yas/html-first-word (string)
(replace-regexp-in-string "\\\W.*" "" string))
(defun yas/html-insert-tag-pair-snippet ()
(let* ((tag-and-suffix (or (and yas/selected-text
(cons yas/selected-text nil))
(yas/html-remove-preceding-word)))
(tag (car tag-and-suffix))
(suffix (or (cdr tag-and-suffix) ""))
(single-no-arg "\\(br\\|hr\\)")
(single "\\(img\\|meta\\|link\\|input\\|base\\|area\\|col\\|frame\\|param\\)"))
(cond ((null tag)
(yas/expand-snippet (format "<${1:%s}>%s</${1:$(yas/html-first-word yas/text)}>%s"
(or yas/html-default-tag
"p")
(if yas/html-just-like-tm "$2" "$0")
suffix)))
((string-match single-no-arg tag)
(insert (format "<%s%s/>%s" tag yas/html-xhtml-attr suffix)))
((string-match single tag)
(yas/expand-snippet (format "<%s $1%s/>%s" tag yas/html-xhtml-attr suffix)))
(t
(yas/expand-snippet (format "<%s>%s</%s>%s"
tag
(if yas/html-just-like-tm "$1" "$0")
(replace-regexp-in-string "\\\W.*" "" tag)
suffix))))))
(defun yas/html-wrap-each-line-in-openclose-tag ()
(let* ((mirror "${1:$(yas/html-first-word yas/text)}")
(yas/html-wrap-newline (when (string-match "\n" yas/selected-text) "\n"))
(template (concat (format "<${1:%s}>" (or yas/html-default-tag "p"))
yas/selected-text
"</" mirror ">")))
(setq template (replace-regexp-in-string "\n" (concat "</" mirror ">\n<$1>") template))
(yas/expand-snippet template)))
(defun yas/html-wrap-selection-if-not-wrapped-already (wrapping)
(if (string-match (format "<%s>.*</%s>" wrapping wrapping) yas/selected-text)
(insert yas/selected-text)
(insert (format "<%s>%s</%s>" wrapping yas/selected-text wrapping))))
(defun yas/html-between-tag-pair-p ()
(save-excursion
(backward-word)
(looking-at "\\\w+></\\\w+>")))
(defun yas/html-id-from-string (string)
(replace-regexp-in-string " " "_" (downcase string)))

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 5.0 only
## condition: "text.html"
# --
<!--[if IE 5.0]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.0 only ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 5.5 only
## condition: "text.html"
# --
<!--[if IE 5.5000]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.5 only ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 5.x
## condition: "text.html"
# --
<!--[if lt IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.x ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 6 and below
## condition: "text.html"
# --
<!--[if lte IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 6 and below ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 6 only
## condition: "text.html"
# --
<!--[if IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 6 only ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer 7 and above
## condition: "text.html"
# --
<!--[if gte IE 7]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 7 and above ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: Internet Explorer
## condition: "text.html"
# --
<!--[if IE]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer ")`}<![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: !
# contributor: Translated from TextMate Snippet
# name: IE Conditional Comment: NOT Internet Explorer
## condition: "text.html"
# --
<!--[if !IE]><!-->${1:`(or yas/selected-text " IE Conditional Comment: NOT Internet Explorer ")`}<!-- <![endif]-->$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: arrow
# contributor: Translated from TextMate Snippet
# name: →
## condition: "text.html"
# --
&#x2192;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: backspace
# contributor: Translated from TextMate Snippet
# name: ⌫
## condition: "text.html"
# --
&#x232B;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: backtab
# contributor: Translated from TextMate Snippet
# name: ⇤
## condition: "text.html"
# --
&#x21E4;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: command
# contributor: Translated from TextMate Snippet
# name: ⌘
## condition: "text.html"
# --
&#x2318;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: control
# contributor: Translated from TextMate Snippet
# name: ⌃
## condition: "text.html"
# --
&#x2303;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: delete
# contributor: Translated from TextMate Snippet
# name: ⌦
## condition: "text.html"
# --
&#x2326;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: down
# contributor: Translated from TextMate Snippet
# name: ↓
## condition: "text.html"
# --
&#x2193;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: enter
# contributor: Translated from TextMate Snippet
# name: ⌅
## condition: "text.html"
# --
&#x2305;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: escape
# contributor: Translated from TextMate Snippet
# name: ⎋
## condition: "text.html"
# --
&#x238B;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: left
# contributor: Translated from TextMate Snippet
# name: ←
## condition: "text.html"
# --
&#x2190;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: option
# contributor: Translated from TextMate Snippet
# name: ⌥
## condition: "text.html"
# --
&#x2325;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: return
# contributor: Translated from TextMate Snippet
# name: ↩
## condition: "text.html"
# --
&#x21A9;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: right
# contributor: Translated from TextMate Snippet
# name: →
## condition: "text.html"
# --
&#x2192;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: shift
# contributor: Translated from TextMate Snippet
# name: ⇧
## condition: "text.html"
# --
&#x21E7;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: tab
# contributor: Translated from TextMate Snippet
# name: ⇥
## condition: "text.html"
# --
&#x21E5;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: up
# contributor: Translated from TextMate Snippet
# name: ↑
## condition: "text.html"
# --
&#x2191;

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Translated from TextMate Snippet
# name: Non-Breaking Space
# key: nbsp
## binding: " "
## condition: "text.html"
# --
&nbsp;

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# type: command
# name: Emphasize
# binding: A-i
## condition: "text.html"
# --
(yas/html-wrap-selection-if-not-wrapped-already "em")

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# type: command
# name: Strong
# binding: A-b
## condition: "text.html"
# --
(yas/html-wrap-selection-if-not-wrapped-already "strong")

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: HTML — 4.01 Strict
## condition: "text.html"
# --
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: XHTML — 1.0 Frameset
## condition: "text.html"
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: XHTML — 1.0 Strict
## condition: "text.html"
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: XHTML — 1.0 Transitional
## condition: "text.html"
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: XHTML — 1.1
## condition: "text.html"
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# key: doctype
# contributor: Translated from TextMate Snippet
# name: HTML — 4.01 Transitional
## condition: "text.html"
# --
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# type: command
# contributor: joaotavora, adapted from TextMate HTML bundle
# name: Insert Open/Close Tag (With Current Word)
# expand-env: ((yas/wrap-around-region t))
# binding: "^<"
## condition: "text.html,"
# --
(yas/html-insert-tag-pair-snippet)

View File

@@ -1,17 +0,0 @@
# -*- mode: snippet -*-
# key: movie
# contributor: Translated from TextMate Snippet
# name: Embed QT Movie
## condition: "text.html"
# --
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="$1"`yas/html-xhtml-attr`>
<param name="controller" value="$4"`yas/html-xhtml-attr`>
<param name="autoplay" value="$5"`yas/html-xhtml-attr`>
<embed src="${1:movie.mov}"
width="${2:320}" height="${3:240}"
controller="${4:true}" autoplay="${5:true}"
scale="tofit" cache="true"
pluginspage="http://www.apple.com/quicktime/download/"`(when (and yas/html-xhtml-attr (not (string= "" yas/html-xhtml-attr)))
(concat "\n" yas/html-xhtml-attr))`>
</object>

View File

@@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# key: fieldset
# contributor: Translated from TextMate Snippet
# name: Fieldset
## condition: "text.html"
# --
<fieldset id="${1:$(yas/html-id-from-string yas/text)}" ${2:class="$3"}>
<legend>${1:`yas/selected-text`}</legend>
$0
</fieldset>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: input
# contributor: Translated from TextMate Snippet
# name: Input with Label
## condition: "text.html"
# --
<label for="${2:${1:$(yas/html-id-from-string yas/text)}}">${1:}</label><input type="${3:$$(yas/choose-value '("text" "submit" "hidden" "button"))}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`yas/html-xhtml-attr`>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: opt
# contributor: Translated from TextMate Snippet
# name: Option
## condition: "text.html"
# --
<option${1: value="${2:option}"}>${3:option$(unless yas/modified-p (yas/field-value 2))}</option>

View File

@@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# key: select
# contributor: Translated from TextMate Snippet
# name: Select Box
## condition: "text.html"
# --
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="$6"}${7: size="${8:1}"}}>
<option${9: value="${10:option1}"}>${11:$10}</option>
<option${12: value="${13:option2}"}>${14:$13}</option>$15
$0
</select>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: mailto
# contributor: Translated from TextMate Snippet
# name: Mail Anchor
## condition: "text.html"
# --
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: base
# contributor: Translated from TextMate Snippet
# name: Base
## condition: "text.html"
# --
<base href="$1"${2: target="$3"}`yas/html-xhtml-attr`>

View File

@@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# key: body
# contributor: Translated from TextMate Snippet
# name: Body
## condition: "text.html"
# --
<body id="${1:`(or (and buffer-file-name
(downcase (file-name-sans-extension (file-name-nondirectory buffer-file-name))))
"some_id")`}"${2: onload="$3"}>
$0
</body>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Translated from TextMate Snippet
# name: Br
# binding: M-RET
## condition: "text.html"
# --
<br`yas/html-xhtml-attr`>

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# key: div
# contributor: Translated from TextMate Snippet
# name: Div
## condition: "text.html"
# --
<div${1: id="${2:name}"}>
`yas/selected-text`$0
</div>

View File

@@ -1,14 +0,0 @@
# -*- mode: snippet -*-
# key: form
# contributor: Translated from TextMate Snippet
# name: Form
## condition: "text.html"
# --
<form action="${1:`(or (and buffer-file-name
(concat (file-name-sans-extension (file-name-nondirectory buffer-file-name))
"_submit"))
"some_action")`}" method="${2:get}" accept-charset="utf-8">
$0
<p><input type="submit" value="Continue &rarr;"`yas/html-xhtml-attr`></p>
</form>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: h1
# contributor: Translated from TextMate Snippet
# name: Heading
## condition: "text.html"
# --
<h1 id="${1:$(yas/html-id-from-string yas/text)}">${1:`yas/selected-text`}</h1>

View File

@@ -1,13 +0,0 @@
# -*- mode: snippet -*-
# key: head
# contributor: Translated from TextMate Snippet
# name: Head
## condition: "text.html - text.html source"
# --
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"`yas/html-xhtml-attr`>
<title>${1:`(or (and buffer-file-name
(file-name-sans-extension (file-name-nondirectory buffer-file-name)))
"Page Title")`}</title>
$0
</head>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# key: input
# name: Input
## condition: "text.html"
# --
<input type="${1:$$(yas/choose-value '("text" "submit" "hidden" "button"))}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`yas/html-xhtml-attr`>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: link
# contributor: Translated from TextMate Snippet
# name: Link
## condition: "text.html"
# --
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`yas/html-xhtml-attr`>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: meta
# contributor: Translated from TextMate Snippet
# name: Meta
## condition: "text.html"
# --
<meta name="${1:name}" content="${2:content}"`yas/html-xhtml-attr`>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: scriptsrc
# contributor: Translated from TextMate Snippet
# name: Script With External Source
## condition: "text.html"
# --
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# key: script
# contributor: Translated from TextMate Snippet
# name: Script
## condition: "text.html"
# --
<script type="text/javascript" charset="utf-8">
$0
</script>

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# key: style
# contributor: Translated from TextMate Snippet
# name: Style
## condition: "text.html"
# --
<style type="text/css" media="screen">
$0
</style>

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# key: table
# contributor: Translated from TextMate Snippet
# name: Table
## condition: "text.html"
# --
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
<tr><th>${5:Header}</th></tr>
<tr><td>${0:Data}</td></tr>
</table>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# key: textarea
# contributor: Translated from TextMate Snippet
# name: Text Area
## condition: "text.html"
# --
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# key: title
# contributor: Translated from TextMate Snippet
# name: Title
## condition: "text.html - text.blog"
# --
<title>${1:`(or (and buffer-file-name
(file-name-sans-extension (file-name-nondirectory buffer-file-name)))
"Page Title")`}</title>

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# contributor: Translated from TextMate Snippet
# name: Special: Return Inside Empty Open/Close Tags
# binding: RET
# condition: (yas/html-between-tag-pair-p)
# type: command
# --
(save-excursion
(newline-and-indent))
(indent-according-to-mode)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# type: command
# contributor: joaotavora, adapted from TextMate HTML bundle
# name: Wrap Each Selected Line in Open/Close Tag
# binding: C-S-A-w
# condition: mark-active
# --
(yas/html-wrap-each-line-in-openclose-tag)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: joaotavora, adapted from TextMate HTML bundle
# name: Wrap Selection in Open/Close Tag
# binding: C-S-w
# condition: mark-active
# expand-env: ((yas/html-wrap-newline (when (string-match "\n" yas/selected-text) "\n")))
# --
<${1:p}>`(concat yas/html-wrap-newline yas/selected-text yas/html-wrap-newline)`</${1:$(yas/html-first-word yas/text)}>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Translated from TextMate Snippet
# name: Wrap in <?= … ?>
# expand-env: ((yas/wrap-around-region t))
## condition: "text.html string"
# --
<?= $0 ?>