add a whole bunch of snippets taken from other people

This commit is contained in:
Andrea Crotti 2011-11-03 14:07:34 +00:00
parent 9dea2be458
commit 8d6d521c89
340 changed files with 1800 additions and 2 deletions

3
css-mode/bg Normal file
View File

@ -0,0 +1,3 @@
#name : background-color: ...
# --
background-color: #${1:DDD};

3
css-mode/bg.1 Normal file
View File

@ -0,0 +1,3 @@
#name : background-image: ...
# --
background-image: url($1);

3
css-mode/bor Normal file
View File

@ -0,0 +1,3 @@
#name : border size style color
# --
border: ${1:1px} ${2:solid} #${3:999};

4
css-mode/cl Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : clear: ...
# --
clear: $1;

4
css-mode/disp.block Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : display: block
# --
display: block;

4
css-mode/disp.inline Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : display: inline
# --
display: inline;

4
css-mode/disp.none Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : display: none
# --
display: none;

4
css-mode/ff Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : font-family: ...
# --
font-family: $1;

4
css-mode/fs Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : font-size: ...
# --
font-size: ${12px};

4
css-mode/mar.bottom Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin-bottom: ...
# --
margin-bottom: $1;

4
css-mode/mar.left Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin-left: ...
# --
margin-left: $1;

4
css-mode/mar.mar Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin: ...
# --
margin: $1;

4
css-mode/mar.margin Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin top right bottom left
# --
margin: ${top} ${right} ${bottom} ${left};

4
css-mode/mar.right Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin-right: ...
# --
margin-right: $1;

4
css-mode/mar.top Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : margin-top: ...
# --
margin-top: $1;

4
css-mode/pad.bottom Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding-bottom: ...
# --
padding-bottom: $1;

4
css-mode/pad.left Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding-left: ...
# --
padding-left: $1;

4
css-mode/pad.pad Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding: ...
# --
padding: $1;

4
css-mode/pad.padding Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding: top right bottom left
# --
padding: ${top} ${right} ${bottom} ${left};

4
css-mode/pad.right Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding-right: ...
# --
padding-right: $1;

4
css-mode/pad.top Normal file
View File

@ -0,0 +1,4 @@
#contributor : rejeep <johan.rejeep@gmail.com>
#name : padding-top: ...
# --
padding-top: $1;

View File

@ -0,0 +1,16 @@
#name : process marked files in dired
#contributor : Xah Lee
# --
;; idiom for processing a list of files in dired's marked files
;; suppose myProcessFile is your function that takes a file path
;; and do some processing on the file
(defun dired-myProcessFile ()
"apply myProcessFile function to marked files in dired."
(interactive)
(require 'dired)
(mapc 'myProcessFile (dired-get-marked-files))
)
;; to use it, type M-x dired-myProcessFile

View File

@ -0,0 +1,17 @@
#name : a function that process a file
#contributor : Xah Lee
# --
(defun doThisFile (fpath)
"Process the file at path FPATH ..."
(let ()
;; create temp buffer without undo record or font lock. (more efficient)
;; first space in temp buff name is necessary
(set-buffer (get-buffer-create " myTemp"))
(insert-file-contents fpath nil nil nil t)
;; process it ...
;; (goto-char 0) ; move to begining of file's content (in case it was open)
;; ... do something here
;; (write-file fpath) ;; write back to the file
(kill-buffer " myTemp")))

View File

@ -0,0 +1,17 @@
#name : read lines of a file
#contributor : Xah Lee
# --
(defun read-lines (filePath)
"Return a list of lines in FILEPATH."
(with-temp-buffer
(insert-file-contents filePath)
(split-string
(buffer-string) "\n" t)) )
;; process all lines
(mapc
(lambda (aLine)
(message aLine) ; do your stuff here
)
(read-lines "inputFilePath")
)

View File

@ -0,0 +1,17 @@
#name : find and replace on region
#contributor : Xah Lee
# --
(defun replace-html-chars-region (start end)
"Replace “<” to “&lt;” and other chars in HTML.
This works on the current region."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (search-forward "&" nil t) (replace-match "&amp;" nil t))
(goto-char (point-min))
(while (search-forward "<" nil t) (replace-match "&lt;" nil t))
(goto-char (point-min))
(while (search-forward ">" nil t) (replace-match "&gt;" nil t))
)
)

View File

@ -0,0 +1,4 @@
#name : grab buffer substring
#contributor : Xah Lee
# --
(setq $0 (buffer-substring-no-properties myStartPos myEndPos))

View File

@ -0,0 +1,4 @@
#name : grab word under cursor
#contributor : Xah Lee
# --
(setq $0 (thing-at-point 'symbol))

View File

@ -0,0 +1,6 @@
#name : traversing a directory
#contributor : Xah Lee
# --
;; apply a function to all files in a dir
(require 'find-lisp)
(mapc 'my-process-file (find-lisp-find-files "~/myweb/" "\\.html$"))

View File

@ -0,0 +1,27 @@
#name : Command that works on region or word
#contributor : Xah Lee
# --
;; example of a command that works on current word or text selection
(defun down-case-word-or-region ()
"Lower case the current word or text selection."
(interactive)
(let (pos1 pos2 meat)
(if (and transient-mark-mode mark-active)
(setq pos1 (region-beginning)
pos2 (region-end))
(setq pos1 (car (bounds-of-thing-at-point 'symbol))
pos2 (cdr (bounds-of-thing-at-point 'symbol))))
; now, pos1 and pos2 are the starting and ending positions
; of the current word, or current text selection if exists
;; put your code here.
$0
;; Some example of things you might want to do
(downcase-region pos1 pos2) ; example of a func that takes region as args
(setq meat (buffer-substring-no-properties pos1 pos2)) ; grab the text.
(delete-region pos1 pos2) ; get rid of it
(insert "newText") ; insert your new text
)
)

4
erlang-mode/after Normal file
View File

@ -0,0 +1,4 @@
#name : after ... ->
# --
after
$1 -> $0

5
erlang-mode/begin Normal file
View File

@ -0,0 +1,5 @@
#name : begin ... end
# --
begin
$0
end

4
erlang-mode/beh Normal file
View File

@ -0,0 +1,4 @@
#name : -behaviour(...).
# --
-behaviour(${1:gen_server}).
$0

5
erlang-mode/case Normal file
View File

@ -0,0 +1,5 @@
#name : case ... of ... end
# --
case $1 of
$0
end

4
erlang-mode/compile Normal file
View File

@ -0,0 +1,4 @@
#name : -compile(...).
# --
-compile([${1:export_all}]).
$0

4
erlang-mode/def Normal file
View File

@ -0,0 +1,4 @@
#name : -define(...,...).
# --
-define($1,$2).
$0

5
erlang-mode/exp Normal file
View File

@ -0,0 +1,5 @@
#name : -export([]).
#contributor : hitesh <hitesh.jasani@gmail.com>
# --
-export([${1:start/0}]).
$0

3
erlang-mode/fun Normal file
View File

@ -0,0 +1,3 @@
#name : fun (...) -> ... end
# --
fun ($1) -> $0 end

6
erlang-mode/if Normal file
View File

@ -0,0 +1,6 @@
#name : if ... -> ... ; true -> ... end
# --
if
$1 -> $2;
true -> $0
end

5
erlang-mode/ifdef Normal file
View File

@ -0,0 +1,5 @@
#name : -ifdef(...). ... -endif.
# --
-ifdef($1).
$0
-endif.

5
erlang-mode/ifndef Normal file
View File

@ -0,0 +1,5 @@
#name : -ifndef(...). ... -endif.
# --
-ifndef($1).
$0
-endif.

5
erlang-mode/imp Normal file
View File

@ -0,0 +1,5 @@
#name : -import([]).
#contributor : hitesh <hitesh.jasani@gmail.com>
# --
-import(${1:lists}, [${2:map/2, sum/1}]).
$0

4
erlang-mode/inc Normal file
View File

@ -0,0 +1,4 @@
#name : -include("...").
# --
-include("$1").
$0

4
erlang-mode/inc.lib Normal file
View File

@ -0,0 +1,4 @@
#name : -include_lib("...").
# --
-include_lib("$1").
$0

8
erlang-mode/loop Normal file
View File

@ -0,0 +1,8 @@
#name : loop(...) -> receive _ -> loop(...) end.
# --
${1:loop}($2) ->
receive
${3:_} ->
$1($2)
end.
$0

6
erlang-mode/mod Normal file
View File

@ -0,0 +1,6 @@
#name : -module().
#contributor : hitesh <hitesh.jasani@gmail.com>
# --
-module(${1:`(file-name-nondirectory
(file-name-sans-extension (or (buffer-file-name) (buffer-name))))`}).
$0

5
erlang-mode/rcv Normal file
View File

@ -0,0 +1,5 @@
#name : receive ... -> ... end
# --
receive
$1 -> $0
end

6
erlang-mode/rcv.after Normal file
View File

@ -0,0 +1,6 @@
#name : receive after ... -> ... end
# --
receive
after
$1 -> $0
end

4
erlang-mode/rec Normal file
View File

@ -0,0 +1,4 @@
#name : -record(...,{...}).
# --
-record($1,{$2}).
$0

7
erlang-mode/try Normal file
View File

@ -0,0 +1,7 @@
#name : try ... of ... catch after end
# --
try $1 of
$0
catch
after
end

4
erlang-mode/undef Normal file
View File

@ -0,0 +1,4 @@
#name : -undef(...).
# --
-undef($1).
$0

4
f90-mode/au Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : automatic
# --
automatic $0

4
f90-mode/bd Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : block data
# --
block data $0

4
f90-mode/c Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : continue
# --
continue $0

4
f90-mode/ch Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : character
# --
character $0

4
f90-mode/cx Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : complex
# --
complex $0

4
f90-mode/dc Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : double complex
# --
double complex $0

6
f90-mode/do Normal file
View File

@ -0,0 +1,6 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : do while (...) end do
# --
do while (${1:condition})
$0
end do

4
f90-mode/dp Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : double precision
# --
double precision $0

4
f90-mode/eq Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : equivalence
# --
equivalence $0

4
f90-mode/ib Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit byte
# --
implicit byte $0

4
f90-mode/ic Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit complex
# --
implicit complex $0

4
f90-mode/ich Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit character
# --
implicit character $0

6
f90-mode/if Normal file
View File

@ -0,0 +1,6 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : if then end if
# --
if ( ${1:condition} ) then
$0
end if

4
f90-mode/ii Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit integer
# --
implicit integer $0

4
f90-mode/il Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit logical
# --
implicit logical $0

4
f90-mode/in Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit none
# --
implicit none

4
f90-mode/inc Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : include
# --
include $0

4
f90-mode/intr Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : intrinsic
# --
intrinsic $0

4
f90-mode/ir Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : implicit real
# --
implicit real $0

4
f90-mode/l Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : logical
# --
logical $0

4
f90-mode/pa Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : parameter
# --
parameter $0

6
f90-mode/pr Normal file
View File

@ -0,0 +1,6 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : program ... end program ...
# --
program ${1:name}
$0
end program ${1:name}

4
f90-mode/re Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : read (*,*)
# --
read (${1:*},${2:*}) $0

4
f90-mode/st Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : structure
# --
structure $0

4
f90-mode/su Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : subroutine
# --
subroutine $0

4
f90-mode/wr Normal file
View File

@ -0,0 +1,4 @@
#contributor: Li Zhu <http://www.zhuli.name>
#name : write (*,*)
# --
write (${1:*},${2:*}) $0

6
html-mode/body Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <body>...</body>
# --
<body$1>
$0
</body>

4
html-mode/br Normal file
View File

@ -0,0 +1,4 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <br />
# --
<br />

6
html-mode/code Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <code>...</code>
# --
<code>
$0
</code>

6
html-mode/code.class Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <code class="...">...</code>
# --
<code class="$1">
$0
</code>

5
html-mode/dd Normal file
View File

@ -0,0 +1,5 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dd> ... </dd>
#group : list
# --
<dd>$1</dd>

3
html-mode/div Normal file
View File

@ -0,0 +1,3 @@
#name : <div...>...</div>
# --
<div${1: id="${2:some_id}"}${3: class="${4:some_class}"}>$0</div>

6
html-mode/div.class Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <div class="...">...</div>
# --
<div class="$1">
$0
</div>

6
html-mode/div.id Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <div id="...">...</div>
# --
<div id="$1">
$0
</div>

6
html-mode/div.id-class Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <div id="..." class="...">...</div>
# --
<div id="$1" class="$2">
$0
</div>

7
html-mode/dl Normal file
View File

@ -0,0 +1,7 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dl> ... </dl>
#group : list
# --
<dl>
$0
</dl>

7
html-mode/dl.id Normal file
View File

@ -0,0 +1,7 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dl> ... </dl>
#group : list
# --
<dl id="$1">
$0
</dl>

4
html-mode/doctype Normal file
View File

@ -0,0 +1,4 @@
#name : Doctype HTML 4.01 Strict
#group : meta
# --
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

4
html-mode/doctype.xhml1 Normal file
View File

@ -0,0 +1,4 @@
#name : DocType XHTML 1.0 frameset
#group : meta
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

View File

@ -0,0 +1,4 @@
#name : DocType XHTML 1.1
#group : meta
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

View File

@ -0,0 +1,4 @@
#name : DocType XHTML 1.0 Strict
#group : meta
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View File

@ -0,0 +1,4 @@
#name : DocType XHTML 1.0 Transitional
#group : meta
# --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

11
html-mode/dov Normal file
View File

@ -0,0 +1,11 @@
#name : <dov...>...</dov>
# --
a mirror up here $3
<dov ${1:id="${2:some_id and here comes another nested field: ${3:nested_shit}}"}>
$0
</dov>
<dov $1>
actually some other shit and $3
</dov>

5
html-mode/dt Normal file
View File

@ -0,0 +1,5 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dt> ... </dt>
#group : list
# --
<dt>$1</dt>

6
html-mode/form Normal file
View File

@ -0,0 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name :<form method="..." id="..." action="..."></form>
# --
<form method="$1" id="$2" action="$3">
$0
</form>

5
html-mode/h1 Normal file
View File

@ -0,0 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h1>...</h1>
#group : header
# --
<h1>$1</h1>

5
html-mode/h2 Normal file
View File

@ -0,0 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h2>...</h2>
#group : header
# --
<h2>$1</h2>

5
html-mode/h3 Normal file
View File

@ -0,0 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h3>...</h3>
#group : header
# --
<h3>$1</h3>

5
html-mode/h4 Normal file
View File

@ -0,0 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h4>...</h4>
#group : header
# --
<h4>$1</h4>

5
html-mode/h5 Normal file
View File

@ -0,0 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h5>...</h5>
#group : header
# --
<h5>$1</h5>

Some files were not shown because too many files have changed in this diff Show More