From 897eee81de8b3f6adf0165f50e95600a7b89c20c Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 4 Feb 2015 21:41:42 +0100 Subject: Standalone lisp and snippet repo --- .emacs | 30 +- .emacs.d/lisp/php-mode.el | 1536 +++++ .emacs.d/lisp/yasnippet.el | 5901 +++++++++++--------- .../mysnippets/text-mode/cc-mode/c++-mode/beginend | 3 - .../mysnippets/text-mode/cc-mode/c++-mode/class | 8 - .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/ns | 3 - .../mysnippets/text-mode/cc-mode/c++-mode/template | 3 - .../mysnippets/text-mode/cc-mode/c++-mode/using | 4 - .emacs.d/mysnippets/text-mode/cc-mode/c-mode/fopen | 3 - .../mysnippets/text-mode/cc-mode/c-mode/printf | 6 - .../text-mode/cc-mode/csharp-mode/attrib | 7 - .../text-mode/cc-mode/csharp-mode/attrib.1 | 21 - .../text-mode/cc-mode/csharp-mode/attrib.2 | 21 - .../mysnippets/text-mode/cc-mode/csharp-mode/class | 21 - .../text-mode/cc-mode/csharp-mode/comment | 6 - .../text-mode/cc-mode/csharp-mode/comment.1 | 4 - .../text-mode/cc-mode/csharp-mode/comment.2 | 4 - .../text-mode/cc-mode/csharp-mode/comment.3 | 4 - .../text-mode/cc-mode/csharp-mode/method | 10 - .../text-mode/cc-mode/csharp-mode/namespace | 7 - .../mysnippets/text-mode/cc-mode/csharp-mode/prop | 16 - .../text-mode/cc-mode/csharp-mode/region | 6 - .../mysnippets/text-mode/cc-mode/csharp-mode/using | 4 - .../text-mode/cc-mode/csharp-mode/using.1 | 4 - .../text-mode/cc-mode/csharp-mode/using.2 | 4 - .emacs.d/mysnippets/text-mode/cc-mode/do | 6 - .emacs.d/mysnippets/text-mode/cc-mode/for | 6 - .emacs.d/mysnippets/text-mode/cc-mode/if | 6 - .emacs.d/mysnippets/text-mode/cc-mode/inc | 3 - .emacs.d/mysnippets/text-mode/cc-mode/inc.1 | 3 - .emacs.d/mysnippets/text-mode/cc-mode/main | 7 - .../mysnippets/text-mode/cc-mode/objc-mode/prop | 13 - .emacs.d/mysnippets/text-mode/cc-mode/once | 8 - .emacs.d/mysnippets/text-mode/cc-mode/struct | 6 - .emacs.d/mysnippets/text-mode/css-mode/bg | 3 - .emacs.d/mysnippets/text-mode/css-mode/bg.1 | 3 - .emacs.d/mysnippets/text-mode/css-mode/bor | 3 - .emacs.d/mysnippets/text-mode/css-mode/cl | 4 - .emacs.d/mysnippets/text-mode/css-mode/disp.block | 4 - .emacs.d/mysnippets/text-mode/css-mode/disp.inline | 4 - .emacs.d/mysnippets/text-mode/css-mode/disp.none | 4 - .emacs.d/mysnippets/text-mode/css-mode/ff | 4 - .emacs.d/mysnippets/text-mode/css-mode/fs | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.bottom | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.left | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.mar | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.margin | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.right | 4 - .emacs.d/mysnippets/text-mode/css-mode/mar.top | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.bottom | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.left | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.pad | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.padding | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.right | 4 - .emacs.d/mysnippets/text-mode/css-mode/pad.top | 4 - .../mysnippets/text-mode/emacs-lisp-mode/.read_me | 11 - .../mysnippets/text-mode/emacs-lisp-mode/defun | 11 - .../text-mode/emacs-lisp-mode/dired.process_marked | 16 - .../text-mode/emacs-lisp-mode/file.process | 17 - .../text-mode/emacs-lisp-mode/file.read-lines | 17 - .../text-mode/emacs-lisp-mode/find-replace | 17 - .../text-mode/emacs-lisp-mode/grabstring | 4 - .../mysnippets/text-mode/emacs-lisp-mode/grabthing | 4 - .../text-mode/emacs-lisp-mode/traverse_dir | 6 - .../text-mode/emacs-lisp-mode/word-or-region | 27 - .emacs.d/mysnippets/text-mode/email | 3 - .emacs.d/mysnippets/text-mode/erlang-mode/after | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/begin | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/beh | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/case | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/compile | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/def | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/exp | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/fun | 3 - .emacs.d/mysnippets/text-mode/erlang-mode/if | 6 - .emacs.d/mysnippets/text-mode/erlang-mode/ifdef | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/ifndef | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/imp | 5 - .emacs.d/mysnippets/text-mode/erlang-mode/inc | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/inc.lib | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/loop | 8 - .emacs.d/mysnippets/text-mode/erlang-mode/mod | 6 - .emacs.d/mysnippets/text-mode/erlang-mode/rcv | 5 - .../mysnippets/text-mode/erlang-mode/rcv.after | 6 - .emacs.d/mysnippets/text-mode/erlang-mode/rec | 4 - .emacs.d/mysnippets/text-mode/erlang-mode/try | 7 - .emacs.d/mysnippets/text-mode/erlang-mode/undef | 4 - .emacs.d/mysnippets/text-mode/f90-mode/au | 4 - .emacs.d/mysnippets/text-mode/f90-mode/bd | 4 - .emacs.d/mysnippets/text-mode/f90-mode/c | 4 - .emacs.d/mysnippets/text-mode/f90-mode/ch | 4 - .emacs.d/mysnippets/text-mode/f90-mode/cx | 4 - .emacs.d/mysnippets/text-mode/f90-mode/dc | 4 - .emacs.d/mysnippets/text-mode/f90-mode/do | 6 - .emacs.d/mysnippets/text-mode/f90-mode/dp | 4 - .emacs.d/mysnippets/text-mode/f90-mode/eq | 4 - .emacs.d/mysnippets/text-mode/f90-mode/ib | 4 - .emacs.d/mysnippets/text-mode/f90-mode/ic | 4 - .emacs.d/mysnippets/text-mode/f90-mode/ich | 4 - .emacs.d/mysnippets/text-mode/f90-mode/if | 6 - .emacs.d/mysnippets/text-mode/f90-mode/ii | 4 - .emacs.d/mysnippets/text-mode/f90-mode/il | 4 - .emacs.d/mysnippets/text-mode/f90-mode/in | 4 - .emacs.d/mysnippets/text-mode/f90-mode/inc | 4 - .emacs.d/mysnippets/text-mode/f90-mode/intr | 4 - .emacs.d/mysnippets/text-mode/f90-mode/ir | 4 - .emacs.d/mysnippets/text-mode/f90-mode/l | 4 - .emacs.d/mysnippets/text-mode/f90-mode/pa | 4 - .emacs.d/mysnippets/text-mode/f90-mode/pr | 6 - .emacs.d/mysnippets/text-mode/f90-mode/re | 4 - .emacs.d/mysnippets/text-mode/f90-mode/st | 4 - .emacs.d/mysnippets/text-mode/f90-mode/su | 4 - .emacs.d/mysnippets/text-mode/f90-mode/wr | 4 - .emacs.d/mysnippets/text-mode/html-mode/body | 6 - .emacs.d/mysnippets/text-mode/html-mode/br | 4 - .emacs.d/mysnippets/text-mode/html-mode/code | 6 - .emacs.d/mysnippets/text-mode/html-mode/code.class | 6 - .emacs.d/mysnippets/text-mode/html-mode/dd | 5 - .emacs.d/mysnippets/text-mode/html-mode/div | 3 - .emacs.d/mysnippets/text-mode/html-mode/div.class | 6 - .emacs.d/mysnippets/text-mode/html-mode/div.id | 6 - .../mysnippets/text-mode/html-mode/div.id-class | 6 - .emacs.d/mysnippets/text-mode/html-mode/dl | 7 - .emacs.d/mysnippets/text-mode/html-mode/dl.id | 7 - .emacs.d/mysnippets/text-mode/html-mode/doctype | 4 - .../mysnippets/text-mode/html-mode/doctype.xhml1 | 4 - .../text-mode/html-mode/doctype.xhtml1_1 | 4 - .../text-mode/html-mode/doctype.xhtml1_strict | 4 - .../html-mode/doctype.xhtml1_transitional | 4 - .emacs.d/mysnippets/text-mode/html-mode/dov | 11 - .emacs.d/mysnippets/text-mode/html-mode/dt | 5 - .emacs.d/mysnippets/text-mode/html-mode/form | 6 - .emacs.d/mysnippets/text-mode/html-mode/h1 | 5 - .emacs.d/mysnippets/text-mode/html-mode/h2 | 5 - .emacs.d/mysnippets/text-mode/html-mode/h3 | 5 - .emacs.d/mysnippets/text-mode/html-mode/h4 | 5 - .emacs.d/mysnippets/text-mode/html-mode/h5 | 5 - .emacs.d/mysnippets/text-mode/html-mode/h6 | 5 - .emacs.d/mysnippets/text-mode/html-mode/head | 6 - .emacs.d/mysnippets/text-mode/html-mode/hr | 4 - .emacs.d/mysnippets/text-mode/html-mode/href | 4 - .emacs.d/mysnippets/text-mode/html-mode/html | 6 - .emacs.d/mysnippets/text-mode/html-mode/html.xmlns | 6 - .emacs.d/mysnippets/text-mode/html-mode/img | 4 - .emacs.d/mysnippets/text-mode/html-mode/input | 4 - .emacs.d/mysnippets/text-mode/html-mode/li | 5 - .emacs.d/mysnippets/text-mode/html-mode/li.class | 5 - .../mysnippets/text-mode/html-mode/link.stylesheet | 4 - .../text-mode/html-mode/link.stylesheet-ie | 6 - .emacs.d/mysnippets/text-mode/html-mode/mailto | 4 - .emacs.d/mysnippets/text-mode/html-mode/meta | 5 - .../mysnippets/text-mode/html-mode/meta.http-equiv | 5 - .emacs.d/mysnippets/text-mode/html-mode/ol | 7 - .emacs.d/mysnippets/text-mode/html-mode/ol.class | 7 - .emacs.d/mysnippets/text-mode/html-mode/ol.id | 7 - .emacs.d/mysnippets/text-mode/html-mode/p | 4 - .emacs.d/mysnippets/text-mode/html-mode/pre | 6 - .emacs.d/mysnippets/text-mode/html-mode/quote | 6 - .../text-mode/html-mode/script.javascript | 6 - .../text-mode/html-mode/script.javascript-src | 4 - .emacs.d/mysnippets/text-mode/html-mode/span | 4 - .emacs.d/mysnippets/text-mode/html-mode/span.class | 4 - .emacs.d/mysnippets/text-mode/html-mode/span.id | 4 - .emacs.d/mysnippets/text-mode/html-mode/style | 6 - .emacs.d/mysnippets/text-mode/html-mode/table | 7 - .emacs.d/mysnippets/text-mode/html-mode/td | 5 - .emacs.d/mysnippets/text-mode/html-mode/textarea | 4 - .emacs.d/mysnippets/text-mode/html-mode/th | 5 - .emacs.d/mysnippets/text-mode/html-mode/title | 4 - .emacs.d/mysnippets/text-mode/html-mode/tr | 7 - .emacs.d/mysnippets/text-mode/html-mode/ul | 7 - .emacs.d/mysnippets/text-mode/html-mode/ul.class | 7 - .emacs.d/mysnippets/text-mode/html-mode/ul.id | 7 - .emacs.d/mysnippets/text-mode/latex-mode/begin | 7 - .emacs.d/mysnippets/text-mode/markdown-mode/+ | 5 - .emacs.d/mysnippets/text-mode/markdown-mode/- | 5 - .emacs.d/mysnippets/text-mode/markdown-mode/_ | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/__ | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/` | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/h1.1 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/h1.2 | 7 - .emacs.d/mysnippets/text-mode/markdown-mode/h2.1 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/h2.2 | 7 - .emacs.d/mysnippets/text-mode/markdown-mode/h3 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/h4 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/h5 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/h6 | 6 - .emacs.d/mysnippets/text-mode/markdown-mode/hr.1 | 7 - .emacs.d/mysnippets/text-mode/markdown-mode/hr.2 | 7 - .emacs.d/mysnippets/text-mode/markdown-mode/img | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/link | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/ol | 5 - .emacs.d/mysnippets/text-mode/markdown-mode/rimg | 4 - .emacs.d/mysnippets/text-mode/markdown-mode/rlb | 5 - .emacs.d/mysnippets/text-mode/markdown-mode/rlink | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/body | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/br | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/code | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/div | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/doctype | 5 - .../text-mode/nxml-mode/doctype.xhtml1_strict | 5 - .../nxml-mode/doctype.xhtml1_transitional | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/form | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/h1 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/h2 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/h3 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/h4 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/h5 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/h6 | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/head | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/hr | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/href | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/html | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/img | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/input | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/li | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/link | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/meta | 5 - .emacs.d/mysnippets/text-mode/nxml-mode/name | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/ol | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/p | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/pre | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/quote | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/span | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/style | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/table | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/tag.1l | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/tag.2l | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/td | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/th | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/title | 4 - .emacs.d/mysnippets/text-mode/nxml-mode/tr | 6 - .emacs.d/mysnippets/text-mode/nxml-mode/ul | 6 - .emacs.d/mysnippets/text-mode/perl-mode/eval | 8 - .emacs.d/mysnippets/text-mode/perl-mode/for | 5 - .emacs.d/mysnippets/text-mode/perl-mode/fore | 5 - .emacs.d/mysnippets/text-mode/perl-mode/if | 5 - .emacs.d/mysnippets/text-mode/perl-mode/ife | 7 - .emacs.d/mysnippets/text-mode/perl-mode/ifee | 9 - .emacs.d/mysnippets/text-mode/perl-mode/sub | 5 - .emacs.d/mysnippets/text-mode/perl-mode/unless | 5 - .emacs.d/mysnippets/text-mode/perl-mode/while | 5 - .emacs.d/mysnippets/text-mode/perl-mode/xfore | 3 - .emacs.d/mysnippets/text-mode/perl-mode/xif | 3 - .emacs.d/mysnippets/text-mode/perl-mode/xunless | 3 - .emacs.d/mysnippets/text-mode/perl-mode/xwhile | 3 - .emacs.d/mysnippets/text-mode/php-mode/ife | 10 - .emacs.d/mysnippets/text-mode/php-mode/ppf | 6 - .emacs.d/mysnippets/text-mode/php-mode/ppg | 6 - .emacs.d/mysnippets/text-mode/php-mode/pps | 6 - .emacs.d/mysnippets/text-mode/python-mode/__ | 3 - .emacs.d/mysnippets/text-mode/python-mode/class | 54 - .emacs.d/mysnippets/text-mode/python-mode/def | 35 - .emacs.d/mysnippets/text-mode/python-mode/defm | 33 - .emacs.d/mysnippets/text-mode/python-mode/for | 4 - .emacs.d/mysnippets/text-mode/python-mode/ifmain | 4 - .emacs.d/mysnippets/text-mode/python-mode/mprop | 23 - .emacs.d/mysnippets/text-mode/python-mode/mpropg | 11 - .emacs.d/mysnippets/text-mode/python-mode/mpropsg | 17 - .emacs.d/mysnippets/text-mode/python-mode/prop | 15 - .emacs.d/mysnippets/text-mode/python-mode/propg | 9 - .emacs.d/mysnippets/text-mode/python-mode/propsg | 12 - .emacs.d/mysnippets/text-mode/python-mode/pscript | 12 - .emacs.d/mysnippets/text-mode/python-mode/while | 4 - .emacs.d/mysnippets/text-mode/rst-mode/chap | 6 - .emacs.d/mysnippets/text-mode/rst-mode/sec | 6 - .emacs.d/mysnippets/text-mode/rst-mode/tit | 7 - .emacs.d/mysnippets/text-mode/ruby-mode/# | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/=b | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/Comp | 8 - .emacs.d/mysnippets/text-mode/ruby-mode/all | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/am | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/any | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/app | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/bm | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/case | 7 - .emacs.d/mysnippets/text-mode/ruby-mode/cla | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/classify | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/cls | 13 - .emacs.d/mysnippets/text-mode/ruby-mode/collect | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/dee | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/deli | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/det | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/dow | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/ea | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/eac | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/eai | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/eav | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/eawi | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/forin | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/if | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/ife | 8 - .emacs.d/mysnippets/text-mode/ruby-mode/inject | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/mm | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/r | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/rb | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/reject | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/req | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/rreq | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/rw | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/select | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/tim | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/until | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/upt | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/w | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/when | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/while | 6 - .emacs.d/mysnippets/text-mode/ruby-mode/y | 4 - .emacs.d/mysnippets/text-mode/ruby-mode/zip | 4 - .emacs.d/mysnippets/text-mode/scala-mode/act | 10 - .emacs.d/mysnippets/text-mode/scala-mode/act.arg | 10 - .emacs.d/mysnippets/text-mode/scala-mode/actor | 10 - .emacs.d/mysnippets/text-mode/scala-mode/ano | 4 - .emacs.d/mysnippets/text-mode/scala-mode/app | 6 - .emacs.d/mysnippets/text-mode/scala-mode/arr.new | 4 - .../mysnippets/text-mode/scala-mode/arr.val-new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/asof | 4 - .emacs.d/mysnippets/text-mode/scala-mode/ass | 4 - .emacs.d/mysnippets/text-mode/scala-mode/ass.true | 4 - .emacs.d/mysnippets/text-mode/scala-mode/at.author | 4 - .emacs.d/mysnippets/text-mode/scala-mode/at.param | 4 - .emacs.d/mysnippets/text-mode/scala-mode/at.return | 4 - .../mysnippets/text-mode/scala-mode/at.version | 4 - .emacs.d/mysnippets/text-mode/scala-mode/bang | 4 - .emacs.d/mysnippets/text-mode/scala-mode/case | 4 - .../mysnippets/text-mode/scala-mode/case.match-all | 4 - .emacs.d/mysnippets/text-mode/scala-mode/cast | 4 - .emacs.d/mysnippets/text-mode/scala-mode/cc | 4 - .emacs.d/mysnippets/text-mode/scala-mode/cl | 6 - .emacs.d/mysnippets/text-mode/scala-mode/cl.abs | 6 - .../mysnippets/text-mode/scala-mode/cl.abs-arg | 6 - .emacs.d/mysnippets/text-mode/scala-mode/cl.arg | 6 - .emacs.d/mysnippets/text-mode/scala-mode/clof | 4 - .emacs.d/mysnippets/text-mode/scala-mode/co | 4 - .emacs.d/mysnippets/text-mode/scala-mode/cons | 4 - .emacs.d/mysnippets/text-mode/scala-mode/cons.nil | 4 - .emacs.d/mysnippets/text-mode/scala-mode/def.arg | 4 - .../mysnippets/text-mode/scala-mode/def.arg-body | 6 - .../mysnippets/text-mode/scala-mode/def.arg-ret | 4 - .../text-mode/scala-mode/def.arg-ret-body | 6 - .emacs.d/mysnippets/text-mode/scala-mode/def.body | 6 - .emacs.d/mysnippets/text-mode/scala-mode/def.ret | 4 - .../mysnippets/text-mode/scala-mode/def.ret-body | 6 - .../mysnippets/text-mode/scala-mode/def.simple | 4 - .emacs.d/mysnippets/text-mode/scala-mode/doc.class | 8 - .emacs.d/mysnippets/text-mode/scala-mode/doc.def | 6 - .emacs.d/mysnippets/text-mode/scala-mode/doc.file | 9 - .../mysnippets/text-mode/scala-mode/doc.file-scala | 16 - .../text-mode/scala-mode/doc.file-scala-api | 16 - .../mysnippets/text-mode/scala-mode/doc.scaladoc | 7 - .emacs.d/mysnippets/text-mode/scala-mode/expect | 6 - .emacs.d/mysnippets/text-mode/scala-mode/ext | 4 - .../mysnippets/text-mode/scala-mode/for.extract | 4 - .emacs.d/mysnippets/text-mode/scala-mode/for.if | 6 - .emacs.d/mysnippets/text-mode/scala-mode/for.loop | 6 - .emacs.d/mysnippets/text-mode/scala-mode/for.multi | 9 - .emacs.d/mysnippets/text-mode/scala-mode/foreach | 4 - .emacs.d/mysnippets/text-mode/scala-mode/hmap.new | 4 - .../mysnippets/text-mode/scala-mode/hmap.val-new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/hset.new | 4 - .../mysnippets/text-mode/scala-mode/hset.val-new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/if | 6 - .emacs.d/mysnippets/text-mode/scala-mode/if.else | 8 - .emacs.d/mysnippets/text-mode/scala-mode/imp | 4 - .emacs.d/mysnippets/text-mode/scala-mode/intercept | 6 - .emacs.d/mysnippets/text-mode/scala-mode/isof | 4 - .emacs.d/mysnippets/text-mode/scala-mode/ls.new | 4 - .../mysnippets/text-mode/scala-mode/ls.val-new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/main | 6 - .emacs.d/mysnippets/text-mode/scala-mode/map | 4 - .emacs.d/mysnippets/text-mode/scala-mode/map.new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/match | 6 - .emacs.d/mysnippets/text-mode/scala-mode/match.can | 11 - .../mysnippets/text-mode/scala-mode/match.option | 8 - .emacs.d/mysnippets/text-mode/scala-mode/mix | 6 - .emacs.d/mysnippets/text-mode/scala-mode/ob | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pac | 4 - .../mysnippets/text-mode/scala-mode/pr.newline | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pr.simple | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pr.string | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pr.trace | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pri | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pri.param | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pro | 4 - .emacs.d/mysnippets/text-mode/scala-mode/pro.param | 4 - .emacs.d/mysnippets/text-mode/scala-mode/suite | 8 - .emacs.d/mysnippets/text-mode/scala-mode/test | 7 - .emacs.d/mysnippets/text-mode/scala-mode/throw | 4 - .emacs.d/mysnippets/text-mode/scala-mode/tr | 6 - .emacs.d/mysnippets/text-mode/scala-mode/tr.ext | 6 - .../mysnippets/text-mode/scala-mode/tr.ext-with | 6 - .emacs.d/mysnippets/text-mode/scala-mode/tr.with | 6 - .emacs.d/mysnippets/text-mode/scala-mode/try | 9 - .../text-mode/scala-mode/try.catch-finally | 11 - .../mysnippets/text-mode/scala-mode/try.finally | 8 - .emacs.d/mysnippets/text-mode/scala-mode/tup.arrow | 4 - .emacs.d/mysnippets/text-mode/scala-mode/tup.paren | 4 - .emacs.d/mysnippets/text-mode/scala-mode/val | 4 - .emacs.d/mysnippets/text-mode/scala-mode/val.new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/val.ret | 4 - .emacs.d/mysnippets/text-mode/scala-mode/var | 4 - .emacs.d/mysnippets/text-mode/scala-mode/var.new | 4 - .emacs.d/mysnippets/text-mode/scala-mode/var.ret | 4 - .emacs.d/mysnippets/text-mode/scala-mode/whi | 6 - .emacs.d/mysnippets/text-mode/scala-mode/with | 4 - .emacs.d/mysnippets/text-mode/snippet-mode/field | 5 - .emacs.d/mysnippets/text-mode/snippet-mode/mirror | 5 - .emacs.d/mysnippets/text-mode/snippet-mode/vars | 9 - .emacs.d/mysnippets/text-mode/sql-mode/column | 4 - .emacs.d/mysnippets/text-mode/sql-mode/constraint | 4 - .../mysnippets/text-mode/sql-mode/constraint.1 | 4 - .emacs.d/mysnippets/text-mode/sql-mode/create | 10 - .emacs.d/mysnippets/text-mode/sql-mode/create.1 | 12 - .emacs.d/mysnippets/text-mode/sql-mode/references | 4 - .emacs.d/mysnippets/text-mode/time | 3 - .emacs.d/snippets/.nosearch | 1 + .emacs.d/snippets/c-mode/.yas-parents | 1 + .emacs.d/snippets/c-mode/assert | 6 + .emacs.d/snippets/c-mode/compile | 5 + .emacs.d/snippets/c-mode/define | 5 + .emacs.d/snippets/c-mode/fopen | 4 + .emacs.d/snippets/c-mode/malloc | 6 + .emacs.d/snippets/c-mode/packed | 5 + .emacs.d/snippets/c-mode/printf | 5 + .emacs.d/snippets/c-mode/stdio | 5 + .emacs.d/snippets/c-mode/stdlib | 5 + .emacs.d/snippets/c-mode/string | 5 + .emacs.d/snippets/c-mode/switch | 11 + .emacs.d/snippets/c-mode/union | 7 + .emacs.d/snippets/c-mode/unistd | 5 + .emacs.d/snippets/python-mode/.yas-parents | 1 + .emacs.d/snippets/python-mode/.yas-setup.el | 22 + .emacs.d/snippets/python-mode/__getitem__ | 7 + .emacs.d/snippets/python-mode/__setitem__ | 7 + .emacs.d/snippets/python-mode/arg | 7 + .emacs.d/snippets/python-mode/classmethod | 10 + .emacs.d/snippets/python-mode/cls | 7 + .emacs.d/snippets/python-mode/dec | 14 + .emacs.d/snippets/python-mode/deftest | 7 + .emacs.d/snippets/python-mode/doc | 6 + .emacs.d/snippets/python-mode/eq | 7 + .emacs.d/snippets/python-mode/for | 6 + .emacs.d/snippets/python-mode/from | 6 + .emacs.d/snippets/python-mode/function | 7 + .emacs.d/snippets/python-mode/function_docstring | 10 + .emacs.d/snippets/python-mode/ife | 9 + .emacs.d/snippets/python-mode/ifmain | 6 + .emacs.d/snippets/python-mode/import | 7 + .emacs.d/snippets/python-mode/init_docstring | 10 + .emacs.d/snippets/python-mode/lambda | 5 + .emacs.d/snippets/python-mode/list | 7 + .emacs.d/snippets/python-mode/method | 7 + .emacs.d/snippets/python-mode/method_docstring | 10 + .emacs.d/snippets/python-mode/not_impl | 5 + .emacs.d/snippets/python-mode/parse_args | 9 + .emacs.d/snippets/python-mode/parser | 7 + .emacs.d/snippets/python-mode/print | 5 + .emacs.d/snippets/python-mode/reg | 7 + .emacs.d/snippets/python-mode/repr | 7 + .emacs.d/snippets/python-mode/return | 5 + .emacs.d/snippets/python-mode/script | 13 + .emacs.d/snippets/python-mode/self | 6 + .emacs.d/snippets/python-mode/self_without_dot | 6 + .emacs.d/snippets/python-mode/selfassign | 6 + .emacs.d/snippets/python-mode/static | 6 + .emacs.d/snippets/python-mode/str | 7 + .emacs.d/snippets/python-mode/try | 8 + .emacs.d/snippets/python-mode/unicode | 7 + .emacs.d/snippets/python-mode/utf8 | 5 + .emacs.d/snippets/python-mode/while | 7 + .emacs.d/snippets/python-mode/with | 7 + 471 files changed, 5353 insertions(+), 4927 deletions(-) create mode 100644 .emacs.d/lisp/php-mode.el delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/beginend delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/class delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/ns delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/template delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c++-mode/using delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c-mode/fopen delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/c-mode/printf delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.1 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.2 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/class delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.1 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.2 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.3 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/method delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/namespace delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/prop delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/region delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.1 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.2 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/do delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/for delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/inc delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/inc.1 delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/main delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/objc-mode/prop delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/once delete mode 100644 .emacs.d/mysnippets/text-mode/cc-mode/struct delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/bg delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/bg.1 delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/bor delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/cl delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/disp.block delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/disp.inline delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/disp.none delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/ff delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/fs delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.bottom delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.left delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.mar delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.margin delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.right delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/mar.top delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.bottom delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.left delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.pad delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.padding delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.right delete mode 100644 .emacs.d/mysnippets/text-mode/css-mode/pad.top delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/.read_me delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/defun delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/dired.process_marked delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.process delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabstring delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabthing delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/traverse_dir delete mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/word-or-region delete mode 100644 .emacs.d/mysnippets/text-mode/email delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/after delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/begin delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/beh delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/case delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/compile delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/def delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/exp delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/fun delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/ifdef delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/ifndef delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/imp delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/inc delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/inc.lib delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/loop delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/mod delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/rcv delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/rcv.after delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/rec delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/try delete mode 100644 .emacs.d/mysnippets/text-mode/erlang-mode/undef delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/au delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/bd delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/c delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ch delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/cx delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/dc delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/do delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/dp delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/eq delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ib delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ic delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ich delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ii delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/il delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/in delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/inc delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/intr delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/ir delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/l delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/pa delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/pr delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/re delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/st delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/su delete mode 100644 .emacs.d/mysnippets/text-mode/f90-mode/wr delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/body delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/br delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/code delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/code.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/dd delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/div delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/div.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/div.id delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/div.id-class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/dl delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/dl.id delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/doctype delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/doctype.xhml1 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_1 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_strict delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_transitional delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/dov delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/dt delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/form delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h1 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h2 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h3 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h4 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h5 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/h6 delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/head delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/hr delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/href delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/html delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/html.xmlns delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/img delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/input delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/li delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/li.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/link.stylesheet delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/link.stylesheet-ie delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/mailto delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/meta delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/meta.http-equiv delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ol delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ol.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ol.id delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/p delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/pre delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/quote delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/script.javascript delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/script.javascript-src delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/span delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/span.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/span.id delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/style delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/table delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/td delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/textarea delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/th delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/title delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/tr delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ul delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ul.class delete mode 100644 .emacs.d/mysnippets/text-mode/html-mode/ul.id delete mode 100644 .emacs.d/mysnippets/text-mode/latex-mode/begin delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/+ delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/- delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/_ delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/__ delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/` delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h1.1 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h1.2 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h2.1 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h2.2 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h3 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h4 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h5 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/h6 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/hr.1 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/hr.2 delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/img delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/link delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/ol delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/rimg delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/rlb delete mode 100644 .emacs.d/mysnippets/text-mode/markdown-mode/rlink delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/body delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/br delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/code delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/div delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/doctype delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_strict delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_transitional delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/form delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h1 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h2 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h3 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h4 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h5 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/h6 delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/head delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/hr delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/href delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/html delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/img delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/input delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/li delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/link delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/meta delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/name delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/ol delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/p delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/pre delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/quote delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/span delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/style delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/table delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/tag.1l delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/tag.2l delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/td delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/th delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/title delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/tr delete mode 100644 .emacs.d/mysnippets/text-mode/nxml-mode/ul delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/eval delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/for delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/fore delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/ife delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/ifee delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/sub delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/unless delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/while delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/xfore delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/xif delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/xunless delete mode 100644 .emacs.d/mysnippets/text-mode/perl-mode/xwhile delete mode 100644 .emacs.d/mysnippets/text-mode/php-mode/ife delete mode 100644 .emacs.d/mysnippets/text-mode/php-mode/ppf delete mode 100644 .emacs.d/mysnippets/text-mode/php-mode/ppg delete mode 100644 .emacs.d/mysnippets/text-mode/php-mode/pps delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/__ delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/class delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/def delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/defm delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/for delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/ifmain delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/mprop delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/mpropg delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/mpropsg delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/prop delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/propg delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/propsg delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/pscript delete mode 100644 .emacs.d/mysnippets/text-mode/python-mode/while delete mode 100644 .emacs.d/mysnippets/text-mode/rst-mode/chap delete mode 100644 .emacs.d/mysnippets/text-mode/rst-mode/sec delete mode 100644 .emacs.d/mysnippets/text-mode/rst-mode/tit delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/# delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/=b delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/Comp delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/all delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/am delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/any delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/app delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/bm delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/case delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/cla delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/classify delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/cls delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/collect delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/dee delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/deli delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/det delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/dow delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/ea delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/eac delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/eai delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/eav delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/eawi delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/forin delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/ife delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/inject delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/mm delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/r delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/rb delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/reject delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/req delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/rreq delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/rw delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/select delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/tim delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/until delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/upt delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/w delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/when delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/while delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/y delete mode 100644 .emacs.d/mysnippets/text-mode/ruby-mode/zip delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/act delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/act.arg delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/actor delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ano delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/app delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/arr.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/arr.val-new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/asof delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ass delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ass.true delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/at.author delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/at.param delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/at.return delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/at.version delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/bang delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/case delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/case.match-all delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cast delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cc delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cl delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cl.abs delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cl.abs-arg delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cl.arg delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/clof delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/co delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cons delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/cons.nil delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.arg delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.arg-body delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret-body delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.body delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.ret delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.ret-body delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/def.simple delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.class delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.def delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.file delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala-api delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/doc.scaladoc delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/expect delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ext delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/for.extract delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/for.if delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/for.loop delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/for.multi delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/foreach delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/hmap.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/hmap.val-new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/hset.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/hset.val-new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/if delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/if.else delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/imp delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/intercept delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/isof delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ls.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ls.val-new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/main delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/map delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/map.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/match delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/match.can delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/match.option delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/mix delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/ob delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pac delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pr.newline delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pr.simple delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pr.string delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pr.trace delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pri delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pri.param delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pro delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/pro.param delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/suite delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/test delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/throw delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tr delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tr.ext delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tr.ext-with delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tr.with delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/try delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/try.catch-finally delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/try.finally delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tup.arrow delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/tup.paren delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/val delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/val.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/val.ret delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/var delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/var.new delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/var.ret delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/whi delete mode 100644 .emacs.d/mysnippets/text-mode/scala-mode/with delete mode 100644 .emacs.d/mysnippets/text-mode/snippet-mode/field delete mode 100644 .emacs.d/mysnippets/text-mode/snippet-mode/mirror delete mode 100644 .emacs.d/mysnippets/text-mode/snippet-mode/vars delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/column delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/constraint delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/constraint.1 delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/create delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/create.1 delete mode 100644 .emacs.d/mysnippets/text-mode/sql-mode/references delete mode 100644 .emacs.d/mysnippets/text-mode/time create mode 100644 .emacs.d/snippets/.nosearch create mode 100644 .emacs.d/snippets/c-mode/.yas-parents create mode 100644 .emacs.d/snippets/c-mode/assert create mode 100644 .emacs.d/snippets/c-mode/compile create mode 100644 .emacs.d/snippets/c-mode/define create mode 100644 .emacs.d/snippets/c-mode/fopen create mode 100644 .emacs.d/snippets/c-mode/malloc create mode 100644 .emacs.d/snippets/c-mode/packed create mode 100644 .emacs.d/snippets/c-mode/printf create mode 100644 .emacs.d/snippets/c-mode/stdio create mode 100644 .emacs.d/snippets/c-mode/stdlib create mode 100644 .emacs.d/snippets/c-mode/string create mode 100644 .emacs.d/snippets/c-mode/switch create mode 100644 .emacs.d/snippets/c-mode/union create mode 100644 .emacs.d/snippets/c-mode/unistd create mode 100644 .emacs.d/snippets/python-mode/.yas-parents create mode 100644 .emacs.d/snippets/python-mode/.yas-setup.el create mode 100644 .emacs.d/snippets/python-mode/__getitem__ create mode 100644 .emacs.d/snippets/python-mode/__setitem__ create mode 100644 .emacs.d/snippets/python-mode/arg create mode 100644 .emacs.d/snippets/python-mode/classmethod create mode 100644 .emacs.d/snippets/python-mode/cls create mode 100644 .emacs.d/snippets/python-mode/dec create mode 100644 .emacs.d/snippets/python-mode/deftest create mode 100644 .emacs.d/snippets/python-mode/doc create mode 100644 .emacs.d/snippets/python-mode/eq create mode 100644 .emacs.d/snippets/python-mode/for create mode 100644 .emacs.d/snippets/python-mode/from create mode 100644 .emacs.d/snippets/python-mode/function create mode 100644 .emacs.d/snippets/python-mode/function_docstring create mode 100644 .emacs.d/snippets/python-mode/ife create mode 100644 .emacs.d/snippets/python-mode/ifmain create mode 100644 .emacs.d/snippets/python-mode/import create mode 100644 .emacs.d/snippets/python-mode/init_docstring create mode 100644 .emacs.d/snippets/python-mode/lambda create mode 100644 .emacs.d/snippets/python-mode/list create mode 100644 .emacs.d/snippets/python-mode/method create mode 100644 .emacs.d/snippets/python-mode/method_docstring create mode 100644 .emacs.d/snippets/python-mode/not_impl create mode 100644 .emacs.d/snippets/python-mode/parse_args create mode 100644 .emacs.d/snippets/python-mode/parser create mode 100644 .emacs.d/snippets/python-mode/print create mode 100644 .emacs.d/snippets/python-mode/reg create mode 100644 .emacs.d/snippets/python-mode/repr create mode 100644 .emacs.d/snippets/python-mode/return create mode 100644 .emacs.d/snippets/python-mode/script create mode 100644 .emacs.d/snippets/python-mode/self create mode 100644 .emacs.d/snippets/python-mode/self_without_dot create mode 100644 .emacs.d/snippets/python-mode/selfassign create mode 100644 .emacs.d/snippets/python-mode/static create mode 100644 .emacs.d/snippets/python-mode/str create mode 100644 .emacs.d/snippets/python-mode/try create mode 100644 .emacs.d/snippets/python-mode/unicode create mode 100644 .emacs.d/snippets/python-mode/utf8 create mode 100644 .emacs.d/snippets/python-mode/while create mode 100644 .emacs.d/snippets/python-mode/with diff --git a/.emacs b/.emacs index 3f7c28b..5ab06e9 100644 --- a/.emacs +++ b/.emacs @@ -15,6 +15,10 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. (custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. '(font-lock-comment-face ((nil (:foreground "red"))))) ;;(setq require-final-newline t) @@ -32,6 +36,8 @@ ;; Various (setq auto-save-default nil) (setq make-backup-files nil) +(setq display-time-24hr-format t) +(display-time-mode 1) ;; UTF-8 support (legacy workaround for Ubuntu) (set-default-coding-systems 'utf-8) @@ -47,24 +53,26 @@ ;; Default coding style (setq c-default-style "bsd") -;; yasnippet -(yas/initialize) -;; (setq yas/root-directory '("~/.emacs.d/mysnippets" -;; "/usr/share/emacs/site-lisp/yasnippet/snippets")) -;; (mapc 'yas/load-directory yas/root-directory) -(yas/load-directory "~/.emacs.d/mysnippets") +;; Don't attempt to guess the Python-indent +(setq python-indent-guess-indent-offset nil) -;; Python stuff +;; Custom plugins +(add-to-list 'load-path "~/.emacs.d/lisp/") -;; Don't attempt to guess the indent -(setq python-indent-guess-indent-offset nil) +;;PHP +(autoload 'php-mode "php-mode" "Mode for editing PHP source files") +(add-to-list 'auto-mode-alist '("\\.\\(inc\\|php[s34]?\\)" . php-mode)) -;; (require 'pymacs) +;; yasnippet +(require 'yasnippet) +(yas-global-mode 1) +(yas/load-directory "~/.emacs.d/snippets") + +;; Python stuff ;; (pymacs-load "ropemacs" "rope-") ;; (setq ropemacs-enable-autoimport t) - ;; CUA mode ;;(cua-mode t) ;;(setq cua-auto-tabify-rectangles nil) diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el new file mode 100644 index 0000000..1841c4b --- /dev/null +++ b/.emacs.d/lisp/php-mode.el @@ -0,0 +1,1536 @@ +;;; php-mode.el --- Major mode for editing PHP code + +;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad +;; 2008 Aaron S. Hawley +;; 2011, 2012, 2013, 2014, 2015 Eric James Michael Ritz + +;;; Author: Eric James Michael Ritz +;;; URL: https://github.com/ejmr/php-mode +;;; Version: 1.15.3 + +(defconst php-mode-version-number "1.15.3" + "PHP Mode version number.") + +(defconst php-mode-modified "2015-01-31" + "PHP Mode build date.") + +;;; License + +;; This file is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this file; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Usage + +;; Put this file in your Emacs lisp path (eg. site-lisp) and add to +;; your .emacs file: +;; +;; (require 'php-mode) + +;; To use abbrev-mode, add lines like this: +;; (add-hook 'php-mode-hook +;; '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends"))) + +;; To make php-mode compatible with html-mode, see http://php-mode.sf.net + +;; Many options available under Help:Customize +;; Options specific to php-mode are in +;; Programming/Languages/Php +;; Since it inherits much functionality from c-mode, look there too +;; Programming/Languages/C + +;;; Commentary: + +;; PHP mode is a major mode for editing PHP source code. It's an +;; extension of C mode; thus it inherits all C mode's navigation +;; functionality. But it colors according to the PHP grammar and +;; indents according to the PEAR coding guidelines. It also includes +;; a couple handy IDE-type features such as documentation search and a +;; source and class browser. + +;;; Code: + +(require 'cc-mode) +(eval-when-compile + (require 'cc-langs) + (require 'cc-fonts)) + +;; Boilerplate from other `cc-mode' derived modes. See +;; http://cc-mode.sourceforge.net/derived-mode-ex.el for details on how this all +;; fits together. +(eval-and-compile + (c-add-language 'php-mode 'java-mode)) + +(require 'font-lock) +(require 'add-log) +(require 'custom) +(require 'flymake) +(require 'etags) +(require 'speedbar) +(eval-when-compile + (unless (require 'cl-lib nil t) + (require 'cl)) + (require 'regexp-opt) + (defvar c-vsemi-status-unknown-p) + (defvar syntax-propertize-via-font-lock)) + +;; Work around emacs bug#18845, cc-mode expects cl to be loaded +;; while php-mode only uses cl-lib (without compatibility aliases) +(eval-when-compile + (if (and (= emacs-major-version 24) (= emacs-minor-version 4)) + (require 'cl))) + +;; Use the recommended cl functions in php-mode but alias them to the +;; old names when we detect emacs < 24.3 +(if (and (= emacs-major-version 24) (< emacs-minor-version 3)) + (progn + (unless (fboundp 'cl-flet) + (defalias 'cl-flet 'flet)) + (unless (fboundp 'cl-set-difference) + (defalias 'cl-set-difference 'set-difference)))) + + +;; Local variables +;;;###autoload +(defgroup php nil + "Major mode `php-mode' for editing PHP code." + :prefix "php-" + :group 'languages + :link '(url-link :tag "Official Site" "https://github.com/ejmr/php-mode") + :link '(url-link :tag "PHP Mode Wiki" "https://github.com/ejmr/php-mode/wiki")) + +(defcustom php-executable "/usr/bin/php" + "The location of the PHP executable." + :type 'string + :group 'php) + +(defcustom php-default-face 'default + "Default face in `php-mode' buffers." + :type 'face + :group 'php) + +(defcustom php-speedbar-config t + "When set to true automatically configures Speedbar to observe PHP files. +Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\)\"" + :type 'boolean + :set (lambda (sym val) + (set-default sym val) + (when val + (speedbar-add-supported-extension + "\\.\\(inc\\|php[s345]?\\|phtml\\)"))) + :group 'php) + +(defcustom php-mode-speedbar-open nil + "Normally `php-mode' starts with the speedbar closed. +Turning this on will open it whenever `php-mode' is loaded." + :type 'boolean + :set (lambda (sym val) + (set-default sym val) + (when val + (speedbar 1))) + :group 'php) + +(defcustom php-template-compatibility t + "Should detect presence of html tags." + :type 'boolean + :group 'php) + +(defun php-mode-extra-constants-create-regexp(kwds) + "Create regexp for the list of extra constant keywords KWDS." + (concat "[^_$]?\\<\\(" + (regexp-opt + (append kwds + (when (boundp 'web-mode-extra-php-constants) web-mode-extra-php-constants))) + "\\)\\>[^_]?")) + +(defun php-mode-extra-constants-set(sym value) + "Apply the list of extra constant keywords VALUE. + +This function is called when the custom variable php-extra-constants +is updated. The web-mode-extra-constants list is appended to the list +of constants when set." + ;; remove old keywords + (when (boundp 'php-extra-constants) + (font-lock-remove-keywords + 'php-mode `((,(php-mode-extra-constants-create-regexp php-extra-constants) 1 font-lock-constant-face)))) + ;; add new keywords + (when value + (font-lock-add-keywords + 'php-mode `((,(php-mode-extra-constants-create-regexp value) 1 font-lock-constant-face)))) + (set sym value)) + +(defcustom php-lineup-cascaded-calls nil + "Indent chained method calls to the previous line" + :type 'boolean + :group 'php) + +;;;###autoload +(defcustom php-extra-constants '() + "A list of additional strings to treat as PHP constants." + :type 'list + :set 'php-mode-extra-constants-set + :group 'php) + +(defun php-create-regexp-for-method (visibility) + "Make a regular expression for methods with the given VISIBILITY. + +VISIBILITY must be a string that names the visibility for a PHP +method, e.g. 'public'. The parameter VISIBILITY can itself also +be a regular expression. + +The regular expression this function returns will check for other +keywords that can appear in method signatures, e.g. 'final' and +'static'. The regular expression will have one capture group +which will be the name of the method." + (concat + ;; Initial space with possible 'abstract' or 'final' keywords + "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?" + ;; 'static' keyword may come either before or after visibility + "\\(?:" visibility "\\(?:\\s-+static\\)?\\|\\(?:static\\s-+\\)?" visibility "\\)\\s-+" + ;; Make sure 'function' comes next with some space after + "function\\s-+" + ;; Capture the name as the first group and the regexp and make sure + ;; by the end we see the opening parenthesis for the parameters. + "\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(")) + +(defun php-create-regexp-for-classlike (type) + "Accepts a `type' of a 'classlike' object as a string, such as +'class' or 'interface', and returns a regexp as a string which +can be used to match against definitions for that classlike." + (concat + ;; First see if 'abstract' or 'final' appear, although really these + ;; are not valid for all values of `type' that the function + ;; accepts. + "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?" + ;; The classlike type + type + ;; Its name, which is the first captured group in the regexp. We + ;; allow backslashes in the name to handle namespaces, but again + ;; this is not necessarily correct for all values of `type'. + "\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)")) + +(defvar php-imenu-generic-expression + `(("Namespaces" + ,(php-create-regexp-for-classlike "namespace") 1) + ("Classes" + ,(php-create-regexp-for-classlike "class") 1) + ("Interfaces" + ,(php-create-regexp-for-classlike "interface") 1) + ("Traits" + ,(php-create-regexp-for-classlike "trait") 1) + ("All Methods" + ,(php-create-regexp-for-method "\\(?:\\sw\\|\\s_\\)+") 1) + ("Private Methods" + ,(php-create-regexp-for-method "private") 1) + ("Protected Methods" + ,(php-create-regexp-for-method "protected") 1) + ("Public Methods" + ,(php-create-regexp-for-method "public") 1) + ("Anonymous Functions" + "\\<\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*=\\s-*function\\s-*(" 1) + ("Named Functions" + "^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1)) + "Imenu generic expression for PHP Mode. See `imenu-generic-expression'.") + +(defcustom php-manual-url "http://www.php.net/manual/en/" + "URL at which to find PHP manual. +You can replace \"en\" with your ISO language code." + :type 'string + :group 'php) + +(defcustom php-search-url "http://www.php.net/" + "URL at which to search for documentation on a word." + :type 'string + :group 'php) + +(defcustom php-completion-file "" + "Path to the file which contains the function names known to PHP." + :type 'string + :group 'php) + +(defcustom php-manual-path "" + "Path to the directory which contains the PHP manual." + :type 'string + :group 'php) + +;;;###autoload +(add-to-list 'interpreter-mode-alist (cons "php" 'php-mode)) + +(defcustom php-mode-hook nil + "List of functions to be executed on entry to `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-pear-hook nil + "Hook called when a PHP PEAR file is opened with `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-drupal-hook nil + "Hook called when a Drupal file is opened with `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-wordpress-hook nil + "Hook called when a WordPress file is opened with `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-symfony2-hook nil + "Hook called when a Symfony2 file is opened with `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-psr2-hook nil + "Hook called when a PSR-2 file is opened with `php-mode'." + :type 'hook + :group 'php) + +(defcustom php-mode-force-pear nil + "Normally PEAR coding rules are enforced only when the filename contains \"PEAR.\" +Turning this on will force PEAR rules on all PHP files." + :type 'boolean + :group 'php) + +(defcustom php-mode-warn-if-mumamo-off t + "Warn once per buffer if you try to indent a buffer without +mumamo-mode turned on. Detects if there are any HTML tags in the +buffer before warning, but this is is not very smart; e.g. if you +have any tags inside a PHP string, it will be fooled." + :type '(choice (const :tag "Warg" t) (const "Don't warn" nil)) + :group 'php) + +(defcustom php-mode-coding-style 'pear + "Select default coding style to use with php-mode. +This variable can take one of the following symbol values: + +`Default' - use a reasonable default style for PHP. + +`PEAR' - use coding styles preferred for PEAR code and modules. + +`Drupal' - use coding styles preferred for working with Drupal projects. + +`WordPress' - use coding styles preferred for working with WordPress projects. + +`Symfony2' - use coding styles preferred for working with Symfony2 projects. + +`PSR-2' - use coding styles preferred for working with projects using PSR-2 standards." + :type '(choice (const :tag "Default" default) + (const :tag "PEAR" pear) + (const :tag "Drupal" drupal) + (const :tag "WordPress" wordpress) + (const :tag "Symfony2" symfony2) + (const :tag "PSR-2" psr2)) + :group 'php + :set 'php-mode-custom-coding-style-set + :initialize 'custom-initialize-default) + +(defun php-mode-custom-coding-style-set (sym value) + (when (eq major-mode 'php-mode) + (set sym value) + (set-default sym value) + (cond ((eq value 'pear) + (php-enable-pear-coding-style)) + ((eq value 'default) + (php-enable-default-coding-style)) + ((eq value 'drupal) + (php-enable-drupal-coding-style)) + ((eq value 'wordpress) + (php-enable-wordpress-coding-style)) + ((eq value 'symfony2) + (php-enable-symfony2-coding-style)) + ((eq value 'psr2) + (php-enable-psr2-coding-style))))) + +(defun php-mode-version () + "Display string describing the version of PHP mode." + (interactive) + (message "PHP mode %s of %s" + php-mode-version-number php-mode-modified)) + +(defvar php-mode-map + (let ((map (make-sparse-keymap))) + ;; (define-key map [menu-bar php] + ;; (cons "PHP" (make-sparse-keymap "PHP"))) + + ;; (define-key map [menu-bar php complete-function] + ;; '("Complete function name" . php-complete-function)) + ;; (define-key map [menu-bar php browse-manual] + ;; '("Browse manual" . php-browse-manual)) + ;; (define-key map [menu-bar php search-documentation] + ;; '("Search documentation" . php-search-documentation)) + + ;; By default PHP mode binds C-M-h to c-mark-function, which it + ;; inherits from cc-mode. But there are situations where + ;; c-mark-function fails to properly mark a function. For + ;; example, if we use c-mark-function within a method definition + ;; then the region will expand beyond the method and into the + ;; class definition itself. + ;; + ;; Changing the default to mark-defun provides behavior that users + ;; are more likely to expect. + (define-key map (kbd "C-M-h") 'mark-defun) + + ;; Many packages based on cc-mode provide the 'C-c C-w' binding + ;; to toggle Subword Mode. See the page + ;; + ;; https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html + ;; + ;; for more information about Submode Word. + (if (boundp 'subword-mode) + (if subword-mode + (subword-mode nil) + (subword-mode t))) + + ;; We inherit c-beginning-of-defun and c-end-of-defun from CC Mode + ;; but we have two replacement functions specifically for PHP. We + ;; remap the commands themselves and not their default + ;; key-bindings so that our PHP-specific versions will work even + ;; if the user has reconfigured their keys, e.g. if they rebind + ;; c-end-of-defun to something other than C-M-e. + (define-key map [remap c-beginning-of-defun] 'php-beginning-of-defun) + (define-key map [remap c-end-of-defun] 'php-end-of-defun) + + (define-key map [(control c) (control f)] 'php-search-documentation) + (define-key map [(meta tab)] 'php-complete-function) + (define-key map [(control c) (control m)] 'php-browse-manual) + (define-key map [(control .)] 'php-show-arglist) + (define-key map [(control c) (control r)] 'php-send-region) + ;; Use the Emacs standard indentation binding. This may upset c-mode + ;; which does not follow this at the moment, but I see no better + ;; choice. + (define-key map [tab] 'indent-for-tab-command) + map) + "Keymap for `php-mode'") + +(c-lang-defconst c-mode-menu + php (append '(["Complete function name" php-complete-function t] + ["Browse manual" php-browse-manual t] + ["Search documentation" php-search-documentation t] + ["----" t]) + (c-lang-const c-mode-menu))) + +(c-lang-defconst c-at-vsemi-p-fn + php 'php-c-at-vsemi-p) + +(c-lang-defconst c-vsemi-status-unknown-p-fn + php 'php-c-vsemi-status-unknown-p) + +;; Make php-mode recognize opening tags as preprocessor macro's. +;; +;; This is a workaround, the tags must be recognized as something +;; in order for the syntactic guesses of code below the tag +;; to be correct and as a result not break indentation. +;; +;; Note that submatches or \\| here are not expected by cc-mode. +(c-lang-defconst c-opt-cpp-prefix + php "\\s-*<\\?") + +(c-lang-defconst c-identifier-ops + php '( + (left-assoc "\\" "::" "->") + (prefix "\\" "::"))) + +;; Allow '\' when scanning from open brace back to defining +;; construct like class +(c-lang-defconst c-block-prefix-disallowed-chars + php (cl-set-difference (c-lang-const c-block-prefix-disallowed-chars) + '(?\\))) + +;; Allow $ so variables are recognized in cc-mode and remove @. This +;; makes cc-mode highlight variables and their type hints in arglists. +(c-lang-defconst c-symbol-start + php (concat "[" c-alpha "_$]")) + +;; All string literals can possibly span multiple lines +(c-lang-defconst c-multiline-string-start-char + php t) + +(c-lang-defconst c-assignment-operators + ;; falls back to java, so no need to specify the language + php (append (remove ">>>=" (c-lang-const c-assignment-operators)) + '(".="))) + +(c-lang-defconst beginning-of-defun-function + php 'php-beginning-of-defun) + +(c-lang-defconst end-of-defun-function + php 'php-end-of-defun) + +(c-lang-defconst c-primitive-type-kwds + php '("int" "integer" "bool" "boolean" "float" "double" "real" + "string" "object")) + +(c-lang-defconst c-class-decl-kwds + "Keywords introducing declarations where the following block (if any) +contains another declaration level that should be considered a class." + php '("class" "trait" "interface")) + +(c-lang-defconst c-brace-list-decl-kwds + "Keywords introducing declarations where the following block (if +any) is a brace list. + +PHP does not have an \"enum\"-like keyword." + php nil) + +(c-lang-defconst c-typeless-decl-kwds + php (append (c-lang-const c-class-decl-kwds) '("function"))) + +(c-lang-defconst c-modifier-kwds + php '("abstract" "const" "final" "native" "static" "strictfp" + "synchronized" "transient" "volatile")) + +(c-lang-defconst c-protection-kwds + "Access protection label keywords in classes." + php '("private" "protected" "public")) + +(c-lang-defconst c-postfix-decl-spec-kwds + php '("implements" "extends")) + +(c-lang-defconst c-type-list-kwds + php '("new" "use" "implements" "extends" "namespace" "instanceof" "insteadof")) + +(c-lang-defconst c-ref-list-kwds + php nil) + +(c-lang-defconst c-block-stmt-2-kwds + php (append '("elseif" "foreach" "declare") + (remove "synchronized" (c-lang-const c-block-stmt-2-kwds)))) + +(c-lang-defconst c-simple-stmt-kwds + php (append '("include" "include_once" "require" "require_once" + "echo" "print" "die" "exit") + (c-lang-const c-simple-stmt-kwds))) + +(c-lang-defconst c-constant-kwds + php '("true" + "false" + "null")) + +(c-lang-defconst c-lambda-kwds + php '("function")) + +(c-lang-defconst c-other-kwds + "Keywords not accounted for by any other `*-kwds' language constant." + php '( + "__halt_compiler" + "and" + "array" + "callable" + "as" + "break" + "catch all" + "catch" + "clone" + "default" + "empty" + "enddeclare" + "endfor" + "endforeach" + "endif" + "endswitch" + "endwhile" + "eval" + "global" + "isset" + "list" + "or" + "parent" + "static" + "unset" + "var" + "xor" + "yield" + + ;; Below keywords are technically not reserved keywords, but + ;; threated no differently by php-mode from actual reserved + ;; keywords + ;; + ;;; declare directives: + "encoding" + "ticks" + + ;;; self for static references: + "self" + )) + +;; PHP does not have <> templates/generics +(c-lang-defconst c-recognize-<>-arglists + php nil) + +(c-lang-defconst c-enums-contain-decls + php nil) + +(c-lang-defconst c-nonlabel-token-key + "Regexp matching things that can't occur in generic colon labels. + +This overrides cc-mode `c-nonlabel-token-key' to support switching on +double quoted strings and true/false/null. + +Note: this regexp is also applied to goto-labels, a future improvement +might be to handle switch and goto labels differently." + php (concat + ;; All keywords except `c-label-kwds' and `c-constant-kwds'. + (c-make-keywords-re t + (cl-set-difference (c-lang-const c-keywords) + (append (c-lang-const c-label-kwds) + (c-lang-const c-constant-kwds)) + :test 'string-equal)))) + +(defun php-lineup-cascaded-calls (langelem) + "Line up chained methods using `c-lineup-cascaded-calls', +but only if the setting is enabled" + (if php-lineup-cascaded-calls + (c-lineup-cascaded-calls langelem))) + +(c-add-style + "php" + '((c-basic-offset . 4) + (c-doc-comment-style . javadoc) + (c-offsets-alist . ((arglist-close . php-lineup-arglist-close) + (arglist-cont . (first php-lineup-cascaded-calls 0)) + (arglist-cont-nonempty . (first php-lineup-cascaded-calls c-lineup-arglist)) + (arglist-intro . php-lineup-arglist-intro) + (case-label . +) + (class-open . -) + (comment-intro . 0) + (inlambda . 0) + (inline-open . 0) + (label . +) + (statement-cont . (first php-lineup-cascaded-calls php-lineup-string-cont +)) + (substatement-open . 0) + (topmost-intro-cont . (first php-lineup-cascaded-calls +)))))) + +(defun php-enable-default-coding-style () + "Set PHP Mode to use reasonable default formatting." + (interactive) + (c-set-style "php")) + +(c-add-style + "pear" + '("php" + (c-basic-offset . 4) + (c-offsets-alist . ((case-label . 0))))) + +(defun php-enable-pear-coding-style () + "Sets up php-mode to use the coding styles preferred for PEAR +code and modules." + (interactive) + (setq tab-width 4 + indent-tabs-mode nil) + (c-set-style "pear") + + ;; Undo drupal/PSR-2 coding style whitespace effects + (set (make-local-variable 'show-trailing-whitespace) + (default-value 'show-trailing-whitespace))) + +(c-add-style + "drupal" + '("php" + (c-basic-offset . 2))) + +(defun php-enable-drupal-coding-style () + "Makes php-mode use coding styles that are preferable for +working with Drupal." + (interactive) + (setq tab-width 2 + indent-tabs-mode nil + fill-column 78) + (set (make-local-variable 'show-trailing-whitespace) t) + (add-hook 'before-save-hook 'delete-trailing-whitespace nil t) + (c-set-style "drupal")) + +(c-add-style + "wordpress" + '("php" + (c-basic-offset . 4))) + +(defun php-enable-wordpress-coding-style () + "Makes php-mode use coding styles that are preferable for +working with Wordpress." + (interactive) + (setq indent-tabs-mode t + fill-column 78 + tab-width 4 + c-indent-comments-syntactically-p t) + (c-set-style "wordpress") + + ;; Undo drupal/PSR-2 coding style whitespace effects + (set (make-local-variable 'show-trailing-whitespace) + (default-value 'show-trailing-whitespace))) + +(c-add-style + "symfony2" + '("php" + (c-offsets-alist . ((statement-cont . php-lineup-hanging-semicolon))))) + +(defun php-enable-symfony2-coding-style () + "Makes php-mode use coding styles that are preferable for +working with Symfony2." + (interactive) + (setq indent-tabs-mode nil + fill-column 78 + c-indent-comments-syntactically-p t + require-final-newline t) + (c-set-style "symfony2") + + ;; Undo drupal/PSR-2 coding style whitespace effects + (set (make-local-variable 'show-trailing-whitespace) + (default-value 'show-trailing-whitespace))) + +(c-add-style + "psr2" + '("php")) + +(defun php-enable-psr2-coding-style () + "Makes php-mode comply to the PSR-2 coding style" + (interactive) + (setq indent-tabs-mode nil + fill-column 78 + c-indent-comments-syntactically-p t + require-final-newline t) + (c-set-style "psr2") + + ;; Apply drupal-like coding style whitespace effects + (set (make-local-variable 'require-final-newline) t) + (set (make-local-variable 'show-trailing-whitespace) t) + (add-hook 'before-save-hook 'delete-trailing-whitespace nil t)) + +(defconst php-beginning-of-defun-regexp + "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" + "Regular expression for a PHP function.") + +(defun php-beginning-of-defun (&optional arg) + "Move to the beginning of the ARGth PHP function from point. +Implements PHP version of `beginning-of-defun-function'." + (interactive "p") + (let ((arg (or arg 1))) + (while (> arg 0) + (re-search-backward php-beginning-of-defun-regexp + nil 'noerror) + (setq arg (1- arg))) + (while (< arg 0) + (end-of-line 1) + (let ((opoint (point))) + (beginning-of-defun 1) + (forward-list 2) + (forward-line 1) + (if (eq opoint (point)) + (re-search-forward php-beginning-of-defun-regexp + nil 'noerror)) + (setq arg (1+ arg)))))) + +(defun php-end-of-defun (&optional arg) + "Move the end of the ARGth PHP function from point. +Implements PHP befsion of `end-of-defun-function' + +See `php-beginning-of-defun'." + (interactive "p") + (php-beginning-of-defun (- (or arg 1)))) + + +(defvar php-warned-bad-indent nil) + +;; Do it but tell it is not good if html tags in buffer. +(defun php-check-html-for-indentation () + (let ((html-tag-re "^\\s-*") + (here (point))) + (goto-char (line-beginning-position)) + (if (or (when (boundp 'mumamo-multi-major-mode) mumamo-multi-major-mode) + ;; Fix-me: no idea how to check for mmm or multi-mode + (save-match-data + (not (or (re-search-forward html-tag-re (line-end-position) t) + (re-search-backward html-tag-re (line-beginning-position) t))))) + (progn + (goto-char here) + t) + (goto-char here) + (setq php-warned-bad-indent t) + (let* ((known-multi-libs '(("mumamo" mumamo (lambda () (nxhtml-mumamo))) + ("mmm-mode" mmm-mode (lambda () (mmm-mode 1))) + ("multi-mode" multi-mode (lambda () (multi-mode 1))) + ("web-mode" web-mode (lambda () (web-mode))))) + (known-names (mapcar (lambda (lib) (car lib)) known-multi-libs)) + (available-multi-libs (delq nil + (mapcar + (lambda (lib) + (when (locate-library (car lib)) lib)) + known-multi-libs))) + (available-names (mapcar (lambda (lib) (car lib)) available-multi-libs)) + (base-msg + (concat + "Indentation fails badly with mixed HTML/PHP in the HTML part in +plain `php-mode'. To get indentation to work you must use an +Emacs library that supports 'multiple major modes' in a buffer. +Parts of the buffer will then be in `php-mode' and parts in for +example `html-mode'. Known such libraries are:\n\t" + (mapconcat 'identity known-names ", ") + "\n" + (if available-multi-libs + (concat + "You have these available in your `load-path':\n\t" + (mapconcat 'identity available-names ", ") + "\n\n" + "Do you want to turn any of those on? ") + "You do not have any of those in your `load-path'."))) + (is-using-multi + (catch 'is-using + (dolist (lib available-multi-libs) + (when (and (boundp (cadr lib)) + (symbol-value (cadr lib))) + (throw 'is-using t)))))) + (unless is-using-multi + (if available-multi-libs + (if (not (y-or-n-p base-msg)) + (message "Did not do indentation, but you can try again now if you want") + (let* ((name + (if (= 1 (length available-multi-libs)) + (car available-names) + ;; Minibuffer window is more than one line, fix that first: + (message "") + (completing-read "Choose multiple major mode support library: " + available-names nil t + (car available-names) + '(available-names . 1) + ))) + (mode (when name + (caddr (assoc name available-multi-libs))))) + (when mode + ;; Minibuffer window is more than one line, fix that first: + (message "") + (load name) + (funcall mode)))) + (lwarn 'php-indent :warning base-msg))) + nil)))) + +(defun php-cautious-indent-region (start end &optional quiet) + (if (or (not php-mode-warn-if-mumamo-off) + php-warned-bad-indent + (php-check-html-for-indentation)) + (funcall 'c-indent-region start end quiet))) + +(defun php-cautious-indent-line () + (if (or (not php-mode-warn-if-mumamo-off) + php-warned-bad-indent + (php-check-html-for-indentation)) + (let ((here (point)) + doit) + (move-beginning-of-line nil) + ;; Don't indent heredoc end mark + (save-match-data + (unless (looking-at "[a-zA-Z0-9_]+;\n") + (setq doit t))) + (goto-char here) + (when doit + (funcall 'c-indent-line))))) + +(defun php-c-at-vsemi-p (&optional pos) + "Return t on html lines (including php region border), otherwise nil. +POS is a position on the line in question. + +This is was done due to the problem reported here: + + URL `https://answers.launchpad.net/nxhtml/+question/43320'" + (if (not php-template-compatibility) + nil + (setq pos (or pos (point))) + (let ((here (point)) + ret) + (save-match-data + (goto-char pos) + (beginning-of-line) + (setq ret (looking-at + (rx + (or (seq + bol + (0+ space) + "<" + (in "a-z\\?")) + (seq + (0+ not-newline) + (in "a-z\\?") + ">" + (0+ space) + eol)))))) + (goto-char here) + ret))) + +(defun php-c-vsemi-status-unknown-p () + "See `php-c-at-vsemi-p'." + ) + +(defun php-lineup-string-cont (langelem) + "Line up string toward equal sign or dot +e.g. +$str = 'some' + . 'string'; +this ^ lineup" + (save-excursion + (goto-char (cdr langelem)) + (when (or (search-forward "=" (line-end-position) t) + (search-forward "." (line-end-position) t)) + (vector (1- (current-column)))))) + +(defun php-lineup-arglist-intro (langelem) + (save-excursion + (goto-char (cdr langelem)) + (vector (+ (current-column) c-basic-offset)))) + +(defun php-lineup-arglist-close (langelem) + (save-excursion + (goto-char (cdr langelem)) + (vector (current-column)))) + +(defun php-lineup-arglist (langelem) + (save-excursion + (beginning-of-line) + (if (looking-at-p "\\s-*->") '+ 0))) + +(defun php-lineup-hanging-semicolon (langelem) + (save-excursion + (beginning-of-line) + (if (looking-at-p "\\s-*;\\s-*$") 0 '+))) + +(defconst php-heredoc-start-re + "<<<\\(?:\\w+\\|'\\w+'\\)$" + "Regular expression for the start of a PHP heredoc.") + +(defun php-heredoc-end-re (heredoc-start) + "Build a regular expression for the end of a heredoc started by +the string HEREDOC-START." + ;; Extract just the identifier without <<< and quotes. + (string-match "\\w+" heredoc-start) + (concat "^\\(" (match-string 0 heredoc-start) "\\)\\W")) + +(defsubst php-in-string-p () + (nth 3 (syntax-ppss))) + +(defsubst php-in-comment-p () + (nth 4 (syntax-ppss))) + +(defun php-syntax-propertize-function (start end) + "Apply propertize rules from START to END." + ;; (defconst php-syntax-propertize-function + ;; (syntax-propertize-rules + ;; (php-heredoc-start-re (0 (ignore (php-heredoc-syntax)))))) + (goto-char start) + (while (and (< (point) end) + (re-search-forward php-heredoc-start-re end t)) + (php-heredoc-syntax)) + (goto-char start) + (while (re-search-forward "['\"]" end t) + (when (php-in-comment-p) + (c-put-char-property (match-beginning 0) + 'syntax-table (string-to-syntax "_"))))) + +(defun php-heredoc-syntax () + "Mark the boundaries of searched heredoc." + (goto-char (match-beginning 0)) + (c-put-char-property (point) 'syntax-table (string-to-syntax "|")) + (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) + (goto-char (match-end 1)) + ;; Did not find the delimiter so go to the end of the buffer. + (goto-char (point-max))) + (c-put-char-property (1- (point)) 'syntax-table (string-to-syntax "|"))) + +(defun php-syntax-propertize-extend-region (start end) + "Extend the propertize region if START or END falls inside a +PHP heredoc." + (let ((new-start) + (new-end)) + (goto-char start) + (when (re-search-backward php-heredoc-start-re nil t) + (let ((maybe (point))) + (when (and (re-search-forward + (php-heredoc-end-re (match-string 0)) nil t) + (> (point) start)) + (setq new-start maybe)))) + (goto-char end) + (when (re-search-backward php-heredoc-start-re nil t) + (if (re-search-forward + (php-heredoc-end-re (match-string 0)) nil t) + (when (> (point) end) + (setq new-end (point))) + (setq new-end (point-max)))) + (when (or new-start new-end) + (cons (or new-start start) (or new-end end))))) + +(easy-menu-define php-mode-menu php-mode-map "PHP Mode Commands" + (cons "PHP" (c-lang-const c-mode-menu php))) + +;;;###autoload +(define-derived-mode php-mode c-mode "PHP" + "Major mode for editing PHP code. + +\\{php-mode-map}" + + (c-initialize-cc-mode t) + (c-init-language-vars php-mode) + (c-common-init 'php-mode) + + (modify-syntax-entry ?_ "_" php-mode-syntax-table) + (modify-syntax-entry ?` "\"" php-mode-syntax-table) + (modify-syntax-entry ?\" "\"" php-mode-syntax-table) + (modify-syntax-entry ?# "< b" php-mode-syntax-table) + (modify-syntax-entry ?\n "> b" php-mode-syntax-table) + + (set (make-local-variable 'syntax-propertize-via-font-lock) + '(("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\"")) + ("\\(\'\\)\\(\\\\.\\|[^\'\n\\]\\)*\\(\'\\)" (1 "\"") (3 "\"")))) + + (when (boundp 'syntax-propertize-function) + (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) + #'php-syntax-propertize-extend-region) + (set (make-local-variable 'syntax-propertize-function) + #'php-syntax-propertize-function)) + + (setq font-lock-maximum-decoration t + imenu-generic-expression php-imenu-generic-expression) + + ;; PHP vars are case-sensitive + (setq case-fold-search t) + + ;; Do not force newline at end of file. Such newlines can cause + ;; trouble if the PHP file is included in another file before calls + ;; to header() or cookie(). + (set (make-local-variable 'require-final-newline) nil) + (set (make-local-variable 'next-line-add-newlines) nil) + + ;; PEAR coding standards + (add-hook 'php-mode-pear-hook 'php-enable-pear-coding-style + nil t) + + ;; ;; Drupal coding standards + (add-hook 'php-mode-drupal-hook 'php-enable-drupal-coding-style + nil t) + + ;; ;; WordPress coding standards + (add-hook 'php-mode-wordpress-hook 'php-enable-wordpress-coding-style + nil t) + + ;; ;; Symfony2 coding standards + (add-hook 'php-mode-symfony2-hook 'php-enable-symfony2-coding-style + nil t) + + ;; ;; PSR-2 coding standards + (add-hook 'php-mode-psr2-hook 'php-enable-psr2-coding-style + nil t) + + (cond ((eq php-mode-coding-style 'pear) + (php-enable-pear-coding-style) + (run-hooks 'php-mode-pear-hook)) + ((eq php-mode-coding-style 'drupal) + (php-enable-drupal-coding-style) + (run-hooks 'php-mode-drupal-hook)) + ((eq php-mode-coding-style 'wordpress) + (php-enable-wordpress-coding-style) + (run-hooks 'php-mode-wordpress-hook)) + ((eq php-mode-coding-style 'symfony2) + (php-enable-symfony2-coding-style) + (run-hooks 'php-mode-symfony2-hook)) + ((eq php-mode-coding-style 'psr2) + (php-enable-psr2-coding-style) + (run-hooks 'php-mode-psr2-hook))) + + (if (or php-mode-force-pear + (and (stringp buffer-file-name) + (string-match "PEAR\\|pear" + (buffer-file-name)) + (string-match "\\.php$" (buffer-file-name)))) + (run-hooks 'php-mode-pear-hook)) + + (setq indent-line-function 'php-cautious-indent-line) + (setq indent-region-function 'php-cautious-indent-region) + (setq c-at-vsemi-p-fn 'php-c-at-vsemi-p) + (setq c-vsemi-status-unknown-p 'php-c-vsemi-status-unknown-p) + + (set (make-local-variable 'syntax-begin-function) + 'c-beginning-of-syntax) + + ;; We map the php-{beginning,end}-of-defun functions so that they + ;; replace the similar commands that we inherit from CC Mode. + ;; Because of our remapping we may not actually need to keep the + ;; following two local variables, but we keep them for now until we + ;; are completely sure their removal will not break any current + ;; behavior or backwards compatibility. + (set (make-local-variable 'beginning-of-defun-function) + 'php-beginning-of-defun) + (set (make-local-variable 'end-of-defun-function) + 'php-end-of-defun) + + (set (make-local-variable 'open-paren-in-column-0-is-defun-start) + nil) + (set (make-local-variable 'defun-prompt-regexp) + "^\\s-*function\\s-+&?\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*") + (set (make-local-variable 'add-log-current-defun-header-regexp) + php-beginning-of-defun-regexp)) + +;; Define function name completion function +(defvar php-completion-table nil + "Obarray of tag names defined in current tags table and functions known to PHP.") + +(defun php-complete-function () + "Perform function completion on the text around point. +Completes to the set of names listed in the current tags table +and the standard php functions. +The string to complete is chosen in the same way as the default +for \\[find-tag] (which see)." + (interactive) + (let ((pattern (php-get-pattern)) + beg + completion + (php-functions (php-completion-table))) + (if (not pattern) (message "Nothing to complete") + (if (not (search-backward pattern nil t)) + (message "Can't complete here") + (setq beg (point)) + (forward-char (length pattern)) + (setq completion (try-completion pattern php-functions nil)) + (cond ((eq completion t)) + ((null completion) + (message "Can't find completion for \"%s\"" pattern) + (ding)) + ((not (string= pattern completion)) + (delete-region beg (point)) + (insert completion)) + (t + (message "Making completion list...") + (with-output-to-temp-buffer "*Completions*" + (display-completion-list + (all-completions pattern php-functions))) + (message "Making completion list...%s" "done"))))))) + +(defun php-completion-table () + "Build variable `php-completion-table' on demand. +The table includes the PHP functions and the tags from the +current `tags-file-name'." + (or (and tags-file-name + (save-excursion (tags-verify-table tags-file-name)) + php-completion-table) + (let ((tags-table + (when tags-file-name + (with-current-buffer (get-file-buffer tags-file-name) + (etags-tags-completion-table)))) + (php-table + (cond ((and (not (string= "" php-completion-file)) + (file-readable-p php-completion-file)) + (php-build-table-from-file php-completion-file)) + (php-manual-path + (php-build-table-from-path php-manual-path)) + (t nil)))) + (unless (or php-table tags-table) + (error + (concat "No TAGS file active nor are " + "`php-completion-file' or `php-manual-path' set"))) + (when tags-table + ;; Combine the tables. + (mapatoms (lambda (sym) (intern (symbol-name sym) php-table)) + tags-table)) + (setq php-completion-table php-table)))) + +(defun php-build-table-from-file (filename) + (let ((table (make-vector 1022 0)) + (buf (find-file-noselect filename))) + (with-current-buffer buf + (goto-char (point-min)) + (while (re-search-forward + "^\\([-a-zA-Z0-9_.]+\\)\n" + nil t) + (intern (buffer-substring (match-beginning 1) (match-end 1)) + table))) + (kill-buffer buf) + table)) + +(defun php-build-table-from-path (path) + (let ((table (make-vector 1022 0)) + (files (directory-files + path + nil + "^function\\..+\\.html$"))) + (mapc (lambda (file) + (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) + (intern + (replace-regexp-in-string + "-" "_" (substring file (match-beginning 1) (match-end 1)) t) + table)) + files) + table)) + +;; Find the pattern we want to complete +;; find-tag-default from GNU Emacs etags.el +(defun php-get-pattern () + (save-excursion + (while (looking-at "\\sw\\|\\s_") + (forward-char 1)) + (if (or (re-search-backward "\\sw\\|\\s_" + (save-excursion (beginning-of-line) (point)) + t) + (re-search-forward "\\(\\sw\\|\\s_\\)+" + (save-excursion (end-of-line) (point)) + t)) + (progn (goto-char (match-end 0)) + (buffer-substring-no-properties + (point) + (progn (forward-sexp -1) + (while (looking-at "\\s'") + (forward-char 1)) + (point)))) + nil))) + +(defun php-show-arglist () + (interactive) + (let* ((tagname (php-get-pattern)) + (buf (find-tag-noselect tagname nil nil)) + arglist) + (with-current-buffer buf + (goto-char (point-min)) + (when (re-search-forward + (format "function\\s-+%s\\s-*(\\([^{]*\\))" tagname) + nil t) + (setq arglist (buffer-substring-no-properties + (match-beginning 1) (match-end 1))))) + (if arglist + (message "Arglist for %s: %s" tagname arglist) + (message "Unknown function: %s" tagname)))) + +(defcustom php-search-documentation-browser-function nil + "Function to display PHP documentation in a WWW browser. + +If non-nil, this shadows the value of `browse-url-browser-function' when +calling `php-search-documentation' or `php-search-local-documentation'." + :type '(choice (const :tag "default" nil) function) + :link '(variable-link browse-url-browser-function) + :group 'php) + +(defun php-browse-documentation-url (url) + "Browse a documentation URL using the configured browser function. + +See `php-search-documentation-browser-function'." + (let ((browse-url-browser-function + (or php-search-documentation-browser-function + browse-url-browser-function))) + (browse-url url))) + +(defvar php-search-local-documentation-types + (list "function" "control-structures" "class" "book") + ;; "intro" and "ref" also look interesting, but for all practical purposes + ;; their terms are sub-sets of the "book" terms (with the few exceptions + ;; being very unlikely search terms). + "The set (and priority sequence) of documentation file prefixes +under which to search for files in the local documentation directory.") + +(defvar php-search-local-documentation-words-cache nil) + +(defun php--search-documentation-read-arg () + "Obtain interactive argument for searching documentation." + ;; Cache the list of documentation words available for completion, + ;; based on the defined types-of-interest. + (let ((types-list php-search-local-documentation-types) + (words-cache php-search-local-documentation-words-cache) + (local-manual (and (stringp php-manual-path) + (not (string= php-manual-path ""))))) + (when (and local-manual + (not (assq types-list words-cache))) + ;; Generate the cache on the first run, or if the types changed. + ;; We read the filenames matching our types list in the local + ;; documention directory, and extract the 'middle' component + ;; of each. e.g. "function.array-map.html" => "array_map". + (let* ((types-opt (regexp-opt types-list)) + (pattern (concat "\\`" types-opt "\\.\\(.+\\)\\.html\\'")) + (collection + (mapcar (lambda (filename) (subst-char-in-string + ?- ?_ (replace-regexp-in-string + pattern "\\1" filename))) + (directory-files php-manual-path nil pattern)))) + ;; Replace the entire cache. If the types changed, we don't need + ;; to retain the collection for the previous value. + (setq words-cache (list (cons types-list collection))) + (setq php-search-local-documentation-words-cache words-cache))) + ;; By default we search for (current-word) immediately, without prompting. + ;; With a prefix argument, or if there is no (current-word), we perform a + ;; completing read for a word from the cached collection. + (let* ((default (current-word)) + (prompt (if default + (format "Search PHP docs (%s): " default) + "Search PHP docs: ")) + (collection (and local-manual + (cdr (assq types-list words-cache)))) + (word (if (or current-prefix-arg (not default)) + (completing-read prompt collection nil nil nil nil default) + default))) + ;; Return interactive argument list. + (list word)))) + +(defun php-search-local-documentation (word) + "Search the local PHP documentation (i.e. in `php-manual-path') for +the word at point. The function returns t if the requested documentation +exists, and nil otherwise. + +With a prefix argument, prompt (with completion) for a word to search for." + (interactive (php--search-documentation-read-arg)) + (cl-flet ((php-file-for (type name) + (expand-file-name + (format "%s.%s.html" type + (replace-regexp-in-string + "_" "-" (downcase name))) + php-manual-path)) + (php-file-url (file) + ;; Some browsers require the file:// prefix. + ;; Others do not seem to care. But it should + ;; never be incorrect to use the prefix. + (if (string-prefix-p "file://" file) + file + (concat "file://" file)))) + (let ((file (catch 'found + (loop for type in php-search-local-documentation-types do + (let ((file (php-file-for type word))) + (when (file-exists-p file) + (throw 'found file))))))) + (when file + (php-browse-documentation-url (php-file-url file)) + t)))) + +;; Define function documentation function +(defun php-search-documentation (word) + "Search PHP documentation for the word at point. + +If `php-manual-path' has a non-empty string value then the command +will first try searching the local documentation. If the requested +documentation does not exist it will fallback to searching the PHP +website. + +With a prefix argument, prompt for a documentation word to search +for. If the local documentation is available, it is used to build +a completion list." + (interactive (php--search-documentation-read-arg)) + (cl-flet ((php-search-web-documentation (name) + (php-browse-documentation-url + (concat php-search-url name)))) + (if (and (stringp php-manual-path) + (not (string= php-manual-path ""))) + (or (php-search-local-documentation word) + (php-search-web-documentation word)) + (php-search-web-documentation word)))) + +;; Define function for browsing manual +(defun php-browse-manual () + "Bring up manual for PHP." + (interactive) + (browse-url php-manual-url)) + +(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php) + "Basic highlighting for PHP mode.") + +(defconst php-font-lock-keywords-2 (c-lang-const c-matchers-2 php) + "Medium level highlighting for PHP mode.") + +(defconst php-font-lock-keywords-3 + (append + ;; php-mode patterns *before* cc-mode: + ;; only add patterns here if you want to prevent cc-mode from applying + ;; a different face. + '( + ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but + ;; not in $obj->var() + ("->\\(\\sw+\\)\\s-*(" 1 'default) + + ;; Highlight special variables + ("\\$\\(this\\|that\\)" 1 font-lock-constant-face) + ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 font-lock-variable-name-face) + + ;; Highlight function/method names + ("\\var', but + ;; not in $obj->var() + ("->\\(\\sw+\\)\\s-*(" 1 'default) + + ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 font-lock-variable-name-face) + + ;; Highlight all upper-cased symbols as constant + ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 font-lock-constant-face) + + ;; Highlight all statically accessed class names as constant, + ;; another valid option would be using type-face, but using + ;; constant-face because this is how it works in c++-mode. + ("\\(\\sw+\\)::" 1 font-lock-constant-face) + + ;; Highlight class name after "use .. as" + ("\\" "")) 0 font-lock-preprocessor-face))) + "Detailed highlighting for PHP mode.") + +(defvar php-font-lock-keywords php-font-lock-keywords-3 + "Default expressions to highlight in PHP mode.") + +;;; Provide support for Flymake so that users can see warnings and +;;; errors in real-time as they write code. + +(defun flymake-php-init () + (let* ((temp-file (flymake-init-create-temp-buffer-copy + 'flymake-create-temp-inplace)) + (local-file (file-relative-name + temp-file + (file-name-directory buffer-file-name)))) + (list php-executable (list "-f" local-file "-l")))) + +(add-to-list 'flymake-allowed-file-name-masks + '("\\.php[345s]?$" + flymake-php-init + flymake-simple-cleanup + flymake-get-real-file-name)) + +(add-to-list 'flymake-err-line-patterns + '("\\(Parse\\|Fatal\\) error: \\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)" 3 4 nil 2)) + + +(defun php-send-region (start end) + "Send the region between `start' and `end' to PHP for execution. +The output will appear in the buffer *PHP*." + (interactive "r") + (let ((php-buffer (get-buffer-create "*PHP*")) + (code (buffer-substring start end))) + ;; Calling 'php -r' will fail if we send it code that starts with + ;; '\\|::") + (no-front-space "->\\|::")) + (when (and (eq major-mode 'php-mode) + (or (looking-at-p (concat " \\(" no-behind-space "\\)")) + (save-excursion + (forward-char -2) + (looking-at-p no-front-space)))) + (delete-char 1)))) + +(ad-activate 'fixup-whitespace) + +;; Advice `font-lock-fontify-keywords-region' to support namespace +;; separators in class names. Use word syntax for backslashes when +;; doing keyword fontification, but not when doing syntactic +;; fontification because that breaks \ as escape character in strings. +;; +;; Special care is taken to restore the original syntax, because we +;; want \ not to be word for functions like forward-word. +(defadvice font-lock-fontify-keywords-region (around backslash-as-word activate) + "Fontify keywords with backslash as word character" + (let ((old-syntax (string (char-syntax ?\\)))) + (modify-syntax-entry ?\\ "w") + ad-do-it + (modify-syntax-entry ?\\ old-syntax))) + + +;;;###autoload +(dolist (pattern '("\\.php[s345t]?\\'" "\\.phtml\\'" "Amkfile" "\\.amk$")) + (add-to-list 'auto-mode-alist `(,pattern . php-mode) t)) + +(provide 'php-mode) + +;;; php-mode.el ends here diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index fcbce9e..bbfca9c 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -1,164 +1,175 @@ -;;; Yasnippet.el --- Yet another snippet extension for Emacs. - -;; Copyright 2008 pluskid -;; 2009 pluskid, joaotavora - -;; Authors: pluskid , joaotavora -;; Version: 0.6.1 -;; Package-version: 0.6.1c -;; X-URL: http://code.google.com/p/yasnippet/ +;;; yasnippet.el --- Yet another snippet extension for Emacs. + +;; Copyright (C) 2008-2013 Free Software Foundation, Inc. +;; Authors: pluskid , João Távora +;; Maintainer: João Távora +;; Version: 0.8.1 +;; Package-version: 0.8.0 +;; X-URL: http://github.com/capitaomorte/yasnippet ;; Keywords: convenience, emulation -;; URL: http://code.google.com/p/yasnippet/ +;; URL: http://github.com/capitaomorte/yasnippet ;; EmacsWiki: YaSnippetMode -;; This file is free software; you can redistribute it and/or modify +;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. -;; This file is distributed in the hope that it will be useful, +;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; along with this program. If not, see . ;;; Commentary: - -;; Basic steps to setup: ;; -;; 1. In your .emacs file: -;; (add-to-list 'load-path "/dir/to/yasnippet.el") -;; (require 'yasnippet) -;; 2. Place the `snippets' directory somewhere. E.g: ~/.emacs.d/snippets -;; 3. In your .emacs file -;; (setq yas/root-directory "~/.emacs/snippets") -;; (yas/load-directory yas/root-directory) -;; 4. To enable the YASnippet menu and tab-trigger expansion -;; M-x yas/minor-mode -;; 5. To globally enable the minor mode in *all* buffers -;; M-x yas/global-mode +;; Basic steps to setup: +;; +;; (add-to-list 'load-path +;; "~/path-to-yasnippet") +;; (require 'yasnippet) +;; (yas-global-mode 1) ;; -;; Steps 4. and 5. are optional, you don't have to use the minor -;; mode to use YASnippet. ;; ;; Interesting variables are: ;; -;; `yas/root-directory' +;; `yas-snippet-dirs' ;; ;; The directory where user-created snippets are to be -;; stored. Can also be a list of directories that -;; `yas/reload-all' will use for bulk-reloading snippets. In -;; that case the first directory the default for storing new -;; snippets. +;; stored. Can also be a list of directories. In that case, +;; when used for bulk (re)loading of snippets (at startup or +;; via `yas-reload-all'), directories appearing earlier in +;; the list shadow other dir's snippets. Also, the first +;; directory is taken as the default for storing the user's +;; new snippets. ;; -;; `yas/mode-symbol' +;; The deprecated `yas/root-directory' aliases this variable +;; for backward-compatibility. ;; -;; A local variable that you can set in a hook to override -;; snippet-lookup based on major mode. It is a a symbol (or -;; list of symbols) that correspond to subdirectories of -;; `yas/root-directory' and is used for deciding which -;; snippets to consider for the active buffer. ;; ;; Major commands are: ;; -;; M-x yas/expand +;; M-x yas-expand ;; -;; Try to expand snippets before point. In `yas/minor-mode', -;; this is bound to `yas/trigger-key' which you can customize. +;; Try to expand snippets before point. In `yas-minor-mode', +;; this is normally bound to TAB, but you can customize it in +;; `yas-minor-mode-map'. ;; -;; M-x yas/load-directory +;; M-x yas-load-directory ;; ;; Prompts you for a directory hierarchy of snippets to load. ;; -;; M-x yas/insert-snippet +;; M-x yas-activate-extra-mode +;; +;; Prompts you for an extra mode to add snippets for in the +;; current buffer. +;; +;; M-x yas-insert-snippet ;; ;; Prompts you for possible snippet expansion if that is ;; possible according to buffer-local and snippet-local ;; expansion conditions. With prefix argument, ignore these ;; conditions. ;; -;; M-x yas/find-snippets -;; -;; Lets you find the snippet files in the correct -;; subdirectory of `yas/root-directory', according to the -;; active major mode (if it exists) like -;; `find-file-other-window'. -;; -;; M-x yas/visit-snippet-file +;; M-x yas-visit-snippet-file ;; ;; Prompts you for possible snippet expansions like -;; `yas/insert-snippet', but instead of expanding it, takes +;; `yas-insert-snippet', but instead of expanding it, takes ;; you directly to the snippet definition's file, if it ;; exists. ;; -;; M-x yas/new-snippet +;; M-x yas-new-snippet ;; ;; Lets you create a new snippet file in the correct -;; subdirectory of `yas/root-directory', according to the +;; subdirectory of `yas-snippet-dirs', according to the ;; active major mode. ;; -;; M-x yas/load-snippet-buffer +;; M-x yas-load-snippet-buffer ;; ;; When editing a snippet, this loads the snippet. This is ;; bound to "C-c C-c" while in the `snippet-mode' editing ;; mode. ;; -;; M-x yas/tryout-snippet +;; M-x yas-tryout-snippet ;; ;; When editing a snippet, this opens a new empty buffer, ;; sets it to the appropriate major mode and inserts the ;; snippet there, so you can see what it looks like. This is ;; bound to "C-c C-t" while in `snippet-mode'. ;; -;; The `dropdown-list.el' extension is bundled with YASnippet, you -;; can optionally use it the preferred "prompting method", puting in -;; your .emacs file, for example: +;; M-x yas-describe-tables +;; +;; Lists known snippets in a separate buffer. User is +;; prompted as to whether only the currently active tables +;; are to be displayed, or all the tables for all major +;; modes. +;; +;; If you have `dropdown-list' installed, you can optionally use it +;; as the preferred "prompting method", putting in your .emacs file, +;; for example: ;; ;; (require 'dropdown-list) -;; (setq yas/prompt-functions '(yas/dropdown-prompt -;; yas/ido-prompt -;; yas/completing-prompt)) +;; (setq yas-prompt-functions '(yas-dropdown-prompt +;; yas-ido-prompt +;; yas-completing-prompt)) ;; ;; Also check out the customization group ;; ;; M-x customize-group RET yasnippet RET ;; ;; If you use the customization group to set variables -;; `yas/root-directory' or `yas/global-mode', make sure the path to +;; `yas-snippet-dirs' or `yas-global-mode', make sure the path to ;; "yasnippet.el" is present in the `load-path' *before* the ;; `custom-set-variables' is executed in your .emacs file. ;; ;; For more information and detailed usage, refer to the project page: -;; http://code.google.com/p/yasnippet/ +;; http://github.com/capitaomorte/yasnippet ;;; Code: (require 'cl) -(require 'assoc) +(require 'cl-lib) (require 'easymenu) +(require 'help-mode) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; User customizable variables +(defvar yas--editing-template) +(defvar yas--guessed-modes) +(defvar yas--indent-original-column) +(defvar yas--scheduled-jit-loads) +(defvar yas-keymap) +(defvar yas-selected-text) +(defvar yas-verbosity) +(defvar yas--current-template) + +;;; User customizable variables (defgroup yasnippet nil "Yet Another Snippet extension" + :prefix "yas-" :group 'editing) -;;;###autoload -(defcustom yas/root-directory nil - "Root directory that stores the snippets for each major mode. - -If you set this from your .emacs, can also be a list of strings, -for multiple root directories. If you make this a list, the first -element is always the user-created snippets directory. Other -directories are used for bulk reloading of all snippets using -`yas/reload-all'" +(defvar yas-installed-snippets-dir nil) +(setq yas-installed-snippets-dir + (when load-file-name + (concat (file-name-directory load-file-name) "snippets"))) + +(defcustom yas-snippet-dirs (remove nil + (list "~/.emacs.d/snippets" + 'yas-installed-snippets-dir)) + "List of top-level snippet directories. + +Each element, a string or a symbol whose value is a string, +designates a top-level directory where per-mode snippet +directories can be found. + +Elements appearing earlier in the list shadow later elements' +snippets. + +The first directory is taken as the default for storing snippet's +created with `yas-new-snippet'. " :type '(choice (string :tag "Single directory (string)") (repeat :args (string) :tag "List of directories (strings)")) :group 'yasnippet @@ -167,15 +178,43 @@ directories are used for bulk reloading of all snippets using (let ((old (and (boundp symbol) (symbol-value symbol)))) (set-default symbol new) - (unless (or (not (fboundp 'yas/reload-all)) + (unless (or (not (fboundp 'yas-reload-all)) (equal old new)) - (yas/reload-all))))) + (yas-reload-all))))) + +(defun yas-snippet-dirs () + "Return variable `yas-snippet-dirs' as list of strings." + (cl-loop for e in (if (listp yas-snippet-dirs) + yas-snippet-dirs + (list yas-snippet-dirs)) + collect + (cond ((stringp e) e) + ((and (symbolp e) + (boundp e) + (stringp (symbol-value e))) + (symbol-value e)) + (t + (error "[yas] invalid element %s in `yas-snippet-dirs'" e))))) + +(defvaralias 'yas/root-directory 'yas-snippet-dirs) + +(defcustom yas-new-snippet-default "\ +# -*- mode: snippet; require-final-newline: nil -*- +# name: $1 +# key: ${2:${1:$(yas--key-from-desc yas-text)}}${3: +# binding: ${4:direct-keybinding}} +# -- +$0" + "Default snippet to use when creating a new snippet. +If nil, don't use any snippet." + :type 'string + :group 'yasnippet) -(defcustom yas/prompt-functions '(yas/x-prompt - yas/dropdown-prompt - yas/completing-prompt - yas/ido-prompt - yas/no-prompt) +(defcustom yas-prompt-functions '(yas-x-prompt + yas-dropdown-prompt + yas-completing-prompt + yas-ido-prompt + yas-no-prompt) "Functions to prompt for keys, templates, etc interactively. These functions are called with the following arguments: @@ -202,7 +241,7 @@ signal `quit' with :type '(repeat function) :group 'yasnippet) -(defcustom yas/indent-line 'auto +(defcustom yas-indent-line 'auto "Controls indenting applied to a recent snippet expansion. The following values are possible: @@ -211,7 +250,7 @@ The following values are possible: - `auto' Indent each line of the snippet with `indent-according-to-mode' -Every other value means don't apply any snippet-side indendation +Every other value means don't apply any snippet-side indentation after expansion (the manual per-line \"$>\" indentation still applies)." :type '(choice (const :tag "Nothing" nothing) @@ -219,248 +258,217 @@ applies)." (const :tag "Auto" auto)) :group 'yasnippet) -(defcustom yas/also-auto-indent-first-line nil +(defcustom yas-also-auto-indent-first-line nil "Non-nil means also auto indent first line according to mode. -Naturally this is only valid when `yas/indent-line' is `auto'" +Naturally this is only valid when `yas-indent-line' is `auto'" :type 'boolean :group 'yasnippet) -(defcustom yas/snippet-revival t +(defcustom yas-snippet-revival t "Non-nil means re-activate snippet fields after undo/redo." :type 'boolean :group 'yasnippet) -(defcustom yas/trigger-key "TAB" - "The key bound to `yas/expand' when function `yas/minor-mode' is active. +(defcustom yas-triggers-in-field nil + "If non-nil, allow stacked expansions (snippets inside snippets). -Value is a string that is converted to the internal Emacs key -representation using `read-kbd-macro'." - :type 'string - :group 'yasnippet - :set #'(lambda (symbol key) - (let ((old (and (boundp symbol) - (symbol-value symbol)))) - (set-default symbol key) - ;; On very first loading of this defcustom, - ;; `yas/trigger-key' is *not* loaded. - (if (fboundp 'yas/trigger-key-reload) - (yas/trigger-key-reload old))))) - -(defcustom yas/next-field-key '("TAB" "") - "The key to navigate to next field when a snippet is active. - -Value is a string that is converted to the internal Emacs key -representation using `read-kbd-macro'. - -Can also be a list of strings." - :type '(choice (string :tag "String") - (repeat :args (string) :tag "List of strings")) - :group 'yasnippet - :set #'(lambda (symbol val) - (set-default symbol val) - (if (fboundp 'yas/init-yas-in-snippet-keymap) - (yas/init-yas-in-snippet-keymap)))) - - -(defcustom yas/prev-field-key '("" "") - "The key to navigate to previous field when a snippet is active. - -Value is a string that is converted to the internal Emacs key -representation using `read-kbd-macro'. - -Can also be a list of strings." - :type '(choice (string :tag "String") - (repeat :args (string) :tag "List of strings")) - :group 'yasnippet - :set #'(lambda (symbol val) - (set-default symbol val) - (if (fboundp 'yas/init-yas-in-snippet-keymap) - (yas/init-yas-in-snippet-keymap)))) - -(defcustom yas/skip-and-clear-key "C-d" - "The key to clear the currently active field. - -Value is a string that is converted to the internal Emacs key -representation using `read-kbd-macro'. - -Can also be a list of strings." - :type '(choice (string :tag "String") - (repeat :args (string) :tag "List of strings")) - :group 'yasnippet - :set #'(lambda (symbol val) - (set-default symbol val) - (if (fboundp 'yas/init-yas-in-snippet-keymap) - (yas/init-yas-in-snippet-keymap)))) - -(defcustom yas/triggers-in-field nil - "If non-nil, `yas/next-field-key' can trigger stacked expansions. - -Otherwise, `yas/next-field-key' just tries to move on to the next -field" +Otherwise `yas-next-field-or-maybe-expand' just moves on to the +next field" :type 'boolean :group 'yasnippet) -(defcustom yas/fallback-behavior 'call-other-command - "How to act when `yas/trigger-key' does *not* expand a snippet. +(defcustom yas-fallback-behavior 'call-other-command + "How to act when `yas-expand' does *not* expand a snippet. - `call-other-command' means try to temporarily disable YASnippet - and call the next command bound to `yas/trigger-key'. + and call the next command bound to whatever key was used to + invoke `yas-expand'. - nil or the symbol `return-nil' mean do nothing. (and - `yas/expand-returns' nil) + `yas-expand' returns nil) -- A lisp form (apply COMMAND . ARGS) means interactively call - COMMAND, if ARGS is non-nil, call COMMAND non-interactively +- A Lisp form (apply COMMAND . ARGS) means interactively call + COMMAND. If ARGS is non-nil, call COMMAND non-interactively with ARGS as arguments." :type '(choice (const :tag "Call previous command" call-other-command) (const :tag "Do nothing" return-nil)) :group 'yasnippet) -(make-variable-buffer-local 'yas/fallback-behavior) -(defcustom yas/choose-keys-first nil +(defcustom yas-choose-keys-first nil "If non-nil, prompt for snippet key first, then for template. Otherwise prompts for all possible snippet names. -This affects `yas/insert-snippet' and `yas/visit-snippet-file'." +This affects `yas-insert-snippet' and `yas-visit-snippet-file'." :type 'boolean :group 'yasnippet) -(defcustom yas/choose-tables-first nil +(defcustom yas-choose-tables-first nil "If non-nil, and multiple eligible snippet tables, prompts user for tables first. Otherwise, user chooses between the merging together of all eligible tables. -This affects `yas/insert-snippet', `yas/visit-snippet-file'" +This affects `yas-insert-snippet', `yas-visit-snippet-file'" :type 'boolean :group 'yasnippet) -(defcustom yas/use-menu 'real-modes +(defcustom yas-use-menu 'abbreviate "Display a YASnippet menu in the menu bar. When non-nil, submenus for each snippet table will be listed under the menu \"Yasnippet\". -- If set to `real-modes' only submenus whose name more or less -corresponds to a major mode are listed. - - If set to `abbreviate', only the current major-mode -menu and the modes set in `yas/mode-symbol' are listed. +menu and the modes set in `yas--extra-modes' are listed. + +- If set to `full', every submenu is listed + +- If set to `nil', hide the menu. Any other non-nil value, every submenu is listed." - :type '(choice (const :tag "Full" t) - (const :tag "Real modes only" real-modes) - (const :tag "Abbreviate" abbreviate)) + :type '(choice (const :tag "Full" full) + (const :tag "Abbreviate" abbreviate) + (const :tag "No menu" nil)) :group 'yasnippet) -(defcustom yas/trigger-symbol " =>" +(defcustom yas-trigger-symbol (or (and (eq window-system 'mac) + (ignore-errors + (char-to-string ?\x21E5))) ;; little ->| sign + " =>") "The text that will be used in menu to represent the trigger." :type 'string :group 'yasnippet) -(defcustom yas/wrap-around-region nil +(defcustom yas-wrap-around-region nil "If non-nil, snippet expansion wraps around selected region. The wrapping occurs just before the snippet's exit marker. This -can be overriden on a per-snippet basis." +can be overridden on a per-snippet basis." :type 'boolean :group 'yasnippet) -(defcustom yas/good-grace t +(defcustom yas-good-grace t "If non-nil, don't raise errors in inline elisp evaluation. An error string \"[yas] error\" is returned instead." :type 'boolean :group 'yasnippet) -(defcustom yas/ignore-filenames-as-triggers nil - "If non-nil, don't derive tab triggers from filenames. +(defcustom yas-visit-from-menu nil + "If non-nil visit snippets's files from menu, instead of expanding them. -This means a snippet without a \"# key:'\ directive wont have a -tab trigger." +This can only work when snippets are loaded from files." :type 'boolean :group 'yasnippet) -(defcustom yas/visit-from-menu nil - "If non-nil visit snippets's files from menu, instead of expanding them. +(defcustom yas-expand-only-for-last-commands nil + "List of `last-command' values to restrict tab-triggering to, or nil. -This cafn only work when snippets are loaded from files." - :type 'boolean +Leave this set at nil (the default) to be able to trigger an +expansion simply by placing the cursor after a valid tab trigger, +using whichever commands. + +Optionally, set this to something like '(self-insert-command) if +you to wish restrict expansion to only happen when the last +letter of the snippet tab trigger was typed immediately before +the trigger key itself." + :type '(repeat function) :group 'yasnippet) -(defface yas/field-highlight-face - '((((class color) (background light)) (:background "DarkSeaGreen1")) - (t (:background "DimGrey"))) +;; Only two faces, and one of them shouldn't even be used... +;; +(defface yas-field-highlight-face + '((t (:inherit 'region))) "The face used to highlight the currently active field of a snippet" :group 'yasnippet) -(defface yas/field-debug-face +(defface yas--field-debug-face '() "The face used for debugging some overlays normally hidden" :group 'yasnippet) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; User can also customize the next defvars -(defun yas/define-some-keys (keys keymap definition) - "Bind KEYS to DEFINITION in KEYMAP, read with `read-kbd-macro'." - (let ((keys (or (and (listp keys) keys) - (list keys)))) - (dolist (key keys) - (define-key keymap (read-kbd-macro key) definition)))) - -(defvar yas/keymap - (let ((map (make-sparse-keymap))) - (mapc #'(lambda (binding) - (yas/define-some-keys (car binding) map (cdr binding))) - `((,yas/next-field-key . yas/next-field-or-maybe-expand) - (,yas/prev-field-key . yas/prev-field) - ("C-g" . yas/abort-snippet) - (,yas/skip-and-clear-key . yas/skip-and-clear-or-delete-char))) - map) - "The keymap active while a snippet expansion is in progress.") +;;; User-visible variables + +(defvar yas-keymap (let ((map (make-sparse-keymap))) + (define-key map [(tab)] 'yas-next-field-or-maybe-expand) + (define-key map (kbd "TAB") 'yas-next-field-or-maybe-expand) + (define-key map [(shift tab)] 'yas-prev-field) + (define-key map [backtab] 'yas-prev-field) + (define-key map (kbd "C-g") 'yas-abort-snippet) + (define-key map (kbd "C-d") 'yas-skip-and-clear-or-delete-char) + map) + "The active keymap while a snippet expansion is in progress.") + +(defvar yas-key-syntaxes (list "w" "w_" "w_." "w_.()" + #'yas-try-key-from-whitespace) + "Syntaxes and functions to help look for trigger keys before point. + +Each element in this list specifies how to skip buffer positions +backwards and look for the start of a trigger key. + +Each element can be either a string or a function receiving the +original point as an argument. A string element is simply passed +to `skip-syntax-backward' whereas a function element is called +with no arguments and should also place point before the original +position. + +The string between the resulting buffer position and the original +point is matched against the trigger keys in the active snippet +tables. + +If no expandable snippets are found, the next element is the list +is tried, unless a function element returned the symbol `again', +in which case it is called again from the previous position and +may once more reposition point. -(defvar yas/key-syntaxes (list "w" "w_" "w_." "^ ") - "A list of syntax of a key. This list is tried in the order -to try to find a key. For example, if the list is '(\"w\" \"w_\"). -And in emacs-lisp-mode, where \"-\" has the syntax of \"_\": +For example, if `yas-key-syntaxes'' value is '(\"w\" \"w_\"), +trigger keys composed exclusively of \"word\"-syntax characters +are looked for first. Failing that, longer keys composed of +\"word\" or \"symbol\" syntax are looked for. Therefore, +triggering after foo-bar -will first try \"bar\", if not found, then \"foo-bar\" is tried.") +will, according to the \"w\" element first try \"barbaz\". If +that isn't a trigger key, \"foo-barbaz\" is tried, respecting the +second \"w_\" element. Notice that even if \"baz\" is a trigger +key for an active snippet, it won't be expanded, unless a +function is added to `yas-key-syntaxes' that eventually places +point between \"bar\" and \"baz\". + +See also Info node `(elisp) Syntax Descriptors'.") -(defvar yas/after-exit-snippet-hook +(defvar yas-after-exit-snippet-hook '() "Hooks to run after a snippet exited. The hooks will be run in an environment where some variables bound to proper values: -`yas/snippet-beg' : The beginning of the region of the snippet. +`yas-snippet-beg' : The beginning of the region of the snippet. -`yas/snippet-end' : Similar to beg. +`yas-snippet-end' : Similar to beg. -Attention: These hooks are not run when exiting nested/stackd snippet expansion!") +Attention: These hooks are not run when exiting nested/stacked snippet expansion!") -(defvar yas/before-expand-snippet-hook +(defvar yas-before-expand-snippet-hook '() "Hooks to run just before expanding a snippet.") -(defvar yas/buffer-local-condition - '(if (and (not (bobp)) - (or (equal 'font-lock-comment-face - (get-char-property (1- (point)) - 'face)) - (equal 'font-lock-string-face - (get-char-property (1- (point)) - 'face)))) +(defvar yas-buffer-local-condition + '(if (and (or (fourth (syntax-ppss)) + (fifth (syntax-ppss))) + this-command + (eq this-command 'yas-expand-from-trigger-key)) '(require-snippet-condition . force-in-comment) t) "Snippet expanding condition. -This variable is a lisp form: +This variable is a Lisp form which is evaluated every time a +snippet expansion is attempted: * If it evaluates to nil, no snippets can be expanded. @@ -471,7 +479,7 @@ This variable is a lisp form: considered * Snippets bearing conditions that evaluate to nil (or - produce an error) won't be onsidered. + produce an error) won't be considered. * If the snippet has a condition that evaluates to non-nil RESULT: @@ -489,7 +497,7 @@ This variable is a lisp form: * If it evaluates to t or some other non-nil value * Snippet bearing no conditions, or conditions that - evaluate to non-nil, are considered for expansion. + evaluate to non-nil, are considered for expansion. * Otherwise, the snippet is not considered. @@ -500,7 +508,7 @@ conditions. (add-hook 'python-mode-hook '(lambda () - (setq yas/buffer-local-condition + (setq yas-buffer-local-condition '(if (python-in-string/comment) '(require-snippet-condition . force-in-comment) t)))) @@ -509,273 +517,364 @@ The default value is similar, it filters out potential snippet expansions inside comments and string literals, unless the snippet itself contains a condition that returns the symbol `force-in-comment'.") -(make-variable-buffer-local 'yas/buffer-local-condition) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Internal variables +;;; Internal variables -(defvar yas/version "0.6.1b") +(defvar yas--version "0.8.0beta") -(defvar yas/menu-table (make-hash-table) +(defvar yas--menu-table (make-hash-table) "A hash table of MAJOR-MODE symbols to menu keymaps.") -(defvar yas/active-keybindings nil - "A list of cons (KEYMAP . KEY) setup from defining snippets.") - -(defvar yas/known-modes +(defvar yas--known-modes '(ruby-mode rst-mode markdown-mode) - "A list of mode which is well known but not part of emacs.") + "A list of mode which is well known but not part of Emacs.") -(defvar yas/escaped-characters - '(?\\ ?` ?' ?$ ?} ) +(defvar yas--escaped-characters + '(?\\ ?` ?\" ?' ?$ ?} ?{ ?\( ?\)) "List of characters which *might* need to be escaped.") -(defconst yas/field-regexp +(defconst yas--field-regexp "${\\([0-9]+:\\)?\\([^}]*\\)}" "A regexp to *almost* recognize a field.") -(defconst yas/multi-dollar-lisp-expression-regexp +(defconst yas--multi-dollar-lisp-expression-regexp "$+[ \t\n]*\\(([^)]*)\\)" "A regexp to *almost* recognize a \"$(...)\" expression.") -(defconst yas/backquote-lisp-expression-regexp +(defconst yas--backquote-lisp-expression-regexp "`\\([^`]*\\)`" "A regexp to recognize a \"`lisp-expression`\" expression." ) -(defconst yas/transform-mirror-regexp +(defconst yas--transform-mirror-regexp "${\\(?:\\([0-9]+\\):\\)?$\\([ \t\n]*([^}]*\\)" "A regexp to *almost* recognize a mirror with a transform.") -(defconst yas/simple-mirror-regexp +(defconst yas--simple-mirror-regexp "$\\([0-9]+\\)" "A regexp to recognize a simple mirror.") -(defvar yas/snippet-id-seed 0 +(defvar yas--snippet-id-seed 0 "Contains the next id for a snippet.") -(defun yas/snippet-next-id () - (let ((id yas/snippet-id-seed)) - (incf yas/snippet-id-seed) +(defun yas--snippet-next-id () + (let ((id yas--snippet-id-seed)) + (cl-incf yas--snippet-id-seed) id)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Minor mode stuff +;;; Minor mode stuff ;; XXX: `last-buffer-undo-list' is somehow needed in Carbon Emacs for MacOSX (defvar last-buffer-undo-list nil) -(defvar yas/minor-mode-menu nil - "Holds the YASnippet menu") +(defvar yas--minor-mode-menu nil + "Holds the YASnippet menu.") -(defun yas/init-minor-keymap () +(defvar yas-minor-mode-map (let ((map (make-sparse-keymap))) - (easy-menu-define yas/minor-mode-menu - map - "Menu used when YAS/minor-mode is active." - '("YASnippet" - "----" - ["Expand trigger" yas/expand - :help "Possibly expand tab trigger before point"] - ["Insert at point..." yas/insert-snippet - :help "Prompt for an expandable snippet and expand it at point"] - ["New snippet..." yas/new-snippet - :help "Create a new snippet in an appropriate directory"] - ["Visit snippet file..." yas/visit-snippet-file - :help "Prompt for an expandable snippet and find its file"] - ["Find snippets..." yas/find-snippets - :help "Invoke `find-file' in the appropriate snippet directory"] - "----" - ("Snippet menu behaviour" - ["Visit snippets" (setq yas/visit-from-menu t) - :help "Visit snippets from the menu" - :active t :style radio :selected yas/visit-from-menu] - ["Expand snippets" (setq yas/visit-from-menu nil) - :help "Expand snippets from the menu" - :active t :style radio :selected (not yas/visit-from-menu)] - "----" - ["Show \"Real\" modes only" (setq yas/use-menu 'real-modes) - :help "Show snippet submenus for modes that appear to be real major modes" - :active t :style radio :selected (eq yas/use-menu 'real-modes)] - ["Show all modes" (setq yas/use-menu 't) - :help "Show one snippet submenu for each loaded table" - :active t :style radio :selected (eq yas/use-menu 't)] - ["Abbreviate according to current mode" (setq yas/use-menu 'abbreviate) - :help "Show only snippet submenus for the current active modes" - :active t :style radio :selected (eq yas/use-menu 'abbreviate)]) - ("Indenting" - ["Auto" (setq yas/indent-line 'auto) - :help "Indent each line of the snippet with `indent-according-to-mode'" - :active t :style radio :selected (eq yas/indent-line 'auto)] - ["Fixed" (setq yas/indent-line 'fixed) - :help "Indent the snippet to the current column" - :active t :style radio :selected (eq yas/indent-line 'fixed)] - ["None" (setq yas/indent-line 'none) - :help "Don't apply any particular snippet indentation after expansion" - :active t :style radio :selected (not (member yas/indent-line '(fixed auto)))] - "----" - ["Also auto indent first line" (setq yas/also-auto-indent-first-line - (not yas/also-auto-indent-first-line)) - :help "When auto-indenting also, auto indent the first line menu" - :active (eq yas/indent-line 'auto) - :style toggle :selected yas/also-auto-indent-first-line] - ) - ("Prompting method" - ["System X-widget" (setq yas/prompt-functions - (cons 'yas/x-prompt - (remove 'yas/x-prompt - yas/prompt-functions))) - :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" - :active t :style radio :selected (eq (car yas/prompt-functions) - 'yas/x-prompt)] - ["Dropdown-list" (setq yas/prompt-functions - (cons 'yas/dropdown-prompt - (remove 'yas/dropdown-prompt - yas/prompt-functions))) - :help "Use a special dropdown list" - :active t :style radio :selected (eq (car yas/prompt-functions) - 'yas/dropdown-prompt)] - ["Ido" (setq yas/prompt-functions - (cons 'yas/ido-prompt - (remove 'yas/ido-prompt - yas/prompt-functions))) - :help "Use an ido-style minibuffer prompt" - :active t :style radio :selected (eq (car yas/prompt-functions) - 'yas/ido-prompt)] - ["Completing read" (setq yas/prompt-functions - (cons 'yas/completing-prompt - (remove 'yas/completing-prompt-prompt - yas/prompt-functions))) - :help "Use a normal minibuffer prompt" - :active t :style radio :selected (eq (car yas/prompt-functions) - 'yas/completing-prompt-prompt)] - ) - ("Misc" - ["Wrap region in exit marker" - (setq yas/wrap-around-region - (not yas/wrap-around-region)) - :help "If non-nil automatically wrap the selected text in the $0 snippet exit" - :style toggle :selected yas/wrap-around-region] - ["Allow stacked expansions " - (setq yas/triggers-in-field - (not yas/triggers-in-field)) - :help "If non-nil allow snippets to be triggered inside other snippet fields" - :style toggle :selected yas/triggers-in-field] - ["Revive snippets on undo " - (setq yas/snippet-revival - (not yas/snippet-revival)) - :help "If non-nil allow snippets to become active again after undo" - :style toggle :selected yas/snippet-revival] - ["Good grace " - (setq yas/good-grace - (not yas/good-grace)) - :help "If non-nil don't raise errors in bad embedded eslip in snippets" - :style toggle :selected yas/good-grace] - ["Ignore filenames as triggers" - (setq yas/ignore-filenames-as-triggers - (not yas/ignore-filenames-as-triggers)) - :help "If non-nil don't derive tab triggers from filenames" - :style toggle :selected yas/ignore-filenames-as-triggers] - ) - "----" - ["Load snippets..." yas/load-directory - :help "Load snippets from a specific directory"] - ["Reload everything" yas/reload-all - :help "Cleanup stuff, reload snippets, rebuild menus"] - ["About" yas/about - :help "Display some information about YASsnippet"])) - ;; Now for the stuff that has direct keybindings - ;; - (define-key map "\C-c&\C-s" 'yas/insert-snippet) - (define-key map "\C-c&\C-n" 'yas/new-snippet) - (define-key map "\C-c&\C-v" 'yas/visit-snippet-file) - (define-key map "\C-c&\C-f" 'yas/find-snippets) - map)) - -(defvar yas/minor-mode-map (yas/init-minor-keymap) - "The keymap used when `yas/minor-mode' is active.") - -(defun yas/trigger-key-reload (&optional unbind-key) - "Rebind `yas/expand' to the new value of `yas/trigger-key'. - -With optional UNBIND-KEY, try to unbind that key from -`yas/minor-mode-map'." - (when (and unbind-key - (stringp unbind-key) - (not (string= unbind-key ""))) - (define-key yas/minor-mode-map (read-kbd-macro unbind-key) nil)) - (when (and yas/trigger-key - (stringp yas/trigger-key) - (not (string= yas/trigger-key ""))) - (define-key yas/minor-mode-map (read-kbd-macro yas/trigger-key) 'yas/expand))) + (define-key map [(tab)] 'yas-expand) + (define-key map (kbd "TAB") 'yas-expand) + (define-key map "\C-c&\C-s" 'yas-insert-snippet) + (define-key map "\C-c&\C-n" 'yas-new-snippet) + (define-key map "\C-c&\C-v" 'yas-visit-snippet-file) + map) + "The keymap used when `yas-minor-mode' is active.") + +(easy-menu-define yas--minor-mode-menu + yas-minor-mode-map + "Menu used when `yas-minor-mode' is active." + '("YASnippet" :visible yas-use-menu + "----" + ["Expand trigger" yas-expand + :help "Possibly expand tab trigger before point"] + ["Insert at point..." yas-insert-snippet + :help "Prompt for an expandable snippet and expand it at point"] + ["New snippet..." yas-new-snippet + :help "Create a new snippet in an appropriate directory"] + ["Visit snippet file..." yas-visit-snippet-file + :help "Prompt for an expandable snippet and find its file"] + "----" + ("Snippet menu behaviour" + ["Visit snippets" (setq yas-visit-from-menu t) + :help "Visit snippets from the menu" + :active t :style radio :selected yas-visit-from-menu] + ["Expand snippets" (setq yas-visit-from-menu nil) + :help "Expand snippets from the menu" + :active t :style radio :selected (not yas-visit-from-menu)] + "----" + ["Show all known modes" (setq yas-use-menu 'full) + :help "Show one snippet submenu for each loaded table" + :active t :style radio :selected (eq yas-use-menu 'full)] + ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) + :help "Show only snippet submenus for the current active modes" + :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) + ("Indenting" + ["Auto" (setq yas-indent-line 'auto) + :help "Indent each line of the snippet with `indent-according-to-mode'" + :active t :style radio :selected (eq yas-indent-line 'auto)] + ["Fixed" (setq yas-indent-line 'fixed) + :help "Indent the snippet to the current column" + :active t :style radio :selected (eq yas-indent-line 'fixed)] + ["None" (setq yas-indent-line 'none) + :help "Don't apply any particular snippet indentation after expansion" + :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] + "----" + ["Also auto indent first line" (setq yas-also-auto-indent-first-line + (not yas-also-auto-indent-first-line)) + :help "When auto-indenting also, auto indent the first line menu" + :active (eq yas-indent-line 'auto) + :style toggle :selected yas-also-auto-indent-first-line] + ) + ("Prompting method" + ["System X-widget" (setq yas-prompt-functions + (cons 'yas-x-prompt + (remove 'yas-x-prompt + yas-prompt-functions))) + :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-x-prompt)] + ["Dropdown-list" (setq yas-prompt-functions + (cons 'yas-dropdown-prompt + (remove 'yas-dropdown-prompt + yas-prompt-functions))) + :help "Use a special dropdown list" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-dropdown-prompt)] + ["Ido" (setq yas-prompt-functions + (cons 'yas-ido-prompt + (remove 'yas-ido-prompt + yas-prompt-functions))) + :help "Use an ido-style minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-ido-prompt)] + ["Completing read" (setq yas-prompt-functions + (cons 'yas-completing-prompt + (remove 'yas-completing-prompt + yas-prompt-functions))) + :help "Use a normal minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-completing-prompt)] + ) + ("Misc" + ["Wrap region in exit marker" + (setq yas-wrap-around-region + (not yas-wrap-around-region)) + :help "If non-nil automatically wrap the selected text in the $0 snippet exit" + :style toggle :selected yas-wrap-around-region] + ["Allow stacked expansions " + (setq yas-triggers-in-field + (not yas-triggers-in-field)) + :help "If non-nil allow snippets to be triggered inside other snippet fields" + :style toggle :selected yas-triggers-in-field] + ["Revive snippets on undo " + (setq yas-snippet-revival + (not yas-snippet-revival)) + :help "If non-nil allow snippets to become active again after undo" + :style toggle :selected yas-snippet-revival] + ["Good grace " + (setq yas-good-grace + (not yas-good-grace)) + :help "If non-nil don't raise errors in bad embedded elisp in snippets" + :style toggle :selected yas-good-grace] + ) + "----" + ["Load snippets..." yas-load-directory + :help "Load snippets from a specific directory"] + ["Reload everything" yas-reload-all + :help "Cleanup stuff, reload snippets, rebuild menus"] + ["About" yas-about + :help "Display some information about YASnippet"])) + +(defvar yas--extra-modes nil + "An internal list of modes for which to also lookup snippets. + +This variable probably makes more sense as buffer-local, so +ensure your use `make-local-variable' when you set it.") +(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.8.1") + +(defvar yas--tables (make-hash-table) + "A hash table of mode symbols to `yas--table' objects.") + +(defvar yas--parents (make-hash-table) + "A hash table of mode symbols do lists of direct parent mode symbols. + +This list is populated when reading the \".yas-parents\" files +found when traversing snippet directories with +`yas-load-directory'. + +There might be additional parenting information stored in the +`derived-mode-parent' property of some mode symbols, but that is +not recorded here.") + +(defvar yas--direct-keymaps (list) + "Keymap alist supporting direct snippet keybindings. + +This variable is placed in `emulation-mode-map-alists'. + +Its elements looks like (TABLE-NAME . KEYMAP). They're +instantiated on `yas-reload-all' but KEYMAP is added to only when +loading snippets. `yas--direct-TABLE-NAME' is then a variable set +buffer-locally when entering `yas-minor-mode'. KEYMAP binds all +defined direct keybindings to the command +`yas-expand-from-keymap' which then which snippet to expand.") + +(defun yas-direct-keymaps-reload () + "Force reload the direct keybinding for active snippet tables." + (interactive) + (setq yas--direct-keymaps nil) + (maphash #'(lambda (name table) + (push (cons (intern (format "yas--direct-%s" name)) + (yas--table-direct-keymap table)) + yas--direct-keymaps)) + yas--tables)) + +(defun yas--modes-to-activate () + "Compute list of mode symbols that are active for `yas-expand' +and friends." + (let (dfs) + (setq dfs (lambda (mode &optional explored) + (push mode explored) + (cons mode + (loop for neighbour + in (cl-list* (get mode 'derived-mode-parent) + (ignore-errors (symbol-function mode)) + (gethash mode yas--parents)) + when (and neighbour + (not (memq neighbour explored)) + (symbolp neighbour)) + append (funcall dfs neighbour explored))))) + (remove-duplicates (append yas--extra-modes + (funcall dfs major-mode))))) + +(defvar yas-minor-mode-hook nil + "Hook run when `yas-minor-mode' is turned on.") ;;;###autoload -(define-minor-mode yas/minor-mode +(define-minor-mode yas-minor-mode "Toggle YASnippet mode. -When YASnippet mode is enabled, the `tas/trigger-key' key expands -snippets of code depending on the mode. +When YASnippet mode is enabled, `yas-expand', normally bound to +the TAB key, expands snippets of code depending on the major +mode. With no argument, this command toggles the mode. positive prefix argument turns on the mode. Negative prefix argument turns off the mode. -You can customize the key through `yas/trigger-key'. - Key bindings: -\\{yas/minor-mode-map}" +\\{yas-minor-mode-map}" nil ;; The indicator for the mode line. " yas" :group 'yasnippet - (when yas/minor-mode - (yas/trigger-key-reload) - ;; load all snippets definitions unless we still don't have a - ;; root-directory or some snippets have already been loaded. - (unless (or (null yas/root-directory) - (> (hash-table-count yas/snippet-tables) 0)) - (yas/reload-all)))) - -(defvar yas/dont-activate #'(lambda () - (and yas/root-directory - (null (yas/get-snippet-tables)))) - "If non-nil don't let `yas/minor-mode-on' active yas for this buffer. - -`yas/minor-mode-on' is usually called by `yas/global-mode' so -this effectively lets you define exceptions to the \"global\" -behaviour.") -(make-variable-buffer-local 'yas/dont-activate) - - -(defun yas/minor-mode-on () + (cond (yas-minor-mode + ;; Install the direct keymaps in `emulation-mode-map-alists' + ;; (we use `add-hook' even though it's not technically a hook, + ;; but it works). Then define variables named after modes to + ;; index `yas--direct-keymaps'. + ;; + ;; Also install the post-command-hook. + ;; + (add-hook 'emulation-mode-map-alists 'yas--direct-keymaps) + (add-hook 'post-command-hook 'yas--post-command-handler nil t) + ;; Set the `yas--direct-%s' vars for direct keymap expansion + ;; + (dolist (mode (yas--modes-to-activate)) + (let ((name (intern (format "yas--direct-%s" mode)))) + (set-default name nil) + (set (make-local-variable name) t))) + ;; Perform JIT loads + ;; + (yas--load-pending-jits)) + (t + ;; Uninstall the direct keymaps and the post-command hook + ;; + (remove-hook 'post-command-hook 'yas--post-command-handler t) + (remove-hook 'emulation-mode-map-alists 'yas--direct-keymaps)))) + +(defun yas-activate-extra-mode (mode) + "Activates the snippets for the given `mode' in the buffer. + +The function can be called in the hook of a minor mode to +activate snippets associated with that mode." + (interactive + (let (modes + symbol) + (maphash (lambda (k _) + (setq modes (cons (list k) modes))) + yas--parents) + (setq symbol (completing-read + "Activate mode: " modes nil t)) + (list + (when (not (string= "" symbol)) + (intern symbol))))) + (when mode + (add-to-list (make-local-variable 'yas--extra-modes) mode) + (yas--load-pending-jits))) + +(defun yas-deactivate-extra-mode (mode) + "Deactivates the snippets for the given `mode' in the buffer." + (interactive + (list (intern + (completing-read + "Deactivate mode: " (mapcar #'list yas--extra-modes) nil t)))) + (set (make-local-variable 'yas--extra-modes) + (remove mode + yas--extra-modes))) + +(defvar yas-dont-activate '(minibufferp) + "If non-nil don't let `yas-global-mode' affect some buffers. + +If a function of zero arguments, then its result is used. + +If a list of functions, then all functions must return nil to +activate yas for this buffer. + +In Emacsen <= 23, this variable is buffer-local. Because +`yas-minor-mode-on' is called by `yas-global-mode' after +executing the buffer's major mode hook, setting this variable +there is an effective way to define exceptions to the \"global\" +activation behaviour. + +In Emacsen > 23, only the global value is used. To define +per-mode exceptions to the \"global\" activation behaviour, call +`yas-minor-mode' with a negative argument directily in the major +mode's hook.") +(unless (> emacs-major-version 23) + (with-no-warnings + (make-variable-buffer-local 'yas-dont-activate))) + + +(defun yas-minor-mode-on () "Turn on YASnippet minor mode. -Do this unless `yas/dont-activate' is t or the function -`yas/get-snippet-tables' (which see), returns an empty list." +Honour `yas-dont-activate', which see." (interactive) - (unless (or (and (functionp yas/dont-activate) - (funcall yas/dont-activate)) - (and (not (functionp yas/dont-activate)) - yas/dont-activate)) - (yas/minor-mode 1))) - -(defun yas/minor-mode-off () - "Turn off YASnippet minor mode." - (interactive) - (yas/minor-mode -1)) + ;; Check `yas-dont-activate' + (unless (cond ((functionp yas-dont-activate) + (funcall yas-dont-activate)) + ((consp yas-dont-activate) + (some #'funcall yas-dont-activate)) + (yas-dont-activate)) + (yas-minor-mode 1))) -(define-globalized-minor-mode yas/global-mode yas/minor-mode yas/minor-mode-on +;;;###autoload +(define-globalized-minor-mode yas-global-mode yas-minor-mode yas-minor-mode-on :group 'yasnippet :require 'yasnippet) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Major mode stuff -;; -(defvar yas/font-lock-keywords +(defun yas--global-mode-reload-with-jit-maybe () + "Run `yas-reload-all' when `yas-global-mode' is on." + (when yas-global-mode (yas-reload-all))) + +(add-hook 'yas-global-mode-hook 'yas--global-mode-reload-with-jit-maybe) + + +;;; Major mode stuff + +(defvar yas--font-lock-keywords (append '(("^#.*$" . font-lock-comment-face)) - lisp-font-lock-keywords - lisp-font-lock-keywords-1 lisp-font-lock-keywords-2 '(("$\\([0-9]+\\)" (0 font-lock-keyword-face) @@ -783,13 +882,13 @@ Do this unless `yas/dont-activate' is t or the function ("${\\([0-9]+\\):?" (0 font-lock-keyword-face) (1 font-lock-warning-face t)) - ("${" font-lock-keyword-face) - ("$[0-9]+?" font-lock-preprocessor-face) + ("${" . font-lock-keyword-face) + ("$[0-9]+?" . font-lock-preprocessor-face) ("\\(\\$(\\)" 1 font-lock-preprocessor-face) ("}" (0 font-lock-keyword-face))))) -(defun yas/init-major-keymap () +(defvar snippet-mode-map (let ((map (make-sparse-keymap))) (easy-menu-define nil map @@ -799,162 +898,312 @@ Do this unless `yas/dont-activate' is t or the function (when (third ent) (define-key map (third ent) (second ent))) (vector (first ent) (second ent) t)) - (list - (list "Load this snippet" 'yas/load-snippet-buffer "\C-c\C-c") - (list "Try out this snippet" 'yas/tryout-snippet "\C-c\C-t"))))) - map)) - -(defvar snippet-mode-map - (yas/init-major-keymap) - "The keymap used when `snippet-mode' is active") + '(("Load this snippet" yas-load-snippet-buffer "\C-c\C-l") + ("Load and quit window" yas-load-snippet-buffer-and-close "\C-c\C-c") + ("Try out this snippet" yas-tryout-snippet "\C-c\C-t"))))) + map) + "The keymap used when `snippet-mode' is active.") (define-derived-mode snippet-mode text-mode "Snippet" "A mode for editing yasnippets" - (set-syntax-table (standard-syntax-table)) - (setq font-lock-defaults '(yas/font-lock-keywords)) + (setq font-lock-defaults '(yas--font-lock-keywords)) (set (make-local-variable 'require-final-newline) nil) - (use-local-map snippet-mode-map)) + (set (make-local-variable 'comment-start) "#") + (set (make-local-variable 'comment-start-skip) "#+[\t ]*")) + -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Internal structs for template management + +;;; Internal structs for template management -(defstruct (yas/template (:constructor yas/make-template - (content name condition expand-env file keybinding))) +(defstruct (yas--template (:constructor yas--make-blank-template)) "A template for a snippet." + key content name condition expand-env file - keybinding) - -(defvar yas/snippet-tables (make-hash-table) - "A hash table of MAJOR-MODE symbols to `yas/snippet-table' objects.") - -(defstruct (yas/snippet-table (:constructor yas/make-snippet-table (name))) + keybinding + uuid + menu-binding-pair + group ;; as dictated by the #group: directive or .yas-make-groups + perm-group ;; as dictated by `yas-define-menu' + table + ) + +(defun yas--populate-template (template &rest args) + "Helper function to populate TEMPLATE with properties." + (while args + (aset template + (position (intern (substring (symbol-name (car args)) 1)) + (mapcar #'car (get 'yas--template 'cl-struct-slots))) + (second args)) + (setq args (cddr args))) + template) + +(defstruct (yas--table (:constructor yas--make-snippet-table (name))) "A table to store snippets for a particular mode. Has the following fields: -`yas/snippet-table-name' +`yas--table-name' - A symbol normally corresponding to a major mode, but can also be - a pseudo major-mode to be referenced in `yas/mode-symbol', for - example. + A symbol name normally corresponding to a major mode, but can + also be a pseudo major-mode to be used in + `yas-activate-extra-mode', for example. -`yas/snippet-table-hash' +`yas--table-hash' - A hash table the key is a string (the snippet key) and the - value is yet another hash of (NAME TEMPLATE), where NAME is the - snippet name and TEMPLATE is a `yas/template' object name. + A hash table (KEY . NAMEHASH), known as the \"keyhash\". KEY is + a string or a vector, where the former is the snippet's trigger + and the latter means it's a direct keybinding. NAMEHASH is yet + another hash of (NAME . TEMPLATE) where NAME is the snippet's + name and TEMPLATE is a `yas--template' object. -`yas/snippet-table-parents' +`yas--table-direct-keymap' - A list of tables considered parents of this table: i.e. when - searching for expansions they are searched as well." + A keymap for the snippets in this table that have direct + keybindings. This is kept in sync with the keyhash, i.e., all + the elements of the keyhash that are vectors appear here as + bindings to `yas-expand-from-keymap'. + +`yas--table-uuidhash' + + A hash table mapping snippets uuid's to the same `yas--template' + objects. A snippet uuid defaults to the snippet's name." name (hash (make-hash-table :test 'equal)) - (parents nil)) + (uuidhash (make-hash-table :test 'equal)) + (parents nil) + (direct-keymap (make-sparse-keymap))) -(defvar yas/better-guess-for-replacements nil - "If non-nil `yas/store' better guess snippet replacements.") +(defun yas--get-template-by-uuid (mode uuid) + "Find the snippet template in MODE by its UUID." + (let* ((table (gethash mode yas--tables mode))) + (when table + (gethash uuid (yas--table-uuidhash table))))) -(defun yas/store (table name key template) - "Store a snippet template in the TABLE." +;; Apropos storing/updating in TABLE, this works in two steps: +;; +;; 1. `yas--remove-template-by-uuid' removes any +;; keyhash-namehash-template mappings from TABLE, grabbing the +;; snippet by its uuid. Also removes mappings from TABLE's +;; `yas--table-direct-keymap' (FIXME: and should probably take care +;; of potentially stale menu bindings right?.) +;; +;; 2. `yas--add-template' adds this all over again. +;; +;; Create a new or add to an existing keyhash-namehash mapping. +;; +;; For reference on understanding this, consider three snippet +;; definitions: +;; +;; A: # name: The Foo +;; # key: foo +;; # binding: C-c M-l +;; +;; B: # name: Mrs Foo +;; # key: foo +;; +;; C: # name: The Bar +;; # binding: C-c M-l +;; +;; D: # name: Baz +;; # key: baz +;; +;; keyhash namehashes(3) yas--template structs(4) +;; ----------------------------------------------------- +;; __________ +;; / \ +;; "foo" ---> "The Foo" ---> [yas--template A] | +;; "Mrs Foo" ---> [yas--template B] | +;; | +;; [C-c M-l] ---> "The Foo" -------------------------/ +;; "The Bar" ---> [yas--template C] +;; +;; "baz" ---> "Baz" ---> [yas--template D] +;; +;; Additionally, since uuid defaults to the name, we have a +;; `yas--table-uuidhash' for TABLE +;; +;; uuidhash yas--template structs +;; ------------------------------- +;; "The Foo" ---> [yas--template A] +;; "Mrs Foo" ---> [yas--template B] +;; "The Bar" ---> [yas--template C] +;; "Baz" ---> [yas--template D] +;; +;; FIXME: the more I look at this data-structure the more I think I'm +;; stupid. There has to be an easier way (but beware lots of code +;; depends on this). +;; +(defun yas--remove-template-by-uuid (table uuid) + "Remove from TABLE a template identified by UUID." + (let ((template (gethash uuid (yas--table-uuidhash table)))) + (when template + (let* ((name (yas--template-name template)) + (empty-keys nil)) + ;; Remove the name from each of the targeted namehashes + ;; + (maphash #'(lambda (k v) + (let ((template (gethash name v))) + (when (and template + (eq uuid (yas--template-uuid template))) + (remhash name v) + (when (zerop (hash-table-count v)) + (push k empty-keys))))) + (yas--table-hash table)) + ;; Remove the namehash themselves if they've become empty + ;; + (dolist (key empty-keys) + (when (vectorp key) + (define-key (yas--table-direct-keymap table) key nil)) + (remhash key (yas--table-hash table))) - ;; This is dones by searching twice: - ;; - ;; * Try to get the existing namehash from TABLE using key. - ;; - ;; * Try to get the existing namehash from by searching the *whole* - ;; snippet table for NAME. This is becuase they user might have - ;; changed the key and that can no longer be used to locate the - ;; previous `yas/template-structure'. + ;; Finally, remove the uuid from the uuidhash + ;; + (remhash uuid (yas--table-uuidhash table)))))) + +(defun yas--add-template (table template) + "Store in TABLE the snippet template TEMPLATE. + +KEY can be a string (trigger key) of a vector (direct +keybinding)." + (let ((name (yas--template-name template)) + (key (yas--template-key template)) + (keybinding (yas--template-keybinding template)) + (_menu-binding-pair (yas--template-menu-binding-pair-get-create template))) + (dolist (k (remove nil (list key keybinding))) + (puthash name + template + (or (gethash k + (yas--table-hash table)) + (puthash k + (make-hash-table :test 'equal) + (yas--table-hash table)))) + (when (vectorp k) + (define-key (yas--table-direct-keymap table) k 'yas-expand-from-keymap))) + + ;; Update TABLE's `yas--table-uuidhash' + (puthash (yas--template-uuid template) + template + (yas--table-uuidhash table)))) + +(defun yas--update-template (table template) + "Add or update TEMPLATE in TABLE. + +Also takes care of adding and updating to the associated menu." + ;; Remove from table by uuid ;; - ;; * If that returns nothing, oh well... + (yas--remove-template-by-uuid table (yas--template-uuid template)) + ;; Add to table again ;; - (dolist (existing-namehash (remove nil (list (gethash key (yas/snippet-table-hash table)) - (when yas/better-guess-for-replacements - (let (a) - (maphash #'(lambda (key namehash) - (when (gethash name namehash) - (setq a namehash))) - (yas/snippet-table-hash table)) - a))))) - (let ((existing-template (gethash name existing-namehash))) - (when existing-template - ;; Remove the existing keybinding - (when (yas/template-keybinding existing-template) - (define-key - (symbol-value (first (yas/template-keybinding existing-template))) - (second (yas/template-keybinding existing-template)) - nil) - (setq yas/active-keybindings - (delete (yas/template-keybinding existing-template) - yas/active-keybindings))) - ;; Remove the (name . template) mapping from existing-namehash. - (remhash name existing-namehash)))) - ;; Now store the new template independent of the previous steps. + (yas--add-template table template) + ;; Take care of the menu ;; - (puthash name - template - (or (gethash key - (yas/snippet-table-hash table)) - (puthash key - (make-hash-table :test 'equal) - (yas/snippet-table-hash table))))) - -(defun yas/fetch (table key) - "Fetch a snippet binding to KEY from TABLE." - (let* ((keyhash (yas/snippet-table-hash table)) + (yas--update-template-menu table template)) + +(defun yas--update-template-menu (table template) + "Update every menu-related for TEMPLATE." + (let ((menu-binding-pair (yas--template-menu-binding-pair-get-create template)) + (key (yas--template-key template)) + (keybinding (yas--template-keybinding template))) + ;; The snippet might have changed name or keys, so update + ;; user-visible strings + ;; + (unless (eq (cdr menu-binding-pair) :none) + ;; the menu item name + ;; + (setf (cadar menu-binding-pair) (yas--template-name template)) + ;; the :keys information (also visible to the user) + (setf (getf (cdr (car menu-binding-pair)) :keys) + (or (and keybinding (key-description keybinding)) + (and key (concat key yas-trigger-symbol)))))) + (unless (yas--template-menu-managed-by-yas-define-menu template) + (let ((menu-keymap + (yas--menu-keymap-get-create (yas--table-mode table) + (mapcar #'yas--table-mode + (yas--table-parents table)))) + (group (yas--template-group template))) + ;; Remove from menu keymap + ;; + (assert menu-keymap) + (yas--delete-from-keymap menu-keymap (yas--template-uuid template)) + + ;; Add necessary subgroups as necessary. + ;; + (dolist (subgroup group) + (let ((subgroup-keymap (lookup-key menu-keymap (vector (make-symbol subgroup))))) + (unless (and subgroup-keymap + (keymapp subgroup-keymap)) + (setq subgroup-keymap (make-sparse-keymap)) + (define-key menu-keymap (vector (make-symbol subgroup)) + `(menu-item ,subgroup ,subgroup-keymap))) + (setq menu-keymap subgroup-keymap))) + + ;; Add this entry to the keymap + ;; + (define-key menu-keymap + (vector (make-symbol (yas--template-uuid template))) + (car (yas--template-menu-binding-pair template)))))) + +(defun yas--namehash-templates-alist (namehash) + "Return NAMEHASH as an alist." + (let (alist) + (maphash #'(lambda (k v) + (push (cons k v) alist)) + namehash) + alist)) + +(defun yas--fetch (table key) + "Fetch templates in TABLE by KEY. + +Return a list of cons (NAME . TEMPLATE) where NAME is a +string and TEMPLATE is a `yas--template' structure." + (let* ((keyhash (yas--table-hash table)) (namehash (and keyhash (gethash key keyhash)))) (when namehash - (yas/filter-templates-by-condition - (let (alist) - (maphash #'(lambda (k v) - (push (cons k v) alist)) - namehash) - alist))))) + (yas--filter-templates-by-condition (yas--namehash-templates-alist namehash))))) -;; Filtering/condition logic +;;; Filtering/condition logic -(defun yas/eval-condition (condition) +(defun yas--eval-condition (condition) (condition-case err (save-excursion (save-restriction (save-match-data (eval condition)))) (error (progn - (message (format "[yas] error in condition evaluation: %s" - (error-message-string err))) + (yas--message 1 "Error in condition evaluation: %s" (error-message-string err)) nil)))) -(defun yas/filter-templates-by-condition (templates) +(defun yas--filter-templates-by-condition (templates) "Filter the templates using the applicable condition. TEMPLATES is a list of cons (NAME . TEMPLATE) where NAME is a -string and TEMPLATE is a `yas/template' structure. +string and TEMPLATE is a `yas--template' structure. This function implements the rules described in -`yas/buffer-local-condition'. See that variables documentation." - (let ((requirement (yas/require-template-specific-condition-p))) +`yas-buffer-local-condition'. See that variables documentation." + (let ((requirement (yas--require-template-specific-condition-p))) (if (eq requirement 'always) templates (remove-if-not #'(lambda (pair) - (yas/template-can-expand-p (yas/template-condition (cdr pair)) requirement)) + (yas--template-can-expand-p + (yas--template-condition (cdr pair)) requirement)) templates)))) -(defun yas/require-template-specific-condition-p () - "Decides if this buffer requests/requires snippet-specific +(defun yas--require-template-specific-condition-p () + "Decide if this buffer requests/requires snippet-specific conditions to filter out potential expansions." - (if (eq 'always yas/buffer-local-condition) + (if (eq 'always yas-buffer-local-condition) 'always - (let ((local-condition (or (and (consp yas/buffer-local-condition) - (yas/eval-condition yas/buffer-local-condition)) - yas/buffer-local-condition))) + (let ((local-condition (or (and (consp yas-buffer-local-condition) + (yas--eval-condition yas-buffer-local-condition)) + yas-buffer-local-condition))) (when local-condition (if (eq local-condition t) t @@ -963,207 +1212,229 @@ conditions to filter out potential expansions." (symbolp (cdr local-condition)) (cdr local-condition))))))) -(defun yas/template-can-expand-p (condition &optional requirement) - "Evaluates CONDITION and REQUIREMENT and returns a boolean" - (let* ((requirement (or requirement - (yas/require-template-specific-condition-p))) - (result (or (null condition) - (yas/eval-condition - (condition-case err - (read condition) - (error (progn - (message (format "[yas] error reading condition: %s" - (error-message-string err)))) - nil)))))) +(defun yas--template-can-expand-p (condition requirement) + "Evaluate CONDITION and REQUIREMENT and return a boolean." + (let* ((result (or (null condition) + (yas--eval-condition condition)))) (cond ((eq requirement t) result) (t (eq requirement result))))) -(defun yas/snippet-table-get-all-parents (table) - (let ((parents (yas/snippet-table-parents table))) - (when parents - (append (copy-list parents) - (mapcan #'yas/snippet-table-get-all-parents parents))))) - -(defun yas/snippet-table-templates (table) +(defun yas--table-templates (table) (when table (let ((acc (list))) - (maphash #'(lambda (key namehash) + (maphash #'(lambda (_key namehash) (maphash #'(lambda (name template) (push (cons name template) acc)) namehash)) - (yas/snippet-table-hash table)) - (yas/filter-templates-by-condition acc)))) - -(defun yas/current-key () - "Get the key under current position. A key is used to find -the template of a snippet in the current snippet-table." - (let ((start (point)) - (end (point)) - (syntaxes yas/key-syntaxes) - syntax - done - templates) - (while (and (not done) syntaxes) - (setq syntax (car syntaxes)) - (setq syntaxes (cdr syntaxes)) - (save-excursion - (skip-syntax-backward syntax) - (setq start (point))) - (setq templates - (mapcan #'(lambda (table) - (yas/fetch table (buffer-substring-no-properties start end))) - (yas/get-snippet-tables))) - (if templates - (setq done t) - (setq start end))) - (list templates - start - end))) - - -(defun yas/snippet-table-all-keys (table) - (when table - (let ((acc)) - (maphash #'(lambda (key templates) - (when (yas/filter-templates-by-condition templates) - (push key acc))) - (yas/snippet-table-hash table)) - acc))) + (yas--table-hash table)) + (yas--filter-templates-by-condition acc)))) + +(defun yas--templates-for-key-at-point () + "Find `yas--template' objects for any trigger keys preceding point. +Returns (TEMPLATES START END). This function respects +`yas-key-syntaxes', which see." + (save-excursion + (let ((original (point)) + (methods yas-key-syntaxes) + (templates) + (method)) + (while (and methods + (not templates)) + (unless (eq method (car methods)) + ;; TRICKY: `eq'-ness test means we can only be here if + ;; `method' is a function that returned `again', and hence + ;; don't revert back to original position as per + ;; `yas-key-syntaxes'. + (goto-char original)) + (setq method (car methods)) + (cond ((stringp method) + (skip-syntax-backward method) + (setq methods (cdr methods))) + ((functionp method) + (unless (eq (funcall method original) + 'again) + (setq methods (cdr methods)))) + (t + (yas--warning "Warning invalid element %s in `yas-key-syntaxes'" method))) + (let ((possible-key (buffer-substring-no-properties (point) original))) + (save-excursion + (goto-char original) + (setq templates + (mapcan #'(lambda (table) + (yas--fetch table possible-key)) + (yas--get-snippet-tables)))))) + (when templates + (list templates (point) original))))) + +(defun yas--table-all-keys (table) + "Get trigger keys of all active snippets in TABLE." + (let ((acc)) + (maphash #'(lambda (key namehash) + (when (yas--filter-templates-by-condition (yas--namehash-templates-alist namehash)) + (push key acc))) + (yas--table-hash table)) + acc)) + +(defun yas--table-mode (table) + (intern (yas--table-name table))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Internal functions - -(defun yas/real-mode? (mode) - "Try to find out if MODE is a real mode. The MODE bound to -a function (like `c-mode') is considered real mode. Other well -known mode like `ruby-mode' which is not part of Emacs might -not bound to a function until it is loaded. So yasnippet keeps -a list of modes like this to help the judgement." +;;; Internal functions and macros: + +(defun yas--real-mode? (mode) + "Try to find out if MODE is a real mode. + +The MODE bound to a function (like `c-mode') is considered real +mode. Other well known mode like `ruby-mode' which is not part of +Emacs might not bound to a function until it is loaded. So +yasnippet keeps a list of modes like this to help the judgment." (or (fboundp mode) - (find mode yas/known-modes))) + (find mode yas--known-modes))) + +(defun yas--handle-error (err) + "Handle error depending on value of `yas-good-grace'." + (let ((msg (yas--format "elisp error: %s" (error-message-string err)))) + (if yas-good-grace msg + (error "%s" msg)))) -(defun yas/read-and-eval-string (string) - ;; TODO: This is a possible optimization point, the expression could - ;; be stored in cons format instead of string, - "Evaluate STRING and convert the result to string." - (let ((retval (catch 'yas/exception +(defun yas--eval-lisp (form) + "Evaluate FORM and convert the result to string." + (let ((retval (catch 'yas--exception (condition-case err (save-excursion (save-restriction (save-match-data (widen) - (let ((result (eval (read string)))) + (let ((result (eval form))) (when result (format "%s" result)))))) - (error (if yas/good-grace - "[yas] elisp error!" - (error (format "[yas] elisp error: %s" - (error-message-string err))))))))) + (error (yas--handle-error err)))))) (when (and (consp retval) - (eq 'yas/exception (car retval))) + (eq 'yas--exception (car retval))) (error (cdr retval))) retval)) -(defvar yas/mode-symbol nil - "If non-nil, lookup snippets using this instead of `major-mode'.") -(make-variable-buffer-local 'yas/mode-symbol) +(defun yas--eval-lisp-no-saves (form) + (condition-case err + (eval form) + (error (message "%s" (yas--handle-error err))))) -(defun yas/snippet-table-get-create (mode) - "Get the snippet table corresponding to MODE. +(defun yas--read-lisp (string &optional nil-on-error) + "Read STRING as a elisp expression and return it. -Optional DIRECTORY gets recorded as the default directory to -search for snippet files if the retrieved/created table didn't -already have such a property." +In case STRING in an invalid expression and NIL-ON-ERROR is nil, +return an expression that when evaluated will issue an error." + (condition-case err + (read string) + (error (and (not nil-on-error) + `(error (error-message-string ,err)))))) + +(defun yas--read-keybinding (keybinding) + "Read KEYBINDING as a snippet keybinding, return a vector." + (when (and keybinding + (not (string-match "keybinding" keybinding))) + (condition-case err + (let ((res (or (and (string-match "^\\[.*\\]$" keybinding) + (read keybinding)) + (read-kbd-macro keybinding 'need-vector)))) + res) + (error + (yas--message 3 "warning: keybinding \"%s\" invalid since %s." + keybinding (error-message-string err)) + nil)))) + +(defun yas--table-get-create (mode) + "Get or create the snippet table corresponding to MODE." (let ((table (gethash mode - yas/snippet-tables))) + yas--tables))) (unless table - (setq table (yas/make-snippet-table (symbol-name mode))) - (puthash mode table yas/snippet-tables)) + (setq table (yas--make-snippet-table (symbol-name mode))) + (puthash mode table yas--tables) + (push (cons (intern (format "yas--direct-%s" mode)) + (yas--table-direct-keymap table)) + yas--direct-keymaps)) table)) -(defun yas/get-snippet-tables (&optional mode-symbol dont-search-parents) +(defun yas--get-snippet-tables () "Get snippet tables for current buffer. -Return a list of 'yas/snippet-table' objects indexed by mode. - -The modes are tried in this order: optional MODE-SYMBOL, then -`yas/mode-symbol', then `major-mode' then, unless -DONT-SEARCH-PARENTS is non-nil, the guessed parent mode of either -MODE-SYMBOL or `major-mode'. - -Guessing is done by looking up the MODE-SYMBOL's -`derived-mode-parent' property, see also `derived-mode-p'." - (let ((mode-tables - (mapcar #'(lambda (mode) - (gethash mode yas/snippet-tables)) - (append (list mode-symbol) - (if (listp yas/mode-symbol) - yas/mode-symbol - (list yas/mode-symbol)) - (list major-mode - (and (not dont-search-parents) - (get (or mode-symbol major-mode) - 'derived-mode-parent)))))) - (all-tables)) - (dolist (table (remove nil mode-tables)) - (push table all-tables) - (nconc all-tables (yas/snippet-table-get-all-parents table))) - (remove-duplicates all-tables))) - -(defun yas/menu-keymap-get-create (mode) - "Get the menu keymap correspondong to MODE." - (or (gethash mode yas/menu-table) - (puthash mode (make-sparse-keymap) yas/menu-table))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +Return a list of `yas--table' objects. The list of modes to +consider is returned by `yas--modes-to-activate'" + (remove nil + (mapcar #'(lambda (name) + (gethash name yas--tables)) + (yas--modes-to-activate)))) + +(defun yas--menu-keymap-get-create (mode &optional parents) + "Get or create the menu keymap for MODE and its PARENTS. + +This may very well create a plethora of menu keymaps and arrange +them all in `yas--menu-table'" + (let* ((menu-keymap (or (gethash mode yas--menu-table) + (puthash mode (make-sparse-keymap) yas--menu-table)))) + (mapc #'yas--menu-keymap-get-create parents) + (define-key yas--minor-mode-menu (vector mode) + `(menu-item ,(symbol-name mode) ,menu-keymap + :visible (yas--show-menu-p ',mode))) + menu-keymap)) + + +(defmacro yas--called-interactively-p (&optional kind) + "A backward-compatible version of `called-interactively-p'. + +Optional KIND is as documented at `called-interactively-p' +in GNU Emacs 24.1 or higher." + (if (string< emacs-version "24.1") + '(called-interactively-p) + `(called-interactively-p ,kind))) + + ;;; Template-related and snippet loading functions -(defun yas/parse-template (&optional file) +(defun yas--parse-template (&optional file) "Parse the template in the current buffer. Optional FILE is the absolute file name of the file being parsed. +Optional GROUP is the group where the template is to go, +otherwise we attempt to calculate it from FILE. + Return a snippet-definition, i.e. a list - (KEY TEMPLATE NAME CONDITION GROUP VARS FILE KEYBINDING) + (KEY TEMPLATE NAME CONDITION GROUP VARS FILE KEYBINDING UUID) -If the buffer contains a line of \"# --\" then the contents -above this line are ignored. Variables can be set above this -line through the syntax: +If the buffer contains a line of \"# --\" then the contents above +this line are ignored. Directives can set most of these with the syntax: -#name : value +# directive-name : directive-value -Here's a list of currently recognized variables: +Here's a list of currently recognized directives: + * type * name * contributor * condition - * key * group + * key * expand-env - -#name: #include \"...\" -# -- -#include \"$1\"" - ;; - ;; + * binding + * uuid" (goto-char (point-min)) - (let* ((name (and file + (let* ((type 'snippet) + (name (and file (file-name-nondirectory file))) - (key (unless yas/ignore-filenames-as-triggers - (and name - (file-name-sans-extension name)))) + (key nil) template bound condition (group (and file - (yas/calculate-group file))) + (yas--calculate-group file))) expand-env - binding) + binding + uuid) (if (re-search-forward "^# --\n" nil t) (progn (setq template (buffer-substring-no-properties (point) @@ -1171,23 +1442,36 @@ Here's a list of currently recognized variables: (setq bound (point)) (goto-char (point-min)) (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*\\)$" bound t) + (when (string= "uuid" (match-string-no-properties 1)) + (setq uuid (match-string-no-properties 2))) + (when (string= "type" (match-string-no-properties 1)) + (setq type (if (string= "command" (match-string-no-properties 2)) + 'command + 'snippet))) + (when (string= "key" (match-string-no-properties 1)) + (setq key (match-string-no-properties 2))) (when (string= "name" (match-string-no-properties 1)) (setq name (match-string-no-properties 2))) (when (string= "condition" (match-string-no-properties 1)) - (setq condition (match-string-no-properties 2))) + (setq condition (yas--read-lisp (match-string-no-properties 2)))) (when (string= "group" (match-string-no-properties 1)) (setq group (match-string-no-properties 2))) (when (string= "expand-env" (match-string-no-properties 1)) - (setq expand-env (match-string-no-properties 2))) - (when (string= "key" (match-string-no-properties 1)) - (setq key (match-string-no-properties 2))) + (setq expand-env (yas--read-lisp (match-string-no-properties 2) + 'nil-on-error))) (when (string= "binding" (match-string-no-properties 1)) (setq binding (match-string-no-properties 2))))) (setq template (buffer-substring-no-properties (point-min) (point-max)))) - (list key template name condition group expand-env file binding))) - -(defun yas/calculate-group (file) + (unless (or key binding) + (setq key (and file (file-name-nondirectory file)))) + (when (eq type 'command) + (setq template (yas--read-lisp (concat "(progn" template ")")))) + (when group + (setq group (split-string group "\\."))) + (list key template name condition group expand-env file binding uuid))) + +(defun yas--calculate-group (file) "Calculate the group for snippet file path FILE." (let* ((dominating-dir (locate-dominating-file file ".yas-make-groups")) @@ -1204,261 +1488,448 @@ Here's a list of currently recognized variables: (directory-file-name extra-dir))))) group)) -;; (defun yas/glob-files (directory &optional recurse-p append) -;; "Returns files under DIRECTORY ignoring dirs and hidden files. - -;; If RECURSE in non-nil, do that recursively." -;; (let (ret -;; (default-directory directory)) -;; (dolist (entry (directory-files ".")) -;; (cond ((or (string-match "^\\." -;; (file-name-nondirectory entry)) -;; (string-match "~$" -;; (file-name-nondirectory entry))) -;; nil) -;; ((and recurse-p -;; (file-directory-p entry)) -;; (setq ret (nconc ret -;; (yas/glob-files (expand-file-name entry) -;; recurse-p -;; (if append -;; (concat append "/" entry) -;; entry))))) -;; ((file-directory-p entry) -;; nil) -;; (t -;; (push (if append -;; (concat append "/" entry) -;; entry) ret)))) -;; ret)) - -(defun yas/subdirs (directory &optional file?) - "Return subdirs or files of DIRECTORY according to FILE?." +(defun yas--subdirs (directory &optional filep) + "Return subdirs or files of DIRECTORY according to FILEP." (remove-if (lambda (file) (or (string-match "^\\." (file-name-nondirectory file)) + (string-match "^#.*#$" + (file-name-nondirectory file)) (string-match "~$" (file-name-nondirectory file)) - (if file? + (if filep (file-directory-p file) (not (file-directory-p file))))) (directory-files directory t))) -(defun yas/make-menu-binding (template) - `(lambda () (interactive) (yas/expand-or-visit-from-menu ,template))) +(defun yas--make-menu-binding (template) + (let ((mode (yas--table-mode (yas--template-table template)))) + `(lambda () (interactive) (yas--expand-or-visit-from-menu ',mode ,(yas--template-uuid template))))) + +(defun yas--expand-or-visit-from-menu (mode uuid) + (let* ((table (yas--table-get-create mode)) + (yas--current-template (and table + (gethash uuid (yas--table-uuidhash table))))) + (when yas--current-template + (if yas-visit-from-menu + (yas--visit-snippet-file-1 yas--current-template) + (let ((where (if (region-active-p) + (cons (region-beginning) (region-end)) + (cons (point) (point))))) + (yas-expand-snippet (yas--template-content yas--current-template) + (car where) + (cdr where) + (yas--template-expand-env yas--current-template))))))) + +(defun yas--key-from-desc (text) + "Return a yasnippet key from a description string TEXT." + (replace-regexp-in-string "\\(\\w+\\).*" "\\1" text)) -(defun yas/expand-or-visit-from-menu (template) - (if yas/visit-from-menu - (yas/visit-snippet-file-1 template) - (let ((where (if mark-active - (cons (region-beginning) (region-end)) - (cons (point) (point))))) - (yas/expand-snippet (yas/template-content template) - (car where) - (cdr where))))) + +;;; Popping up for keys and templates -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Popping up for keys and templates -;; -(defun yas/prompt-for-template (templates &optional prompt) +(defun yas--prompt-for-template (templates &optional prompt) "Interactively choose a template from the list TEMPLATES. -TEMPLATES is a list of `yas/template'." +TEMPLATES is a list of `yas--template'. + +Optional PROMPT sets the prompt to use." (when templates + (setq templates + (sort templates #'(lambda (t1 t2) + (< (length (yas--template-name t1)) + (length (yas--template-name t2)))))) (some #'(lambda (fn) (funcall fn (or prompt "Choose a snippet: ") templates - #'yas/template-name)) - yas/prompt-functions))) + #'yas--template-name)) + yas-prompt-functions))) -(defun yas/prompt-for-keys (keys &optional prompt) - "Interactively choose a template key from the list KEYS." +(defun yas--prompt-for-keys (keys &optional prompt) + "Interactively choose a template key from the list KEYS. + +Optional PROMPT sets the prompt to use." (when keys (some #'(lambda (fn) (funcall fn (or prompt "Choose a snippet key: ") keys)) - yas/prompt-functions))) + yas-prompt-functions))) + +(defun yas--prompt-for-table (tables &optional prompt) + "Interactively choose a table from the list TABLES. -(defun yas/prompt-for-table (tables &optional prompt) +Optional PROMPT sets the prompt to use." (when tables (some #'(lambda (fn) (funcall fn (or prompt "Choose a snippet table: ") tables - #'yas/snippet-table-name)) - yas/prompt-functions))) + #'yas--table-name)) + yas-prompt-functions))) -(defun yas/x-prompt (prompt choices &optional display-fn) +(defun yas-x-prompt (prompt choices &optional display-fn) + "Display choices in a x-window prompt." (when (and window-system choices) - (let ((keymap (cons 'keymap - (cons - prompt - (mapcar (lambda (choice) - (list choice - 'menu-item - (if display-fn - (funcall display-fn choice) - choice) - t)) - choices))))) - (when (cdr keymap) - (car (x-popup-menu (if (fboundp 'posn-at-point) - (let ((x-y (posn-x-y (posn-at-point (point))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - keymap)))))) - -(defun yas/ido-prompt (prompt choices &optional display-fn) - (when (and (featurep 'ido) - ido-mode) - (let* ((formatted-choices (or (and display-fn - (mapcar display-fn choices)) - choices)) - (chosen (and formatted-choices - (ido-completing-read prompt - formatted-choices - nil - 'require-match - nil - nil)))) - (when chosen - (nth (position chosen formatted-choices :test #'string=) choices))))) - -(eval-when-compile (require 'dropdown-list nil t)) -(defun yas/dropdown-prompt (prompt choices &optional display-fn) - (when (featurep 'dropdown-list) - (let* ((formatted-choices (or (and display-fn - (mapcar display-fn choices)) - choices)) - (chosen (and formatted-choices - (nth (dropdown-list formatted-choices) - choices)))) - chosen))) - -(defun yas/completing-prompt (prompt choices &optional display-fn) - (let* ((formatted-choices (or (and display-fn - (mapcar display-fn choices)) - choices)) - (chosen (and formatted-choices - (completing-read prompt - formatted-choices - nil - 'require-match - nil - nil)))) - (when chosen - (nth (position chosen formatted-choices :test #'string=) choices)))) - -(defun yas/no-prompt (prompt choices &optional display-fn) + (or + (x-popup-menu + (if (fboundp 'posn-at-point) + (let ((x-y (posn-x-y (posn-at-point (point))))) + (list (list (+ (car x-y) 10) + (+ (cdr x-y) 20)) + (selected-window))) + t) + `(,prompt ("title" + ,@(mapcar* (lambda (c d) `(,(concat " " d) . ,c)) + choices + (if display-fn (mapcar display-fn choices) choices))))) + (keyboard-quit)))) + +(defun yas-ido-prompt (prompt choices &optional display-fn) + (when (and (fboundp 'ido-completing-read) + (or (>= emacs-major-version 24) + ido-mode)) + (yas-completing-prompt prompt choices display-fn #'ido-completing-read))) + +(defun yas-dropdown-prompt (_prompt choices &optional display-fn) + (when (fboundp 'dropdown-list) + (let* ((formatted-choices + (if display-fn (mapcar display-fn choices) choices)) + (n (dropdown-list formatted-choices))) + (if n (nth n choices) + (keyboard-quit))))) + +(defun yas-completing-prompt (prompt choices &optional display-fn completion-fn) + (let* ((formatted-choices + (if display-fn (mapcar display-fn choices) choices)) + (chosen (funcall (or completion-fn #'completing-read) + prompt formatted-choices + nil 'require-match nil nil))) + (if (eq choices formatted-choices) + chosen + (nth (or (position chosen formatted-choices :test #'string=) 0) + choices)))) + +(defun yas-no-prompt (_prompt choices &optional _display-fn) (first choices)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Loading snippets from files + +;;; Defining snippets +;; This consists of creating and registering `yas--template' objects in the +;; correct tables. ;; -(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 - (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") - nil - no-hierarchy-parents))) - (yas/ignore-filenames-as-triggers (or yas/ignore-filenames-as-triggers - (file-exists-p (concat directory "/" ".yas-ignore-filenames-as-triggers")))) - (mode-sym (and major-mode-and-parents - (car major-mode-and-parents))) - (parents (if making-groups-sym - parents - (rest major-mode-and-parents))) - (snippet-defs nil) - (make-groups-p (or making-groups-sym - (file-exists-p (concat directory "/" ".yas-make-groups"))))) - (with-temp-buffer - (dolist (file (yas/subdirs directory 'no-subdirs-just-files)) - (when (file-readable-p file) - (insert-file-contents file nil nil nil t) - (push (yas/parse-template file) - snippet-defs)))) - (yas/define-snippets (or mode-sym - making-groups-sym) - snippet-defs - parents) - (dolist (subdir (yas/subdirs directory)) - (if make-groups-p - (yas/load-directory-1 subdir parents 't (or mode-sym - making-groups-sym)) - (yas/load-directory-1 subdir (list mode-sym))))))) - -(defun yas/load-directory (directory) - "Load snippet definition from a directory hierarchy. - -Below the top-level directory, each directory is a mode -name. And under each subdirectory, each file is a definition -of a snippet. The file name is the trigger key and the -content of the file is the template." - (interactive "DSelect the root directory: ") - (unless (file-directory-p directory) - (error "Error %s not a directory" directory)) - (unless yas/root-directory - (setq yas/root-directory directory)) - (dolist (dir (yas/subdirs directory)) - (yas/load-directory-1 dir nil 'no-hierarchy-parents)) - (when (interactive-p) - (message "done."))) - -(defun yas/kill-snippet-keybindings () - "Remove the all active snippet keybindings." - (interactive) - (dolist (keybinding yas/active-keybindings) - (define-key (symbol-value (first keybinding)) (second keybinding) nil)) - (setq yas/active-keybindings nil)) -(defun yas/reload-all (&optional reset-root-directory) - "Reload all snippets and rebuild the YASnippet menu. " - (interactive "P") - ;; Turn off global modes and minor modes, save their state though +(defvar yas--creating-compiled-snippets nil) + +(defun yas--define-snippets-1 (snippet snippet-table) + "Helper for `yas-define-snippets'." + ;; X) Calculate some more defaults on the values returned by + ;; `yas--parse-template'. ;; - (let ((restore-global-mode (prog1 yas/global-mode - (yas/global-mode -1))) - (restore-minor-mode (prog1 yas/minor-mode - (yas/minor-mode -1)))) - ;; Empty all snippet tables and all menu tables + (let* ((file (seventh snippet)) + (key (car snippet)) + (name (or (third snippet) + (and file + (file-name-directory file)))) + (condition (fourth snippet)) + (group (fifth snippet)) + (keybinding (yas--read-keybinding (eighth snippet))) + (uuid (or (ninth snippet) + name)) + (template (or (gethash uuid (yas--table-uuidhash snippet-table)) + (yas--make-blank-template)))) + ;; X) populate the template object ;; - (setq yas/snippet-tables (make-hash-table)) - (setq yas/menu-table (make-hash-table)) - - ;; Init the `yas/minor-mode-map', taking care not to break the - ;; menu.... + (yas--populate-template template + :table snippet-table + :key key + :content (second snippet) + :name (or name key) + :group group + :condition condition + :expand-env (sixth snippet) + :file (seventh snippet) + :keybinding keybinding + :uuid uuid) + ;; X) Update this template in the appropriate table. This step + ;; also will take care of adding the key indicators in the + ;; templates menu entry, if any ;; - (setf (cdr yas/minor-mode-map) - (cdr (yas/init-minor-keymap))) + (yas--update-template snippet-table template) + ;; X) Return the template + ;; + ;; + template)) - ;; Now, clean up the other keymaps we might have cluttered up. - (yas/kill-snippet-keybindings) +(defun yas-define-snippets (mode snippets) + "Define SNIPPETS for MODE. - (when reset-root-directory - (setq yas/root-directory nil)) +SNIPPETS is a list of snippet definitions, each taking the +following form - ;; Reload the directories listed in `yas/root-directory' or prompt - ;; the user to select one. - ;; - (if yas/root-directory - (if (listp yas/root-directory) - (dolist (directory yas/root-directory) - (yas/load-directory directory)) - (yas/load-directory yas/root-directory)) - (call-interactively 'yas/load-directory)) - - ;; Restore the mode configuration - ;; - (when restore-minor-mode - (yas/minor-mode 1)) - (when restore-global-mode - (yas/global-mode 1)) + (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING UUID) + +Within these, only KEY and TEMPLATE are actually mandatory. + +TEMPLATE might be a Lisp form or a string, depending on whether +this is a snippet or a snippet-command. + +CONDITION, EXPAND-ENV and KEYBINDING are Lisp forms, they have +been `yas--read-lisp'-ed and will eventually be +`yas--eval-lisp'-ed. + +The remaining elements are strings. + +FILE is probably of very little use if you're programatically +defining snippets. + +UUID is the snippet's \"unique-id\". Loading a second snippet +file with the same uuid would replace the previous snippet. + +You can use `yas--parse-template' to return such lists based on +the current buffers contents." + (if yas--creating-compiled-snippets + (progn + (insert ";;; Snippet definitions:\n;;;\n") + (let ((literal-snippets (list)) + (print-length nil)) + (dolist (snippet snippets) + (let ((key (nth 0 snippet)) + (template-content (nth 1 snippet)) + (name (nth 2 snippet)) + (condition (nth 3 snippet)) + (group (nth 4 snippet)) + (expand-env (nth 5 snippet)) + (file nil) ;; omit on purpose + (binding (nth 7 snippet)) + (uuid (nth 8 snippet))) + (push `(,key + ,template-content + ,name + ,condition + ,group + ,expand-env + ,file + ,binding + ,uuid) + literal-snippets))) + (insert (pp-to-string + `(yas-define-snippets ',mode ',literal-snippets))) + (insert "\n\n"))) + ;; Normal case. + (let ((snippet-table (yas--table-get-create mode)) + (template nil)) + (dolist (snippet snippets) + (setq template (yas--define-snippets-1 snippet + snippet-table))) + template))) - (message "[yas] Reloading everything... Done."))) + +;;; Loading snippets from files + +(defun yas--load-yas-setup-file (file) + (if (not yas--creating-compiled-snippets) + ;; Normal case. + (load file 'noerror) + (let ((elfile (concat file ".el"))) + (when (file-exists-p elfile) + (insert ";;; .yas-setup.el support file if any:\n;;;\n") + (insert-file-contents elfile) + (goto-char (point-max)))))) + +(defun yas--define-parents (mode parents) + "Add PARENTS to the list of MODE's parents." + (puthash mode (remove-duplicates + (append parents + (gethash mode yas--parents))) + yas--parents)) + +(defun yas-load-directory (top-level-dir &optional use-jit interactive) + "Load snippets in directory hierarchy TOP-LEVEL-DIR. + +Below TOP-LEVEL-DIR each directory should be a mode name. + +With prefix argument USE-JIT do jit-loading of snippets." + (interactive + (list (read-directory-name "Select the root directory: " nil nil t) + current-prefix-arg t)) + (unless yas-snippet-dirs + (setq yas-snippet-dirs top-level-dir)) + (let ((impatient-buffers)) + (dolist (dir (yas--subdirs top-level-dir)) + (let* ((major-mode-and-parents (yas--compute-major-mode-and-parents + (concat dir "/dummy"))) + (mode-sym (car major-mode-and-parents)) + (parents (cdr major-mode-and-parents))) + ;; Attention: The parents and the menus are already defined + ;; here, even if the snippets are later jit-loaded. + ;; + ;; * We need to know the parents at this point since entering a + ;; given mode should jit load for its parents + ;; immediately. This could be reviewed, the parents could be + ;; discovered just-in-time-as well + ;; + ;; * We need to create the menus here to support the `full' + ;; option to `yas-use-menu' (all known snippet menus are shown to the user) + ;; + (yas--define-parents mode-sym parents) + (yas--menu-keymap-get-create mode-sym) + (let ((fun `(lambda () ;; FIXME: Simulating lexical-binding. + (yas--load-directory-1 ',dir ',mode-sym)))) + (if use-jit + (yas--schedule-jit mode-sym fun) + (funcall fun))) + ;; Look for buffers that are already in `mode-sym', and so + ;; need the new snippets immediately... + ;; + (when use-jit + (cl-loop for buffer in (buffer-list) + do (with-current-buffer buffer + (when (eq major-mode mode-sym) + (yas--message 3 "Discovered there was already %s in %s" buffer mode-sym) + (push buffer impatient-buffers))))))) + ;; ...after TOP-LEVEL-DIR has been completely loaded, call + ;; `yas--load-pending-jits' in these impatient buffers. + ;; + (cl-loop for buffer in impatient-buffers + do (with-current-buffer buffer (yas--load-pending-jits)))) + (when interactive + (yas--message 3 "Loaded snippets from %s." top-level-dir))) -(defun yas/quote-string (string) +(defun yas--load-directory-1 (directory mode-sym) + "Recursively load snippet templates from DIRECTORY." + (if yas--creating-compiled-snippets + (let ((output-file (expand-file-name ".yas-compiled-snippets.el" + directory))) + (with-temp-file output-file + (insert (format ";;; Compiled snippets and support files for `%s'\n" + mode-sym)) + (yas--load-directory-2 directory mode-sym) + (insert (format ";;; Do not edit! File generated at %s\n" + (current-time-string))))) + ;; Normal case. + (unless (file-exists-p (concat directory "/" ".yas-skip")) + (if (and (progn (yas--message 2 "Loading compiled snippets from %s" directory) t) + (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3))) + (yas--message 2 "Loading snippet files from %s" directory) + (yas--load-directory-2 directory mode-sym))))) + +(defun yas--load-directory-2 (directory mode-sym) + ;; Load .yas-setup.el files wherever we find them + ;; + (yas--load-yas-setup-file (expand-file-name ".yas-setup" directory)) + (let* ((default-directory directory) + (snippet-defs nil)) + ;; load the snippet files + ;; + (with-temp-buffer + (dolist (file (yas--subdirs directory 'no-subdirs-just-files)) + (when (file-readable-p file) + (insert-file-contents file nil nil nil t) + (push (yas--parse-template file) + snippet-defs)))) + (when snippet-defs + (yas-define-snippets mode-sym + snippet-defs)) + ;; now recurse to a lower level + ;; + (dolist (subdir (yas--subdirs directory)) + (yas--load-directory-2 subdir + mode-sym)))) + +(defun yas--load-snippet-dirs (&optional nojit) + "Reload the directories listed in `yas-snippet-dirs' or +prompt the user to select one." + (let (errors) + (if yas-snippet-dirs + (dolist (directory (reverse (yas-snippet-dirs))) + (cond ((file-directory-p directory) + (yas-load-directory directory (not nojit)) + (if nojit + (yas--message 3 "Loaded %s" directory) + (yas--message 3 "Prepared just-in-time loading for %s" directory))) + (t + (push (yas--message 0 "Check your `yas-snippet-dirs': %s is not a directory" directory) errors)))) + (call-interactively 'yas-load-directory)) + errors)) + +(defun yas-reload-all (&optional no-jit interactive) + "Reload all snippets and rebuild the YASnippet menu. + +When NO-JIT is non-nil force immediate reload of all known +snippets under `yas-snippet-dirs', otherwise use just-in-time +loading. + +When called interactively, use just-in-time loading when given a +prefix argument." + (interactive (list (not current-prefix-arg) t)) + (catch 'abort + (let ((errors) + (snippet-editing-buffers + (remove-if-not #'(lambda (buffer) + (with-current-buffer buffer yas--editing-template)) + (buffer-list)))) + ;; Warn if there are buffers visiting snippets, since reloading will break + ;; any on-line editing of those buffers. + ;; + (when snippet-editing-buffers + (if interactive + (if (y-or-n-p "Some buffers editing live snippets, close them and proceed with reload? ") + (mapc #'kill-buffer snippet-editing-buffers) + (yas--message 1 "Aborted reload...") + (throw 'abort nil)) + ;; in a non-interactive use, at least set + ;; `yas--editing-template' to nil, make it guess it next time around + (mapc #'(lambda (buffer) + (with-current-buffer buffer + (kill-local-variable 'yas--editing-template))) + (buffer-list)))) + + ;; Empty all snippet tables and parenting info + ;; + (setq yas--tables (make-hash-table)) + (setq yas--parents (make-hash-table)) + + ;; Before killing `yas--menu-table' use its keys to cleanup the + ;; mode menu parts of `yas--minor-mode-menu' (thus also cleaning + ;; up `yas-minor-mode-map', which points to it) + ;; + (maphash #'(lambda (menu-symbol _keymap) + (define-key yas--minor-mode-menu (vector menu-symbol) nil)) + yas--menu-table) + ;; Now empty `yas--menu-table' as well + (setq yas--menu-table (make-hash-table)) + + ;; Cancel all pending 'yas--scheduled-jit-loads' + ;; + (setq yas--scheduled-jit-loads (make-hash-table)) + + ;; Reload the directories listed in `yas-snippet-dirs' or prompt + ;; the user to select one. + ;; + (setq errors (yas--load-snippet-dirs no-jit)) + ;; Reload the direct keybindings + ;; + (yas-direct-keymaps-reload) + + (run-hooks 'yas-after-reload-hook) + (yas--message 3 "Reloaded everything%s...%s." + (if no-jit "" " (snippets will load just-in-time)") + (if errors " (some errors, check *Messages*)" ""))))) + +(defvar yas-after-reload-hook nil + "Hooks run after `yas-reload-all'.") + +(defun yas--load-pending-jits () + (dolist (mode (yas--modes-to-activate)) + (let ((funs (reverse (gethash mode yas--scheduled-jit-loads)))) + ;; must reverse to maintain coherence with `yas-snippet-dirs' + (dolist (fun funs) + (yas--message 3 "Loading for `%s', just-in-time: %s!" mode fun) + (funcall fun)) + (remhash mode yas--scheduled-jit-loads)))) + +;; (when (<= emacs-major-version 22) +;; (add-hook 'after-change-major-mode-hook 'yas--load-pending-jits)) + +(defun yas--quote-string (string) "Escape and quote STRING. foo\"bar\\! -> \"foo\\\"bar\\\\!\"" (concat "\"" @@ -1467,745 +1938,868 @@ foo\"bar\\! -> \"foo\\\"bar\\\\!\"" string t) "\"")) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Yasnippet Bundle + +;;; Snippet compilation function -(defun yas/initialize () - "For backward compatibility, enable `yas/minor-mode' globally" - (yas/global-mode 1)) +(defun yas-compile-directory (top-level-dir) + "Create .yas-compiled-snippets.el files under subdirs of TOP-LEVEL-DIR. -(defun yas/compile-bundle - (&optional yasnippet yasnippet-bundle snippet-roots code dropdown) - "Compile snippets in SNIPPET-ROOTS to a single bundle file. +This works by stubbing a few functions, then calling +`yas-load-directory'." + (interactive "DTop level snippet directory?") + (let ((yas--creating-compiled-snippets t)) + (yas-load-directory top-level-dir nil))) -YASNIPPET is the yasnippet.el file path. +(defun yas-recompile-all () + "Compile every dir in `yas-snippet-dirs'." + (interactive) + (mapc #'yas-compile-directory (yas-snippet-dirs))) -YASNIPPET-BUNDLE is the output file of the compile result. -SNIPPET-ROOTS is a list of root directories that contains the -snippets definition. +;;; JIT loading +;;; -CODE is the code to be placed at the end of the generated file -and that can initialize the YASnippet bundle. +(defvar yas--scheduled-jit-loads (make-hash-table) + "Alist of mode-symbols to forms to be evaled when `yas-minor-mode' kicks in.") -Last optional argument DROPDOWN is the filename of the -dropdown-list.el library. +(defun yas--schedule-jit (mode fun) + (push fun (gethash mode yas--scheduled-jit-loads))) -Here's the default value for all the parameters: - (yas/compile-bundle \"yasnippet.el\" - \"yasnippet-bundle.el\" - \"snippets\") - \"(yas/initialize-bundle) - ### autoload - (require 'yasnippet-bundle)`\" - \"dropdown-list.el\") -" - (interactive "ffind the yasnippet.el file: \nFTarget bundle file: \nDSnippet directory to bundle: \nMExtra code? \nfdropdown-library: ") - - (let* ((yasnippet (or yasnippet - "yasnippet.el")) - (yasnippet-bundle (or yasnippet-bundle - "./yasnippet-bundle.el")) - (snippet-roots (or snippet-roots - "snippets")) - (dropdown (or dropdown - "dropdown-list.el")) - (code (or (and code - (condition-case err (read code) (error nil)) - code) - (concat "(yas/initialize-bundle)" - "\n;;;###autoload" ; break through so that won't - "(require 'yasnippet-bundle)"))) - (dirs (or (and (listp snippet-roots) snippet-roots) - (list snippet-roots))) - (bundle-buffer nil)) - (with-temp-file yasnippet-bundle - (insert ";;; yasnippet-bundle.el --- " - "Yet another snippet extension (Auto compiled bundle)\n") - (insert-file-contents yasnippet) - (goto-char (point-max)) - (insert "\n") - (when dropdown - (insert-file-contents dropdown)) - (goto-char (point-max)) - (insert ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n") - (insert ";;;; Auto-generated code ;;;;\n") - (insert ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n") - (insert "(defun yas/initialize-bundle ()\n" - " \"Initialize YASnippet and load snippets in the bundle.\"") - (flet ((yas/define-snippets - (mode snippets &optional parent-or-parents) - (insert ";;; snippets for " (symbol-name mode) "\n") - (let ((literal-snippets (list))) - (dolist (snippet snippets) - (let ((key (first snippet)) - (template-content (second snippet)) - (name (third snippet)) - (condition (fourth snippet)) - (group (fifth snippet)) - (expand-env (sixth snippet)) - ;; Omit the file on purpose - (file nil) ;; (seventh snippet)) - (binding (eighth snippet))) - (push `(,key - ,template-content - ,name - ,condition - ,group - ,expand-env - ,file - ,binding) - literal-snippets))) - (insert (pp-to-string `(yas/define-snippets ',mode ',literal-snippets ',parent-or-parents))) - (insert "\n\n")))) - (dolist (dir dirs) - (dolist (subdir (yas/subdirs dir)) - (yas/load-directory-1 subdir nil 'no-hierarchy-parents)))) - - (insert (pp-to-string `(yas/global-mode 1))) - (insert ")\n\n" code "\n") - - ;; bundle-specific provide and value for yas/dont-activate - (let ((bundle-feature-name (file-name-nondirectory - (file-name-sans-extension - yasnippet-bundle)))) - (insert (pp-to-string `(set-default 'yas/dont-activate - #'(lambda () - (and (or yas/root-directory - (featurep ',(make-symbol bundle-feature-name))) - (null (yas/get-snippet-tables))))))) - (insert (pp-to-string `(provide ',(make-symbol bundle-feature-name))))) - - (insert ";;; " - (file-name-nondirectory yasnippet-bundle) - " ends here\n")))) - -(defun yas/compile-textmate-bundle () - (interactive) - (yas/compile-bundle "yasnippet.el" - "./yasnippet-textmate-bundle.el" - "extras/imported/" - (concat "(yas/initialize-bundle)" - "\n;;;###autoload" ; break through so that won't - "(require 'yasnippet-textmate-bundle)") - "dropdown-list.el")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;;; Some user level functions -;;; -(defun yas/about () +(defun yas-about () (interactive) (message (concat "yasnippet (version " - yas/version + yas--version ") -- pluskid /joaotavora "))) -(defun yas/define-snippets (mode snippets &optional parent-mode) - "Define SNIPPETS for MODE. - -SNIPPETS is a list of snippet definitions, each taking the -following form: - - (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING) - -Within these, only TEMPLATE is actually mandatory. - -All the elelements are strings, including CONDITION, EXPAND-ENV -and KEYBINDING which will be `read' and eventually `eval'-ed. - -FILE is probably of very little use if you're programatically -defining snippets. - -You can use `yas/parse-template' to return such lists based on -the current buffers contents. - -Optional PARENT-MODE can be used to specify the parent tables of -MODE. It can be a mode symbol of a list of mode symbols. It does -not need to be a real mode." - (let ((snippet-table (yas/snippet-table-get-create mode)) - (parent-tables (mapcar #'yas/snippet-table-get-create - (if (listp parent-mode) - parent-mode - (list parent-mode)))) - (keymap (if yas/use-menu - (yas/menu-keymap-get-create mode) - nil))) - ;; Setup the menu - ;; - (when parent-tables - (setf (yas/snippet-table-parents snippet-table) - parent-tables) - (when yas/use-menu - (let ((parent-menu-syms-and-names - (if (listp parent-mode) - (mapcar #'(lambda (sym) - (cons sym (concat "parent mode - " (symbol-name sym)))) - parent-mode) - '((parent-mode . "parent mode"))))) - (mapc #'(lambda (sym-and-name) - (define-key keymap - (vector (intern (replace-regexp-in-string " " "_" (cdr sym-and-name)))) - (list 'menu-item (cdr sym-and-name) - (yas/menu-keymap-get-create (car sym-and-name))))) - (reverse parent-menu-syms-and-names))))) - (when yas/use-menu - (define-key yas/minor-mode-menu (vector mode) - `(menu-item ,(symbol-name mode) ,keymap - :visible (yas/show-menu-p ',mode)))) - ;; Iterate the recently parsed snippets definition - ;; - (dolist (snippet snippets) - (let* ((file (seventh snippet)) - (key (or (car snippet) - (unless yas/ignore-filenames-as-triggers - (and file - (file-name-sans-extension (file-name-nondirectory file)))))) - (name (or (third snippet) - (and file - (file-name-directory file)))) - (condition (fourth snippet)) - (group (fifth snippet)) - (keybinding (eighth snippet)) - (template nil)) - ;; Read the snippet's "binding :" expression - ;; - (condition-case err - (when keybinding - (setq keybinding (read (eighth snippet))) - (let* ((this-mode-map-symbol (intern (concat (symbol-name mode) "-map"))) - (keys (or (and (consp keybinding) - (read-kbd-macro (cdr keybinding))) - (read-kbd-macro keybinding))) - (keymap-symbol (or (and (consp keybinding) - (car keybinding)) - this-mode-map-symbol))) - (if (and (boundp keymap-symbol) - (keymapp (symbol-value keymap-symbol))) - (setq keybinding (list keymap-symbol - keys - name)) - (error (format "keymap \"%s\" does not (yet?) exist" keymap-symbol))))) - (error - (message "[yas] warning: keybinding \"%s\" invalid for snippet \"%s\" since %s." - keybinding name (error-message-string err)) - (setf keybinding nil))) - - ;; Create the `yas/template' object and store in the - ;; appropriate snippet table. This only done if we have found - ;; a key and a name for the snippet, because that is what - ;; indexes the snippet tables - ;; - (setq template (yas/make-template (second snippet) - (or name key) - condition - (sixth snippet) - (seventh snippet) - keybinding)) - (when (and key - name) - (yas/store snippet-table - name - key - template)) - ;; If we have a keybinding, register it if it does not - ;; conflict! - ;; - (when keybinding - (let ((lookup (lookup-key (symbol-value (first keybinding)) (second keybinding)))) - (if (and lookup - (not (numberp lookup))) - (message "[yas] warning: won't overwrite keybinding \"%s\" for snippet \"%s\" in `%s'" - (key-description (second keybinding)) name (first keybinding)) - (define-key - (symbol-value (first keybinding)) - (second keybinding) - `(lambda (&optional yas/prefix) - (interactive "P") - (when (yas/template-can-expand-p ,(yas/template-condition template)) - (yas/expand-snippet ,(yas/template-content template) - nil - nil - ,(yas/template-expand-env template))))) - (add-to-list 'yas/active-keybindings keybinding)))) - - ;; Setup the menu groups, reorganizing from group to group if - ;; necessary - ;; - (when yas/use-menu - (let ((group-keymap keymap)) - ;; Delete this entry from another group if already exists - ;; in some other group. An entry is considered as existing - ;; in another group if its name string-matches. - ;; - (yas/delete-from-keymap group-keymap name) - - ;; ... then add this entry to the correct group - (when (and (not (null group)) - (not (string= "" group))) - (dolist (subgroup (mapcar #'make-symbol - (split-string group "\\."))) - (let ((subgroup-keymap (lookup-key group-keymap - (vector subgroup)))) - (when (null subgroup-keymap) - (setq subgroup-keymap (make-sparse-keymap)) - (define-key group-keymap (vector subgroup) - `(menu-item ,(symbol-name subgroup) - ,subgroup-keymap))) - (setq group-keymap subgroup-keymap)))) - (define-key group-keymap (vector (gensym)) - `(menu-item ,(yas/template-name template) - ,(yas/make-menu-binding template) - :help ,name - :keys ,(when (and key name) - (concat key yas/trigger-symbol)))))))))) - -(defun yas/show-menu-p (mode) - (cond ((eq yas/use-menu 'abbreviate) + +;;; Apropos snippet menu: +;; +;; The snippet menu keymaps are store by mode in hash table called +;; `yas--menu-table'. They are linked to the main menu in +;; `yas--menu-keymap-get-create' and are initially created empty, +;; reflecting the table hierarchy. +;; +;; They can be populated in two mutually exclusive ways: (1) by +;; reading `yas--template-group', which in turn is populated by the "# +;; group:" directives of the snippets or the ".yas-make-groups" file +;; or (2) by using a separate `yas-define-menu' call, which declares a +;; menu structure based on snippets uuids. +;; +;; Both situations are handled in `yas--update-template-menu', which +;; uses the predicate `yas--template-menu-managed-by-yas-define-menu' +;; that can tell between the two situations. +;; +;; Note: +;; +;; * if `yas-define-menu' is used it must run before +;; `yas-define-snippets' and the UUIDS must match, otherwise we get +;; duplicate entries. The `yas--template' objects are created in +;; `yas-define-menu', holding nothing but the menu entry, +;; represented by a pair of ((menu-item NAME :keys KEYS) TYPE) and +;; stored in `yas--template-menu-binding-pair'. The (menu-item ...) +;; part is then stored in the menu keymap itself which make the item +;; appear to the user. These limitations could probably be revised. +;; +;; * The `yas--template-perm-group' slot is only used in +;; `yas-describe-tables'. +;; +(defun yas--template-menu-binding-pair-get-create (template &optional type) + "Get TEMPLATE's menu binding or assign it a new one. + +TYPE may be `:stay', signaling this menu binding should be +static in the menu." + (or (yas--template-menu-binding-pair template) + (let (;; (key (yas--template-key template)) + ;; (keybinding (yas--template-keybinding template)) + ) + (setf (yas--template-menu-binding-pair template) + (cons `(menu-item ,(or (yas--template-name template) + (yas--template-uuid template)) + ,(yas--make-menu-binding template) + :keys ,nil) + type))))) +(defun yas--template-menu-managed-by-yas-define-menu (template) + "Non-nil if TEMPLATE's menu entry was included in a `yas-define-menu' call." + (cdr (yas--template-menu-binding-pair template))) + + +(defun yas--show-menu-p (mode) + (cond ((eq yas-use-menu 'abbreviate) (find mode (mapcar #'(lambda (table) - (intern (yas/snippet-table-name table))) - (yas/get-snippet-tables)))) - ((eq yas/use-menu 'real-modes) - (yas/real-mode? mode)) - (t - t))) + (yas--table-mode table)) + (yas--get-snippet-tables)))) + (yas-use-menu t))) -(defun yas/delete-from-keymap (keymap name) - "Recursively delete items name NAME from KEYMAP and its submenus. +(defun yas--delete-from-keymap (keymap uuid) + "Recursively delete items with UUID from KEYMAP and its submenus." -Skip any submenus named \"parent mode\"" + ;; XXX: This used to skip any submenus named \"parent mode\" + ;; ;; First of all, recursively enter submenus, i.e. the tree is ;; searched depth first so that stale submenus can be found in the ;; higher passes. ;; (mapc #'(lambda (item) - (when (and (keymapp (fourth item)) - (stringp (third item)) - (not (string-match "parent mode" (third item)))) - (yas/delete-from-keymap (fourth item) name))) + (when (and (listp (cdr item)) + (keymapp (third (cdr item)))) + (yas--delete-from-keymap (third (cdr item)) uuid))) (rest keymap)) + ;; Set the uuid entry to nil + ;; + (define-key keymap (vector (make-symbol uuid)) nil) + ;; Destructively modify keymap ;; - (when (keymapp keymap) - (let ((pos-in-keymap)) - (while (setq pos-in-keymap - (position-if #'(lambda (item) - (and (listp item) - (or - ;; the menu item we want to delete - (and (eq 'menu-item (second item)) - (third item) - (and (string= (third item) name))) - ;; a stale subgroup - (and (keymapp (fourth item)) - (not (and (stringp (third item)) - (string-match "parent mode" - (third item)))) - (null (rest (fourth item))))))) - keymap)) - (setf (nthcdr pos-in-keymap keymap) - (nthcdr (+ 1 pos-in-keymap) keymap)))))) - -(defun yas/define (mode key template &optional name condition group) + (setcdr keymap (delete-if #'(lambda (item) + (or (null (cdr item)) + (and (keymapp (third (cdr item))) + (null (cdr (third (cdr item))))))) + (rest keymap)))) + +(defun yas-define-menu (mode menu &optional omit-items) + "Define a snippet menu for MODE according to MENU, omitting OMIT-ITEMS. + +MENU is a list, its elements can be: + +- (yas-item UUID) : Creates an entry the snippet identified with + UUID. The menu entry for a snippet thus identified is + permanent, i.e. it will never move (be reordered) in the menu. + +- (yas-separator) : Creates a separator + +- (yas-submenu NAME SUBMENU) : Creates a submenu with NAME, + SUBMENU has the same form as MENU. NAME is also added to the + list of groups of the snippets defined thereafter. + +OMIT-ITEMS is a list of snippet uuid's that will always be +omitted from MODE's menu, even if they're manually loaded." + (let* ((table (yas--table-get-create mode)) + (hash (yas--table-uuidhash table))) + (yas--define-menu-1 table + (yas--menu-keymap-get-create mode) + menu + hash) + (dolist (uuid omit-items) + (let ((template (or (gethash uuid hash) + (yas--populate-template (puthash uuid + (yas--make-blank-template) + hash) + :table table + :uuid uuid)))) + (setf (yas--template-menu-binding-pair template) (cons nil :none)))))) + +(defun yas--define-menu-1 (table menu-keymap menu uuidhash &optional group-list) + "Helper for `yas-define-menu'." + (dolist (e (reverse menu)) + (cond ((eq (first e) 'yas-item) + (let ((template (or (gethash (second e) uuidhash) + (yas--populate-template (puthash (second e) + (yas--make-blank-template) + uuidhash) + :table table + :perm-group group-list + :uuid (second e))))) + (define-key menu-keymap (vector (gensym)) + (car (yas--template-menu-binding-pair-get-create template :stay))))) + ((eq (first e) 'yas-submenu) + (let ((subkeymap (make-sparse-keymap))) + (define-key menu-keymap (vector (gensym)) + `(menu-item ,(second e) ,subkeymap)) + (yas--define-menu-1 table + subkeymap + (third e) + uuidhash + (append group-list (list (second e)))))) + ((eq (first e) 'yas-separator) + (define-key menu-keymap (vector (gensym)) + '(menu-item "----"))) + (t + (yas--message 3 "Don't know anything about menu entry %s" (first e)))))) + +(defun yas--define (mode key template &optional name condition group) "Define a snippet. Expanding KEY into TEMPLATE. NAME is a description to this template. Also update the menu if -`yas/use-menu' is `t'. CONDITION is the condition attached to +`yas-use-menu' is t. CONDITION is the condition attached to this snippet. If you attach a condition to a snippet, then it will only be expanded when the condition evaluated to non-nil." - (yas/define-snippets mode + (yas-define-snippets mode (list (list key template name condition group)))) -(defun yas/hippie-try-expand (first-time?) - "Integrate with hippie expand. Just put this function in -`hippie-expand-try-functions-list'." - (if (not first-time?) - (let ((yas/fallback-behavior 'return-nil)) - (yas/expand)) - (undo 1) - nil)) +(defun yas-hippie-try-expand (first-time?) + "Integrate with hippie expand. + +Just put this function in `hippie-expand-try-functions-list'." + (when yas-minor-mode + (if (not first-time?) + (let ((yas-fallback-behavior 'return-nil)) + (yas-expand)) + (undo 1) + nil))) + -(defun yas/expand () +;;; Apropos condition-cache: +;;; +;;; +;;; +;;; +(defvar yas--condition-cache-timestamp nil) +(defmacro yas-define-condition-cache (func doc &rest body) + "Define a function FUNC with doc DOC and body BODY. +BODY is executed at most once every snippet expansion attempt, to check +expansion conditions. + +It doesn't make any sense to call FUNC programatically." + `(defun ,func () ,(if (and doc + (stringp doc)) + (concat doc +"\n\nFor use in snippets' conditions. Within each +snippet-expansion routine like `yas-expand', computes actual +value for the first time then always returns a cached value.") + (setq body (cons doc body)) + nil) + (let ((timestamp-and-value (get ',func 'yas--condition-cache))) + (if (equal (car timestamp-and-value) yas--condition-cache-timestamp) + (cdr timestamp-and-value) + (let ((new-value (progn + ,@body + ))) + (put ',func 'yas--condition-cache (cons yas--condition-cache-timestamp new-value)) + new-value))))) + +(defalias 'yas-expand 'yas-expand-from-trigger-key) +(defun yas-expand-from-trigger-key (&optional field) "Expand a snippet before point. If no snippet expansion is possible, fall back to the behaviour -defined in `yas/fallback-behavior'" +defined in `yas-fallback-behavior'. + +Optional argument FIELD is for non-interactive use and is an +object satisfying `yas--field-p' to restrict the expansion to." + (interactive) + (setq yas--condition-cache-timestamp (current-time)) + (let (templates-and-pos) + (unless (and yas-expand-only-for-last-commands + (not (member last-command yas-expand-only-for-last-commands))) + (setq templates-and-pos (if field + (save-restriction + (narrow-to-region (yas--field-start field) + (yas--field-end field)) + (yas--templates-for-key-at-point)) + (yas--templates-for-key-at-point)))) + (if templates-and-pos + (yas--expand-or-prompt-for-template (first templates-and-pos) + (second templates-and-pos) + (third templates-and-pos)) + (yas--fallback)))) + +(defun yas-expand-from-keymap () + "Directly expand some snippets, searching `yas--direct-keymaps'. + +If expansion fails, execute the previous binding for this key" (interactive) - (yas/expand-1)) - -(defun yas/expand-1 (&optional field) - "Actually fo the work for `yas/expand'" - (multiple-value-bind (templates start end) (if field - (save-restriction - (narrow-to-region (yas/field-start field) (yas/field-end field)) - (yas/current-key)) - (yas/current-key)) + (setq yas--condition-cache-timestamp (current-time)) + (let* ((vec (subseq (this-command-keys-vector) (if current-prefix-arg + (length (this-command-keys)) + 0))) + (templates (mapcan #'(lambda (table) + (yas--fetch table vec)) + (yas--get-snippet-tables)))) (if templates - (let ((template (or (and (rest templates) ;; more than one - (yas/prompt-for-template (mapcar #'cdr templates))) - (cdar templates)))) - (when template - (yas/expand-snippet (yas/template-content template) - start - end - (yas/template-expand-env template)))) - (cond ((eq yas/fallback-behavior 'return-nil) - ;; return nil - nil) - ((eq yas/fallback-behavior 'call-other-command) - (let* ((yas/minor-mode nil) - (keys-1 (this-command-keys-vector)) - (keys-2 (and yas/trigger-key - (stringp yas/trigger-key) - (read-kbd-macro yas/trigger-key))) - (command-1 (and keys-1 (key-binding keys-1))) - (command-2 (and keys-2 (key-binding keys-2))) - (command (or (and (not (eq command-1 'yas/expand)) - command-1) - command-2))) - (when (and (commandp command) - (not (eq 'yas/expand command))) - (setq this-command command) - (call-interactively command)))) - ((and (listp yas/fallback-behavior) - (cdr yas/fallback-behavior) - (eq 'apply (car yas/fallback-behavior))) - (if (cddr yas/fallback-behavior) - (apply (cadr yas/fallback-behavior) - (cddr yas/fallback-behavior)) - (when (commandp (cadr yas/fallback-behavior)) - (setq this-command (cadr yas/fallback-behavior)) - (call-interactively (cadr yas/fallback-behavior))))) - (t - ;; also return nil if all the other fallbacks have failed - nil))))) + (yas--expand-or-prompt-for-template templates) + (let ((yas-fallback-behavior 'call-other-command)) + (yas--fallback))))) + +(defun yas--expand-or-prompt-for-template (templates &optional start end) + "Expand one of TEMPLATES from START to END. + +Prompt the user if TEMPLATES has more than one element, else +expand immediately. Common gateway for +`yas-expand-from-trigger-key' and `yas-expand-from-keymap'." + (let ((yas--current-template (or (and (rest templates) ;; more than one + (yas--prompt-for-template (mapcar #'cdr templates))) + (cdar templates)))) + (when yas--current-template + (yas-expand-snippet (yas--template-content yas--current-template) + start + end + (yas--template-expand-env yas--current-template))))) + +;; Apropos the trigger key and the fallback binding: +;; +;; When `yas-minor-mode-map' binds , that correctly overrides +;; org-mode's , for example and searching for fallbacks correctly +;; returns `org-cycle'. However, most other modes bind "TAB". TODO, +;; improve this explanation. +;; +(defun yas--fallback () + "Fallback after expansion has failed. + +Common gateway for `yas-expand-from-trigger-key' and +`yas-expand-from-keymap'." + (cond ((eq yas-fallback-behavior 'return-nil) + ;; return nil + nil) + ((eq yas-fallback-behavior 'yas--fallback) + (error (concat "yasnippet fallback loop!\n" + "This can happen when you bind `yas-expand' " + "outside of the `yas-minor-mode-map'."))) + ((eq yas-fallback-behavior 'call-other-command) + (let* ((yas-fallback-behavior 'yas--fallback) + ;; Also bind `yas-minor-mode' to prevent fallback + ;; loops when other extensions use mechanisms similar + ;; to `yas--keybinding-beyond-yasnippet'. (github #525 + ;; and #526) + ;; + (yas-minor-mode nil) + (beyond-yasnippet (yas--keybinding-beyond-yasnippet))) + (yas--message 4 "Falling back to %s" beyond-yasnippet) + (assert (or (null beyond-yasnippet) (commandp beyond-yasnippet))) + (setq this-original-command beyond-yasnippet) + (when beyond-yasnippet + (call-interactively beyond-yasnippet)))) + ((and (listp yas-fallback-behavior) + (cdr yas-fallback-behavior) + (eq 'apply (car yas-fallback-behavior))) + (let ((command-or-fn (cadr yas-fallback-behavior)) + (args (cddr yas-fallback-behavior)) + (yas-fallback-behavior 'yas--fallback) + (yas-minor-mode nil)) + (if args + (apply command-or-fn args) + (when (commandp command-or-fn) + (setq this-command command-or-fn) + (call-interactively command-or-fn))))) + (t + ;; also return nil if all the other fallbacks have failed + nil))) + +(defun yas--keybinding-beyond-yasnippet () + "Get current keys's binding as if YASsnippet didn't exist." + (let* ((yas-minor-mode nil) + (yas--direct-keymaps nil) + (keys (this-single-command-keys))) + (or (key-binding keys t) + (key-binding (yas--fallback-translate-input keys) t)))) + +(defun yas--fallback-translate-input (keys) + "Emulate `read-key-sequence', at least what I think it does. + +Keys should be an untranslated key vector. Returns a translated +vector of keys. FIXME not thoroughly tested." + (let ((retval []) + (i 0)) + (while (< i (length keys)) + (let ((j i) + (translated local-function-key-map)) + (while (and (< j (length keys)) + translated + (keymapp translated)) + (setq translated (cdr (assoc (aref keys j) (remove 'keymap translated))) + j (1+ j))) + (setq retval (vconcat retval (cond ((symbolp translated) + `[,translated]) + ((vectorp translated) + translated) + (t + (substring keys i j))))) + (setq i j))) + retval)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Snippet development +;;; Utils for snippet development: -(defun yas/all-templates (tables) - "Return all snippet tables applicable for the current buffer. +(defun yas--all-templates (tables) + "Get `yas--template' objects in TABLES, applicable for buffer and point. -Honours `yas/choose-tables-first', `yas/choose-keys-first' and -`yas/buffer-local-condition'" - (when yas/choose-tables-first - (setq tables (list (yas/prompt-for-table tables)))) +Honours `yas-choose-tables-first', `yas-choose-keys-first' and +`yas-buffer-local-condition'" + (when yas-choose-tables-first + (setq tables (list (yas--prompt-for-table tables)))) (mapcar #'cdr - (if yas/choose-keys-first - (let ((key (yas/prompt-for-keys - (mapcan #'yas/snippet-table-all-keys tables)))) + (if yas-choose-keys-first + (let ((key (yas--prompt-for-keys + (mapcan #'yas--table-all-keys tables)))) (when key (mapcan #'(lambda (table) - (yas/fetch table key)) + (yas--fetch table key)) tables))) - (mapcan #'yas/snippet-table-templates tables)))) + (remove-duplicates (mapcan #'yas--table-templates tables) + :test #'equal)))) -(defun yas/insert-snippet (&optional no-condition) +(defun yas-insert-snippet (&optional no-condition) "Choose a snippet to expand, pop-up a list of choices according -to `yas/prompt-function'. +to `yas-prompt-functions'. With prefix argument NO-CONDITION, bypass filtering of snippets by condition." (interactive "P") - (let* ((yas/buffer-local-condition (or (and no-condition + (setq yas--condition-cache-timestamp (current-time)) + (let* ((yas-buffer-local-condition (or (and no-condition 'always) - yas/buffer-local-condition)) - (templates (yas/all-templates (yas/get-snippet-tables))) - (template (and templates - (or (and (rest templates) ;; more than one template for same key - (yas/prompt-for-template templates)) - (car templates)))) - (where (if mark-active + yas-buffer-local-condition)) + (templates (yas--all-templates (yas--get-snippet-tables))) + (yas--current-template (and templates + (or (and (rest templates) ;; more than one template for same key + (yas--prompt-for-template templates)) + (car templates)))) + (where (if (region-active-p) (cons (region-beginning) (region-end)) (cons (point) (point))))) - (if template - (yas/expand-snippet (yas/template-content template) + (if yas--current-template + (yas-expand-snippet (yas--template-content yas--current-template) (car where) (cdr where) - (yas/template-expand-env template)) - (message "[yas] No snippets can be inserted here!")))) + (yas--template-expand-env yas--current-template)) + (yas--message 3 "No snippets can be inserted here!")))) -(defun yas/visit-snippet-file () - "Choose a snippet to edit, selection like `yas/insert-snippet'. +(defun yas-visit-snippet-file () + "Choose a snippet to edit, selection like `yas-insert-snippet'. Only success if selected snippet was loaded from a file. Put the visited file in `snippet-mode'." (interactive) - (let* ((yas/buffer-local-condition 'always) - (templates (yas/all-templates (yas/get-snippet-tables))) + (let* ((yas-buffer-local-condition 'always) + (templates (yas--all-templates (yas--get-snippet-tables))) + (yas-prompt-functions '(yas-ido-prompt yas-completing-prompt)) (template (and templates - (or (and (rest templates) ;; more than one template for same key - (yas/prompt-for-template templates - "Choose a snippet template to edit: ")) + (or (yas--prompt-for-template templates + "Choose a snippet template to edit: ") (car templates))))) - (when template - (yas/visit-snippet-file-1 template)))) + (if template + (yas--visit-snippet-file-1 template) + (message "No snippets tables active!")))) -(defun yas/visit-snippet-file-1 (template) - (let ((file (yas/template-file template))) - (cond ((and file (file-exists-p file)) +(defun yas--visit-snippet-file-1 (template) + "Helper for `yas-visit-snippet-file'." + (let ((file (yas--template-file template))) + (cond ((and file (file-readable-p file)) (find-file-other-window file) - (snippet-mode)) + (snippet-mode) + (set (make-local-variable 'yas--editing-template) template)) (file (message "Original file %s no longer exists!" file)) (t - (message "This snippet was not loaded from a file!"))))) - -(defun yas/guess-snippet-directories-1 (table &optional suffix) - "Guesses possible snippet subdirsdirectories for TABLE." - (unless suffix - (setq suffix (yas/snippet-table-name table))) - (cons suffix + (switch-to-buffer (format "*%s*"(yas--template-name template))) + (let ((type 'snippet)) + (when (listp (yas--template-content template)) + (insert (format "# type: command\n")) + (setq type 'command)) + (insert (format "# key: %s\n" (yas--template-key template))) + (insert (format "# name: %s\n" (yas--template-name template))) + (when (yas--template-keybinding template) + (insert (format "# binding: %s\n" (yas--template-keybinding template)))) + (when (yas--template-expand-env template) + (insert (format "# expand-env: %s\n" (yas--template-expand-env template)))) + (when (yas--template-condition template) + (insert (format "# condition: %s\n" (yas--template-condition template)))) + (insert "# --\n") + (insert (if (eq type 'command) + (pp-to-string (yas--template-content template)) + (yas--template-content template)))) + (snippet-mode) + (set (make-local-variable 'yas--editing-template) template))))) + +(defun yas--guess-snippet-directories-1 (table) + "Guess possible snippet subdirectories for TABLE." + (cons (yas--table-name table) (mapcan #'(lambda (parent) - (yas/guess-snippet-directories-1 - parent - (concat (yas/snippet-table-name parent) "/" suffix))) - (yas/snippet-table-parents table)))) + (yas--guess-snippet-directories-1 + parent)) + (yas--table-parents table)))) -(defun yas/guess-snippet-directories () +(defun yas--guess-snippet-directories (&optional table) "Try to guess suitable directories based on the current active -tables. +tables (or optional TABLE). + +Returns a list of elements (TABLE . DIRS) where TABLE is a +`yas--table' object and DIRS is a list of all possible directories +where snippets of table might exist." + (let ((main-dir (replace-regexp-in-string + "/+$" "" + (or (first (or (yas-snippet-dirs) + (setq yas-snippet-dirs '("~/.emacs.d/snippets"))))))) + (tables (or (and table + (list table)) + (yas--get-snippet-tables)))) + ;; HACK! the snippet table created here is actually registered! + ;; + (unless (or table (gethash major-mode yas--tables)) + (push (yas--table-get-create major-mode) + tables)) -Returns a a list of options alist TABLE -> DIRS where DIRS are -all the possibly directories where snippets of table might be -lurking." - (let ((main-dir (or (and (listp yas/root-directory) - (first yas/root-directory)) - yas/root-directory - (setq yas/root-directory "~/.emacs.d/snippets"))) - (tables (yas/get-snippet-tables))) - ;; HACK! the snippet table created here is a dummy table that - ;; holds the correct name so that `yas/make-directory-maybe' can - ;; work. The real table, if it does not exist in - ;; yas/snippet-tables will be created when the first snippet for - ;; that mode is loaded. - ;; - (unless (gethash major-mode yas/snippet-tables) - (setq tables (cons (yas/make-snippet-table (symbol-name major-mode)) - tables))) - (mapcar #'(lambda (table) (cons table (mapcar #'(lambda (subdir) (concat main-dir "/" subdir)) - (yas/guess-snippet-directories-1 table)))) + (yas--guess-snippet-directories-1 table)))) tables))) -(defun yas/make-directory-maybe (table-and-dirs &optional main-table-string) - "Returns a dir inside TABLE-AND-DIRS, prompts for creation if none exists." +(defun yas--make-directory-maybe (table-and-dirs &optional main-table-string) + "Return a dir inside TABLE-AND-DIRS, prompts for creation if none exists." (or (some #'(lambda (dir) (when (file-directory-p dir) dir)) (cdr table-and-dirs)) (let ((candidate (first (cdr table-and-dirs)))) + (unless (file-writable-p (file-name-directory candidate)) + (error (yas--format "%s is not writable." candidate))) (if (y-or-n-p (format "Guessed directory (%s) for%s%s table \"%s\" does not exist! Create? " candidate - (if (gethash (intern (yas/snippet-table-name (car table-and-dirs))) - yas/snippet-tables) + (if (gethash (yas--table-mode (car table-and-dirs)) + yas--tables) "" " brand new") (or main-table-string "") - (yas/snippet-table-name (car table-and-dirs)))) + (yas--table-name (car table-and-dirs)))) (progn (make-directory candidate 'also-make-parents) ;; create the .yas-parents file here... candidate))))) -(defun yas/new-snippet (&optional choose-instead-of-guess) - "" - (interactive "P") - (let* ((guessed-directories (yas/guess-snippet-directories)) - (option (or (and choose-instead-of-guess - (some #'(lambda (fn) - (funcall fn "Choose a snippet table: " - guessed-directories - #'(lambda (option) - (yas/snippet-table-name (car option))))) - yas/prompt-functions)) - (first guessed-directories))) - (chosen)) - (setq chosen (yas/make-directory-maybe option (unless choose-instead-of-guess - " main"))) - (unless (or chosen - choose-instead-of-guess) - (if (y-or-n-p (format "Continue guessing for other active tables %s? " - (mapcar #'(lambda (table-and-dirs) - (yas/snippet-table-name (car table-and-dirs))) - (rest guessed-directories)))) - (setq chosen (some #'yas/make-directory-maybe - (rest guessed-directories))))) - (unless (or chosen - choose-instead-of-guess) - (when (y-or-n-p "Having trouble... use snippet root dir? ") - (setq chosen (if (listp yas/root-directory) - (first yas/root-directory) - yas/root-directory)))) - (if chosen - (let ((default-directory chosen) - (name (read-from-minibuffer "Enter a snippet name: "))) - (find-file-other-window (concat name - ".yasnippet")) - (snippet-mode) - (unless (and choose-instead-of-guess - (not (y-or-n-p "Insert a snippet with useful headers? "))) - (yas/expand-snippet (format - "\ -# -*- mode: snippet -*- -# name: %s -# key: $1${2: -# binding: \"${3:keybinding}\"}${4: -# expand-env: ((${5:some-var} ${6:some-value}))} -# -- -$0" name)))) - (message "[yas] aborted snippet creation.")))) - -(defun yas/find-snippets (&optional same-window ) - "Look for user snippets in guessed current mode's directory. - -Calls `find-file' interactively in the guessed directory. +(defun yas-new-snippet (&optional no-template) + "Pops a new buffer for writing a snippet. -With prefix arg SAME-WINDOW opens the buffer in the same window. - -Because snippets can be loaded from many different locations, -this has to guess the correct directory using -`yas/guess-snippet-directories', which returns a list of -options. - -If any one of these exists, it is taken and `find-file' is called -there, otherwise, proposes to create the first option returned by -`yas/guess-snippet-directories'." +Expands a snippet-writing snippet, unless the optional prefix arg +NO-TEMPLATE is non-nil." (interactive "P") - (let* ((guessed-directories (yas/guess-snippet-directories)) - (chosen) - (buffer)) - (setq chosen (yas/make-directory-maybe (first guessed-directories) " main")) - (unless chosen - (if (y-or-n-p (format "Continue guessing for other active tables %s? " - (mapcar #'(lambda (table-and-dirs) - (yas/snippet-table-name (car table-and-dirs))) - (rest guessed-directories)))) - (setq chosen (some #'yas/make-directory-maybe - (rest guessed-directories))))) - (unless chosen - (when (y-or-n-p "Having trouble... go to snippet root dir? ") - (setq chosen (if (listp yas/root-directory) - (first yas/root-directory) - yas/root-directory)))) - (if chosen - (let ((default-directory chosen)) - (setq buffer (call-interactively (if same-window - 'find-file - 'find-file-other-window))) - (when buffer - (save-excursion - (set-buffer buffer) - (when (eq major-mode 'fundamental-mode) - (snippet-mode))))) - (message "Could not guess snippet dir!")))) - -(defun yas/compute-major-mode-and-parents (file &optional prompt-if-failed no-hierarchy-parents) + (let ((guessed-directories (yas--guess-snippet-directories))) + + (switch-to-buffer "*new snippet*") + (erase-buffer) + (kill-all-local-variables) + (snippet-mode) + (yas-minor-mode 1) + (set (make-local-variable 'yas--guessed-modes) (mapcar #'(lambda (d) + (yas--table-mode (car d))) + guessed-directories)) + (if (and (not no-template) yas-new-snippet-default) + (yas-expand-snippet yas-new-snippet-default)))) + +(defun yas--compute-major-mode-and-parents (file) + "Given FILE, find the nearest snippet directory for a given mode. + +Returns a list (MODE-SYM PARENTS), the mode's symbol and a list +representing one or more of the mode's parents. + +Note that MODE-SYM need not be the symbol of a real major mode, +neither do the elements of PARENTS." (let* ((file-dir (and file - (directory-file-name (or (locate-dominating-file file ".yas-make-groups") + (directory-file-name (or (some #'(lambda (special) + (locate-dominating-file file special)) + '(".yas-setup.el" + ".yas-make-groups" + ".yas-parents")) (directory-file-name (file-name-directory file)))))) + (parents-file-name (concat file-dir "/.yas-parents")) (major-mode-name (and file-dir (file-name-nondirectory file-dir))) - (parent-file-dir (and file-dir - (directory-file-name (file-name-directory file-dir)))) - (parent-mode-name (and parent-file-dir - (not no-hierarchy-parents) - (file-name-nondirectory parent-file-dir))) (major-mode-sym (or (and major-mode-name - (intern major-mode-name)) - (when prompt-if-failed - (read-from-minibuffer - "[yas] Cannot auto-detect major mode! Enter a major mode: ")))) - (parent-mode-sym (and parent-mode-name - (intern parent-mode-name))) - (extra-parents-file-name (concat file-dir "/.yas-parents")) - (more-parents (when (file-readable-p extra-parents-file-name) + (intern major-mode-name)))) + (parents (when (file-readable-p parents-file-name) (mapcar #'intern (split-string (with-temp-buffer - (insert-file-contents extra-parents-file-name) + (insert-file-contents parents-file-name) (buffer-substring-no-properties (point-min) (point-max)))))))) (when major-mode-sym - (remove nil (append (list major-mode-sym parent-mode-sym) - more-parents))))) - -(defun yas/load-snippet-buffer (&optional kill) - "Parse and load current buffer's snippet definition. - -With optional prefix argument KILL quit the window and buffer." - (interactive "P") - (if buffer-file-name - (let ((major-mode-and-parent (yas/compute-major-mode-and-parents buffer-file-name))) - (if major-mode-and-parent - (let* ((parsed (yas/parse-template buffer-file-name)) - (name (and parsed - (third parsed)))) - (when name - (let ((yas/better-guess-for-replacements t)) - (yas/define-snippets (car major-mode-and-parent) - (list parsed) - (cdr major-mode-and-parent))) - (when (and (buffer-modified-p) - (y-or-n-p "Save snippet? ")) - (save-buffer)) - (if kill - (quit-window kill) - (message "[yas] Snippet \"%s\" loaded for %s." - name - (car major-mode-and-parent))))) - (message "[yas] Cannot load snippet for unknown major mode"))) - (message "Save the buffer as a file first!"))) - -(defun yas/tryout-snippet (&optional debug) - "Test current buffers's snippet template in other buffer." + (cons major-mode-sym (remove major-mode-sym parents))))) + +(defvar yas--editing-template nil + "Supporting variable for `yas-load-snippet-buffer' and `yas--visit-snippet'.") + +(defvar yas--current-template nil + "Holds the current template being expanded into a snippet.") + +(defvar yas--guessed-modes nil + "List of guessed modes supporting `yas-load-snippet-buffer'.") + +(defun yas--read-table () + "Ask user for a snippet table, help with some guessing." + (let ((prompt (if (and (featurep 'ido) + ido-mode) + 'ido-completing-read 'completing-read))) + (unless yas--guessed-modes + (set (make-local-variable 'yas--guessed-modes) + (or (yas--compute-major-mode-and-parents buffer-file-name)))) + (intern + (funcall prompt (format "Choose or enter a table (yas guesses %s): " + (if yas--guessed-modes + (first yas--guessed-modes) + "nothing")) + (mapcar #'symbol-name yas--guessed-modes) + nil + nil + nil + nil + (if (first yas--guessed-modes) + (symbol-name (first yas--guessed-modes))))))) + +(defun yas-load-snippet-buffer (table &optional interactive) + "Parse and load current buffer's snippet definition into TABLE. + +TABLE is a symbol naming a passed to `yas--table-get-create'. + +When called interactively, prompt for the table name." + (interactive (list (yas--read-table) t)) + (cond + ;; We have `yas--editing-template', this buffer's content comes from a + ;; template which is already loaded and neatly positioned,... + ;; + (yas--editing-template + (yas--define-snippets-1 (yas--parse-template (yas--template-file yas--editing-template)) + (yas--template-table yas--editing-template))) + ;; Try to use `yas--guessed-modes'. If we don't have that use the + ;; value from `yas--compute-major-mode-and-parents' + ;; + (t + (unless yas--guessed-modes + (set (make-local-variable 'yas--guessed-modes) (or (yas--compute-major-mode-and-parents buffer-file-name)))) + (let* ((table (yas--table-get-create table))) + (set (make-local-variable 'yas--editing-template) + (yas--define-snippets-1 (yas--parse-template buffer-file-name) + table))))) + (when interactive + (yas--message 3 "Snippet \"%s\" loaded for %s." + (yas--template-name yas--editing-template) + (yas--table-name (yas--template-table yas--editing-template))))) + +(defun yas-load-snippet-buffer-and-close (table &optional kill) + "Load the snippet with `yas-load-snippet-buffer', possibly + save, then `quit-window' if saved. + +If the snippet is new, ask the user whether (and where) to save +it. If the snippet already has a file, just save it. + +The prefix argument KILL is passed to `quit-window'. + +Don't use this from a Lisp program, call `yas-load-snippet-buffer' +and `kill-buffer' instead." + (interactive (list (yas--read-table) current-prefix-arg)) + (yas-load-snippet-buffer table t) + (when (and (or + ;; Only offer to save this if it looks like a library or new + ;; snippet (loaded from elisp, from a dir in `yas-snippet-dirs' + ;; which is not the first, or from an unwritable file) + ;; + (not (yas--template-file yas--editing-template)) + (not (file-writable-p (yas--template-file yas--editing-template))) + (and (listp yas-snippet-dirs) + (second yas-snippet-dirs) + (not (string-match (expand-file-name (first yas-snippet-dirs)) + (yas--template-file yas--editing-template))))) + (y-or-n-p (yas--format "Looks like a library or new snippet. Save to new file? "))) + (let* ((option (first (yas--guess-snippet-directories (yas--template-table yas--editing-template)))) + (chosen (and option + (yas--make-directory-maybe option)))) + (when chosen + (let ((default-file-name (or (and (yas--template-file yas--editing-template) + (file-name-nondirectory (yas--template-file yas--editing-template))) + (yas--template-name yas--editing-template)))) + (write-file (concat chosen "/" + (read-from-minibuffer (format "File name to create in %s? " chosen) + default-file-name))) + (setf (yas--template-file yas--editing-template) buffer-file-name))))) + (when buffer-file-name + (save-buffer) + (quit-window kill))) + +(defun yas-tryout-snippet (&optional debug) + "Test current buffer's snippet template in other buffer." (interactive "P") - (let* ((major-mode-and-parent (yas/compute-major-mode-and-parents buffer-file-name)) - (parsed (yas/parse-template)) + (let* ((major-mode-and-parent (yas--compute-major-mode-and-parents buffer-file-name)) + (parsed (yas--parse-template)) (test-mode (or (and (car major-mode-and-parent) (fboundp (car major-mode-and-parent)) (car major-mode-and-parent)) - (intern (read-from-minibuffer "[yas] please input a mode: ")))) - (template (and parsed - (fboundp test-mode) - (yas/make-template (second parsed) - (third parsed) - nil - (sixth parsed) - nil - nil)))) - (cond (template - (let ((buffer-name (format "*YAS TEST: %s*" (yas/template-name template)))) - (set-buffer (switch-to-buffer buffer-name)) - (erase-buffer) + (first yas--guessed-modes) + (intern (read-from-minibuffer (yas--format "Please input a mode: "))))) + (yas--current-template + (and parsed + (fboundp test-mode) + (yas--populate-template (yas--make-blank-template) + :table nil ;; no tables for ephemeral snippets + :key (first parsed) + :content (second parsed) + :name (third parsed) + :expand-env (sixth parsed))))) + (cond (yas--current-template + (let ((buffer-name (format "*testing snippet: %s*" (yas--template-name yas--current-template)))) + (kill-buffer (get-buffer-create buffer-name)) + (switch-to-buffer (get-buffer-create buffer-name)) (setq buffer-undo-list nil) - (funcall test-mode) - (yas/expand-snippet (yas/template-content template) + (condition-case nil (funcall test-mode) (error nil)) + (yas-minor-mode 1) + (setq buffer-read-only nil) + (yas-expand-snippet (yas--template-content yas--current-template) (point-min) (point-max) - (yas/template-expand-env template)) - (when debug - (add-hook 'post-command-hook 'yas/debug-snippet-vars 't 'local)))) + (yas--template-expand-env yas--current-template)) + (when (and debug + (require 'yasnippet-debug nil t)) + (add-hook 'post-command-hook 'yas-debug-snippet-vars nil t)))) (t - (message "[yas] Cannot test snippet for unknown major mode"))))) + (yas--message 3 "Cannot test snippet for unknown major mode"))))) + +(defun yas-active-keys () + "Return all active trigger keys for current buffer and point." + (remove-duplicates + (remove-if-not #'stringp (mapcan #'yas--table-all-keys (yas--get-snippet-tables))) + :test #'string=)) + +(defun yas--template-fine-group (template) + (car (last (or (yas--template-group template) + (yas--template-perm-group template))))) + +(defun yas-describe-tables (&optional choose) + "Display snippets for each table." + (interactive "P") + (let* ((by-name-hash (and choose + (y-or-n-p "Show by namehash? "))) + (buffer (get-buffer-create "*YASnippet tables*")) + (active-tables (yas--get-snippet-tables)) + (remain-tables (let ((all)) + (maphash #'(lambda (_k v) + (unless (find v active-tables) + (push v all))) + yas--tables) + all)) + (table-lists (list active-tables remain-tables)) + (original-buffer (current-buffer)) + (continue t) + (yas--condition-cache-timestamp (current-time))) + (with-current-buffer buffer + (setq buffer-read-only nil) + (erase-buffer) + (cond ((not by-name-hash) + (insert "YASnippet tables: \n") + (while (and table-lists + continue) + (dolist (table (car table-lists)) + (yas--describe-pretty-table table original-buffer)) + (setq table-lists (cdr table-lists)) + (when table-lists + (yas--create-snippet-xrefs) + (display-buffer buffer) + (setq continue (and choose (y-or-n-p "Show also non-active tables? "))))) + (yas--create-snippet-xrefs) + (help-mode) + (goto-char 1)) + (t + (insert "\n\nYASnippet tables by NAMEHASH: \n") + (dolist (table (append active-tables remain-tables)) + (insert (format "\nSnippet table `%s':\n\n" (yas--table-name table))) + (let ((keys)) + (maphash #'(lambda (k _v) + (push k keys)) + (yas--table-hash table)) + (dolist (key keys) + (insert (format " key %s maps snippets: %s\n" key + (let ((names)) + (maphash #'(lambda (k _v) + (push k names)) + (gethash key (yas--table-hash table))) + names)))))))) + (goto-char 1) + (setq buffer-read-only t)) + (display-buffer buffer))) + +(defun yas--describe-pretty-table (table &optional original-buffer) + (insert (format "\nSnippet table `%s'" + (yas--table-name table))) + (if (yas--table-parents table) + (insert (format " parents: %s\n" + (mapcar #'yas--table-name + (yas--table-parents table)))) + (insert "\n")) + (insert (make-string 100 ?-) "\n") + (insert "group state name key binding\n") + (let ((groups-hash (make-hash-table :test #'equal))) + (maphash #'(lambda (_k v) + (let ((group (or (yas--template-fine-group v) + "(top level)"))) + (when (yas--template-name v) + (puthash group + (cons v (gethash group groups-hash)) + groups-hash)))) + (yas--table-uuidhash table)) + (maphash + #'(lambda (group templates) + (setq group (truncate-string-to-width group 25 0 ? "...")) + (insert (make-string 100 ?-) "\n") + (dolist (p templates) + (let ((name (truncate-string-to-width (propertize (format "\\\\snippet `%s'" (yas--template-name p)) + 'yasnippet p) + 50 0 ? "...")) + (group (prog1 group + (setq group (make-string (length group) ? )))) + (condition-string (let ((condition (yas--template-condition p))) + (if (and condition + original-buffer) + (with-current-buffer original-buffer + (if (yas--eval-condition condition) + "(y)" + "(s)")) + "(a)")))) + (insert group " ") + (insert condition-string " ") + (insert name + (if (string-match "\\.\\.\\.$" name) + "'" + " ") + " ") + (insert (truncate-string-to-width (or (yas--template-key p) "") + 15 0 ? "...") " ") + (insert (truncate-string-to-width (key-description (yas--template-keybinding p)) + 15 0 ? "...") " ") + (insert "\n")))) + groups-hash))) + + + +;;; User convenience functions, for using in `yas-key-syntaxes' + +(defun yas-try-key-from-whitespace (_start-point) + "As `yas-key-syntaxes' element, look for whitespace delimited key. + +A newline will be considered whitespace even if the mode syntax +marks it as something else (typically comment ender)." + (skip-chars-backward "^[:space:]\n")) + +(defun yas-shortest-key-until-whitespace (_start-point) + "Like `yas-longest-key-from-whitespace' but take the shortest key." + (when (/= (skip-chars-backward "^[:space:]\n" (1- (point))) 0) + 'again)) + +(defun yas-longest-key-from-whitespace (start-point) + "As `yas-key-syntaxes' element, look for longest key between point and whitespace. + +A newline will be considered whitespace even if the mode syntax +marks it as something else (typically comment ender)." + (if (= (point) start-point) + (yas-try-key-from-whitespace start-point) + (forward-char)) + (unless (<= start-point (1+ (point))) + 'again)) + -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; User convenience functions, for using in snippet definitions -(defvar yas/modified-p nil +(defvar yas-modified-p nil "Non-nil if field has been modified by user or transformation.") -(defvar yas/moving-away-p nil +(defvar yas-moving-away-p nil "Non-nil if user is about to exit field.") -(defvar yas/text nil +(defvar yas-text nil "Contains current field text.") -(defun yas/substr (str pattern &optional subexp) +(defun yas-substr (str pattern &optional subexp) "Search PATTERN in STR and return SUBEXPth match. If found, the content of subexp group SUBEXP (default 0) is @@ -2216,81 +2810,111 @@ If found, the content of subexp group SUBEXP (default 0) is (match-string-no-properties grp str) str)))) -(defun yas/choose-value (possibilities) - "Prompt for a string in the list POSSIBILITIES and return it." - (unless (or yas/moving-away-p - yas/modified-p) +(defun yas-choose-value (&rest possibilities) + "Prompt for a string in POSSIBILITIES and return it. + +The last element of POSSIBILITIES may be a list of strings." + (unless (or yas-moving-away-p + yas-modified-p) + (let* ((last-link (last possibilities)) + (last-elem (car last-link))) + (when (listp last-elem) + (setcar last-link (car last-elem)) + (setcdr last-link (cdr last-elem)))) (some #'(lambda (fn) (funcall fn "Choose: " possibilities)) - yas/prompt-functions))) + yas-prompt-functions))) -(defun yas/key-to-value (alist) - "Prompt for a string in the list POSSIBILITIES and return it." - (unless (or yas/moving-away-p - yas/modified-p) +(defun yas-key-to-value (alist) + (unless (or yas-moving-away-p + yas-modified-p) (let ((key (read-key-sequence ""))) (when (stringp key) (or (cdr (find key alist :key #'car :test #'string=)) key))))) -(defun yas/throw (text) - "Throw a yas/exception with TEXT as the reason." - (throw 'yas/exception (cons 'yas/exception text))) +(defun yas-throw (text) + "Throw a yas--exception with TEXT as the reason." + (throw 'yas--exception (cons 'yas--exception text))) -(defun yas/verify-value (possibilities) - "Verify that the current field value is in POSSIBILITIES +(defun yas-verify-value (possibilities) + "Verify that the current field value is in POSSIBILITIES. Otherwise throw exception." - (when (and yas/moving-away-p (notany #'(lambda (pos) (string= pos yas/text)) possibilities)) - (yas/throw (format "[yas] field only allows %s" possibilities)))) + (when (and yas-moving-away-p (notany #'(lambda (pos) (string= pos yas-text)) possibilities)) + (yas-throw (yas--format "Field only allows %s" possibilities)))) + +(defun yas-field-value (number) + "Get the string for field with NUMBER. -(defun yas/field-value (number) - (let* ((snippet (car (yas/snippets-at-point))) +Use this in primary and mirror transformations to tget." + (let* ((snippet (car (yas--snippets-at-point))) (field (and snippet - (yas/snippet-find-field snippet number)))) + (yas--snippet-find-field snippet number)))) (when field - (yas/field-text-for-display field)))) - -(defun yas/default-from-field (number) - (unless yas/modified-p - (yas/field-value number))) - -(defun yas/inside-string () + (yas--field-text-for-display field)))) + +(defun yas-text () + "Return `yas-text' if that exists and is non-empty, else nil." + (if (and yas-text + (not (string= "" yas-text))) + yas-text)) + +(defun yas-selected-text () + "Return `yas-selected-text' if that exists and is non-empty, else nil." + (if (and yas-selected-text + (not (string= "" yas-selected-text))) + yas-selected-text)) + +(defun yas--get-field-once (number &optional transform-fn) + (unless yas-modified-p + (if transform-fn + (funcall transform-fn (yas-field-value number)) + (yas-field-value number)))) + +(defun yas-default-from-field (number) + (unless yas-modified-p + (yas-field-value number))) + +(defun yas-inside-string () + "Return non-nil if the point is inside a string according to font-lock." (equal 'font-lock-string-face (get-char-property (1- (point)) 'face))) +(defun yas-unimplemented (&optional missing-feature) + (if yas--current-template + (if (y-or-n-p (format "This snippet is unimplemented (missing %s) Visit the snippet definition? " + (or missing-feature + "something"))) + (yas--visit-snippet-file-1 yas--current-template)) + (message "No implementation. Missing %s" (or missing-feature "something")))) + -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Snippet expansion and field management -(defvar yas/active-field-overlay nil +(defvar yas--active-field-overlay nil "Overlays the currently active field.") -(defvar yas/field-protection-overlays nil - "Two overlays protect the current active field ") +(defvar yas--field-protection-overlays nil + "Two overlays protect the current active field.") -(defconst yas/prefix nil - "A prefix argument for expansion direct from keybindings") - -(defvar yas/deleted-text nil - "The text deleted in the last snippet expansion.") - -(defvar yas/selected-text nil +(defvar yas-selected-text nil "The selected region deleted on the last snippet expansion.") -(defvar yas/start-column nil +(defvar yas--start-column nil "The column where the snippet expansion started.") -(make-variable-buffer-local 'yas/active-field-overlay) -(make-variable-buffer-local 'yas/field-protection-overlays) -(make-variable-buffer-local 'yas/deleted-text) +(make-variable-buffer-local 'yas--active-field-overlay) +(make-variable-buffer-local 'yas--field-protection-overlays) +(put 'yas--active-field-overlay 'permanent-local t) +(put 'yas--field-protection-overlays 'permanent-local t) -(defstruct (yas/snippet (:constructor yas/make-snippet ())) +(defstruct (yas--snippet (:constructor yas--make-snippet ())) "A snippet. ..." (fields '()) (exit nil) - (id (yas/snippet-next-id) :read-only t) + (id (yas--snippet-next-id) :read-only t) (control-overlay nil) active-field ;; stacked expansion: the `previous-active-field' slot saves the @@ -2298,8 +2922,17 @@ Otherwise throw exception." previous-active-field force-exit) -(defstruct (yas/field (:constructor yas/make-field (number start end parent-field))) - "A field." +(defstruct (yas--field (:constructor yas--make-field (number start end parent-field))) + "A field. + +NUMBER is the field number. +START and END are mostly buffer markers, but see \"apropos markers-to-points\". +PARENT-FIELD is a `yas--field' this field is nested under, or nil. +MIRRORS is a list of `yas--mirror's +TRANSFORM is a lisp form. +MODIFIED-P is a boolean set to true once user inputs text. +NEXT is another `yas--field' or `yas--mirror' or `yas--exit'. +" number start end parent-field @@ -2308,37 +2941,50 @@ Otherwise throw exception." (modified-p nil) next) -(defstruct (yas/mirror (:constructor yas/make-mirror (start end transform))) - "A mirror." + +(defstruct (yas--mirror (:constructor yas--make-mirror (start end transform))) + "A mirror. + +START and END are mostly buffer markers, but see \"apropos markers-to-points\". +TRANSFORM is a lisp form. +PARENT-FIELD is a `yas--field' this mirror is nested under, or nil. +NEXT is another `yas--field' or `yas--mirror' or `yas--exit' +DEPTH is a count of how many nested mirrors can affect this mirror" start end (transform nil) - next) + parent-field + next + depth) -(defstruct (yas/exit (:constructor yas/make-exit (marker))) +(defstruct (yas--exit (:constructor yas--make-exit (marker))) marker next) -(defun yas/apply-transform (field-or-mirror field) - "Calculate the value of the field/mirror. If there's a transform -for this field, apply it. Otherwise, returned nil." - (let* ((yas/text (yas/field-text-for-display field)) - (text yas/text) - (yas/modified-p (yas/field-modified-p field)) - (yas/moving-away-p nil) - (transform (if (yas/mirror-p field-or-mirror) - (yas/mirror-transform field-or-mirror) - (yas/field-transform field-or-mirror))) - (start-point (if (yas/mirror-p field-or-mirror) - (yas/mirror-start field-or-mirror) - (yas/field-start field-or-mirror))) +(defun yas--apply-transform (field-or-mirror field &optional empty-on-nil-p) + "Calculate transformed string for FIELD-OR-MIRROR from FIELD. + +If there is no transform for ht field, return nil. + +If there is a transform but it returns nil, return the empty +string iff EMPTY-ON-NIL-P is true." + (let* ((yas-text (yas--field-text-for-display field)) + (yas-modified-p (yas--field-modified-p field)) + (yas-moving-away-p nil) + (transform (if (yas--mirror-p field-or-mirror) + (yas--mirror-transform field-or-mirror) + (yas--field-transform field-or-mirror))) + (start-point (if (yas--mirror-p field-or-mirror) + (yas--mirror-start field-or-mirror) + (yas--field-start field-or-mirror))) (transformed (and transform (save-excursion (goto-char start-point) - (yas/read-and-eval-string transform))))) + (let ((ret (yas--eval-lisp transform))) + (or ret (and empty-on-nil-p ""))))))) transformed)) -(defsubst yas/replace-all (from to &optional text) - "Replace all occurance from FROM to TO. +(defsubst yas--replace-all (from to &optional text) + "Replace all occurrences from FROM to TO. With optional string TEXT do it in that string." (if text @@ -2347,408 +2993,457 @@ With optional string TEXT do it in that string." (while (search-forward from nil t) (replace-match to t t text)))) -(defun yas/snippet-find-field (snippet number) +(defun yas--snippet-find-field (snippet number) (find-if #'(lambda (field) - (eq number (yas/field-number field))) - (yas/snippet-fields snippet))) + (eq number (yas--field-number field))) + (yas--snippet-fields snippet))) -(defun yas/snippet-sort-fields (snippet) +(defun yas--snippet-sort-fields (snippet) "Sort the fields of SNIPPET in navigation order." - (setf (yas/snippet-fields snippet) - (sort (yas/snippet-fields snippet) - '(lambda (field1 field2) - (yas/snippet-field-compare field1 field2))))) - -(defun yas/snippet-field-compare (field1 field2) - "Compare two fields. The field with a number is sorted first. -If they both have a number, compare through the number. If neither -have, compare through the field's start point" - (let ((n1 (yas/field-number field1)) - (n2 (yas/field-number field2))) + (setf (yas--snippet-fields snippet) + (sort (yas--snippet-fields snippet) + #'yas--snippet-field-compare))) + +(defun yas--snippet-field-compare (field1 field2) + "Compare FIELD1 and FIELD2. + +The field with a number is sorted first. If they both have a +number, compare through the number. If neither have, compare +through the field's start point" + (let ((n1 (yas--field-number field1)) + (n2 (yas--field-number field2))) (if n1 (if n2 - (< n1 n2) - t) + (or (zerop n2) (and (not (zerop n1)) + (< n1 n2))) + (not (zerop n1))) (if n2 - nil - (< (yas/field-start field1) - (yas/field-start field2)))))) + (zerop n2) + (< (yas--field-start field1) + (yas--field-start field2)))))) -(defun yas/field-probably-deleted-p (snippet field) +(defun yas--field-probably-deleted-p (snippet field) "Guess if SNIPPET's FIELD should be skipped." - (and (zerop (- (yas/field-start field) (yas/field-end field))) - (or (yas/field-parent-field field) - (and (eq field (car (last (yas/snippet-fields snippet)))) - (= (yas/field-start field) (overlay-end (yas/snippet-control-overlay snippet))))))) - -(defun yas/snippets-at-point (&optional all-snippets) - "Return a sorted list of snippets at point, most recently -inserted first." + (and + ;; field must be zero length + ;; + (zerop (- (yas--field-start field) (yas--field-end field))) + ;; field must have been modified + ;; + (yas--field-modified-p field) + ;; either: + (or + ;; 1) it's a nested field + ;; + (yas--field-parent-field field) + ;; 2) ends just before the snippet end + ;; + (and (eq field (car (last (yas--snippet-fields snippet)))) + (= (yas--field-start field) (overlay-end (yas--snippet-control-overlay snippet))))) + ;; the field numbered 0, just before the exit marker, should + ;; never be skipped + ;; + (not (zerop (yas--field-number field))))) + +(defun yas--snippets-at-point (&optional all-snippets) + "Return a sorted list of snippets at point. + +The most recently-inserted snippets are returned first." (sort (remove nil (remove-duplicates (mapcar #'(lambda (ov) - (overlay-get ov 'yas/snippet)) + (overlay-get ov 'yas--snippet)) (if all-snippets (overlays-in (point-min) (point-max)) - (overlays-at (point)))))) + (nconc (overlays-at (point)) (overlays-at (1- (point)))))))) #'(lambda (s1 s2) - (<= (yas/snippet-id s2) (yas/snippet-id s1))))) + (<= (yas--snippet-id s2) (yas--snippet-id s1))))) -(defun yas/next-field-or-maybe-expand () - "Try to expand a snippet at a key before point, otherwise -delegate to `yas/next-field'." +(defun yas-next-field-or-maybe-expand () + "Try to expand a snippet at a key before point. + +Otherwise delegate to `yas-next-field'." (interactive) - (if yas/triggers-in-field - (let ((yas/fallback-behavior 'return-nil) - (active-field (overlay-get yas/active-field-overlay 'yas/field))) + (if yas-triggers-in-field + (let ((yas-fallback-behavior 'return-nil) + (active-field (overlay-get yas--active-field-overlay 'yas--field))) (when active-field - (unless (yas/expand-1 active-field) - (yas/next-field)))) - (yas/next-field))) + (unless (yas-expand-from-trigger-key active-field) + (yas-next-field)))) + (yas-next-field))) + +(defun yas-next-field (&optional arg) + "Navigate to the ARGth next field. -(defun yas/next-field (&optional arg) - "Navigate to next field. If there's none, exit the snippet." +If there's none, exit the snippet." (interactive) (let* ((arg (or arg 1)) - (snippet (first (yas/snippets-at-point))) - (active-field (overlay-get yas/active-field-overlay 'yas/field)) + (snippet (first (yas--snippets-at-point))) + (active-field (overlay-get yas--active-field-overlay 'yas--field)) (live-fields (remove-if #'(lambda (field) (and (not (eq field active-field)) - (yas/field-probably-deleted-p snippet field))) - (yas/snippet-fields snippet))) + (yas--field-probably-deleted-p snippet field))) + (yas--snippet-fields snippet))) (active-field-pos (position active-field live-fields)) (target-pos (and active-field-pos (+ arg active-field-pos))) - (target-field (nth target-pos live-fields))) + (target-field (and target-pos (nth target-pos live-fields)))) ;; First check if we're moving out of a field with a transform ;; (when (and active-field - (yas/field-transform active-field)) - (let* ((yas/moving-away-p t) - (yas/text (yas/field-text-for-display active-field)) - (text yas/text) - (yas/modified-p (yas/field-modified-p active-field))) + (yas--field-transform active-field)) + (let* ((yas-moving-away-p t) + (yas-text (yas--field-text-for-display active-field)) + (yas-modified-p (yas--field-modified-p active-field))) ;; primary field transform: exit call to field-transform - (yas/read-and-eval-string (yas/field-transform active-field)))) + (yas--eval-lisp (yas--field-transform active-field)))) ;; Now actually move... - (cond ((>= target-pos (length live-fields)) - (yas/exit-snippet snippet)) + (cond ((and target-pos (>= target-pos (length live-fields))) + (yas-exit-snippet snippet)) (target-field - (yas/move-to-field snippet target-field)) + (yas--move-to-field snippet target-field)) (t nil)))) -(defun yas/place-overlays (snippet field) - "Correctly place overlays for SNIPPET's FIELD" - (yas/make-move-field-protection-overlays snippet field) - (yas/make-move-active-field-overlay snippet field)) +(defun yas--place-overlays (snippet field) + "Correctly place overlays for SNIPPET's FIELD." + (yas--make-move-field-protection-overlays snippet field) + (yas--make-move-active-field-overlay snippet field)) -(defun yas/move-to-field (snippet field) +(defun yas--move-to-field (snippet field) "Update SNIPPET to move to field FIELD. Also create some protection overlays" - (goto-char (yas/field-start field)) - (setf (yas/snippet-active-field snippet) field) - (yas/place-overlays snippet field) - (overlay-put yas/active-field-overlay 'yas/field field) - ;; primary field transform: first call to snippet transform - (unless (yas/field-modified-p field) - (if (yas/field-update-display field snippet) - (let ((inhibit-modification-hooks t)) - (yas/update-mirrors snippet)) - (setf (yas/field-modified-p field) nil)))) - -(defun yas/prev-field () + (goto-char (yas--field-start field)) + (yas--place-overlays snippet field) + (overlay-put yas--active-field-overlay 'yas--field field) + (let ((number (yas--field-number field))) + ;; check for the special ${0: ...} field + (if (and number (zerop number)) + (progn + (set-mark (yas--field-end field)) + (setf (yas--snippet-force-exit snippet) + (or (yas--field-transform field) + t))) + ;; make this field active + (setf (yas--snippet-active-field snippet) field) + ;; primary field transform: first call to snippet transform + (unless (yas--field-modified-p field) + (if (yas--field-update-display field) + (yas--update-mirrors snippet) + (setf (yas--field-modified-p field) nil)))))) + +(defun yas-prev-field () "Navigate to prev field. If there's none, exit the snippet." (interactive) - (yas/next-field -1)) + (yas-next-field -1)) -(defun yas/abort-snippet (&optional snippet) +(defun yas-abort-snippet (&optional snippet) (interactive) (let ((snippet (or snippet - (car (yas/snippets-at-point))))) + (car (yas--snippets-at-point))))) (when snippet - (setf (yas/snippet-force-exit snippet) t)))) + (setf (yas--snippet-force-exit snippet) t)))) -(defun yas/exit-snippet (snippet) +(defun yas-exit-snippet (snippet) "Goto exit-marker of SNIPPET." - (interactive) - (setf (yas/snippet-force-exit snippet) t) - (goto-char (if (yas/snippet-exit snippet) - (yas/exit-marker (yas/snippet-exit snippet)) - (overlay-end (yas/snippet-control-overlay snippet))))) - -(defun yas/exit-all-snippets () + (interactive (list (first (yas--snippets-at-point)))) + (when snippet + (setf (yas--snippet-force-exit snippet) t) + (goto-char (if (yas--snippet-exit snippet) + (yas--exit-marker (yas--snippet-exit snippet)) + (overlay-end (yas--snippet-control-overlay snippet)))))) + +(defun yas-exit-all-snippets () "Exit all snippets." (interactive) (mapc #'(lambda (snippet) - (yas/exit-snippet snippet) - (yas/check-commit-snippet)) - (yas/snippets-at-point))) + (yas-exit-snippet snippet) + (yas--check-commit-snippet)) + (yas--snippets-at-point 'all-snippets))) -;;; Apropos markers-to-points: -;;; -;;; This was found useful for performance reasons, so that an -;;; excessive number of live markers aren't kept around in the -;;; `buffer-undo-list'. However, in `markers-to-points', the -;;; set-to-nil markers can't simply be discarded and replaced with -;;; fresh ones in `points-to-markers'. The original marker that was -;;; just set to nil has to be reused. -;;; -;;; This shouldn't bring horrible problems with undo/redo, but it -;;; you never know -;;; +;;; Some low level snippet-routines: -(defun yas/markers-to-points (snippet) - "Convert all markers in SNIPPET to a cons (POINT . MARKER) -where POINT is the original position of the marker and MARKER is -the original marker object with the position set to nil." - (dolist (field (yas/snippet-fields snippet)) - (let ((start (marker-position (yas/field-start field))) - (end (marker-position (yas/field-end field)))) - (set-marker (yas/field-start field) nil) - (set-marker (yas/field-end field) nil) - (setf (yas/field-start field) (cons start (yas/field-start field))) - (setf (yas/field-end field) (cons end (yas/field-end field)))) - (dolist (mirror (yas/field-mirrors field)) - (let ((start (marker-position (yas/mirror-start mirror))) - (end (marker-position (yas/mirror-end mirror)))) - (set-marker (yas/mirror-start mirror) nil) - (set-marker (yas/mirror-end mirror) nil) - (setf (yas/mirror-start mirror) (cons start (yas/mirror-start mirror))) - (setf (yas/mirror-end mirror) (cons end (yas/mirror-end mirror)))))) - (let ((snippet-exit (yas/snippet-exit snippet))) - (when snippet-exit - (let ((exit (marker-position (yas/exit-marker snippet-exit)))) - (set-marker (yas/exit-marker snippet-exit) nil) - (setf (yas/exit-marker snippet-exit) (cons exit (yas/exit-marker snippet-exit))))))) - -(defun yas/points-to-markers (snippet) - "Convert all cons (POINT . MARKER) in SNIPPET to markers. This -is done by setting MARKER to POINT with `set-marker'." - (dolist (field (yas/snippet-fields snippet)) - (setf (yas/field-start field) (set-marker (cdr (yas/field-start field)) - (car (yas/field-start field)))) - (setf (yas/field-end field) (set-marker (cdr (yas/field-end field)) - (car (yas/field-end field)))) - (dolist (mirror (yas/field-mirrors field)) - (setf (yas/mirror-start mirror) (set-marker (cdr (yas/mirror-start mirror)) - (car (yas/mirror-start mirror)))) - (setf (yas/mirror-end mirror) (set-marker (cdr (yas/mirror-end mirror)) - (car (yas/mirror-end mirror)))))) - (let ((snippet-exit (yas/snippet-exit snippet))) - (when snippet-exit - (setf (yas/exit-marker snippet-exit) (set-marker (cdr (yas/exit-marker snippet-exit)) - (car (yas/exit-marker snippet-exit))))))) +(defvar yas--inhibit-overlay-hooks nil + "Bind this temporarily to non-nil to prevent running `yas--on-*-modification'.") -(defun yas/commit-snippet (snippet &optional no-hooks) - "Commit SNIPPET, but leave point as it is. This renders the -snippet as ordinary text. +(defmacro yas--inhibit-overlay-hooks (&rest body) + "Run BODY with `yas--inhibit-overlay-hooks' set to t." + (declare (indent 0)) + `(let ((yas--inhibit-overlay-hooks t)) + ,@body)) -Return a buffer position where the point should be placed if -exiting the snippet. +(defvar yas-snippet-beg nil "Beginning position of the last snippet committed.") +(defvar yas-snippet-end nil "End position of the last snippet committed.") -NO-HOOKS means don't run the `yas/after-exit-snippet-hook' hooks." +(defun yas--commit-snippet (snippet) + "Commit SNIPPET, but leave point as it is. - (let ((control-overlay (yas/snippet-control-overlay snippet)) - yas/snippet-beg - yas/snippet-end) +This renders the snippet as ordinary text." + + (let ((control-overlay (yas--snippet-control-overlay snippet))) ;; ;; Save the end of the moribund snippet in case we need to revive it ;; its original expansion. ;; (when (and control-overlay (overlay-buffer control-overlay)) - (setq yas/snippet-beg (overlay-start control-overlay)) - (setq yas/snippet-end (overlay-end control-overlay)) + (setq yas-snippet-beg (overlay-start control-overlay)) + (setq yas-snippet-end (overlay-end control-overlay)) (delete-overlay control-overlay)) - (let ((inhibit-modification-hooks t)) - (when yas/active-field-overlay - (delete-overlay yas/active-field-overlay)) - (when yas/field-protection-overlays - (mapc #'delete-overlay yas/field-protection-overlays))) + (yas--inhibit-overlay-hooks + (when yas--active-field-overlay + (delete-overlay yas--active-field-overlay)) + (when yas--field-protection-overlays + (mapc #'delete-overlay yas--field-protection-overlays))) ;; stacked expansion: if the original expansion took place from a ;; field, make sure we advance it here at least to - ;; `yas/snippet-end'... + ;; `yas-snippet-end'... ;; - (let ((previous-field (yas/snippet-previous-active-field snippet))) - (when (and yas/snippet-end previous-field) - (yas/advance-end-maybe previous-field yas/snippet-end))) + (let ((previous-field (yas--snippet-previous-active-field snippet))) + (when (and yas-snippet-end previous-field) + (yas--advance-end-maybe previous-field yas-snippet-end))) ;; Convert all markers to points, ;; - (yas/markers-to-points snippet) + (yas--markers-to-points snippet) ;; Take care of snippet revival ;; - (if yas/snippet-revival - (push `(apply yas/snippet-revive ,yas/snippet-beg ,yas/snippet-end ,snippet) + (if yas-snippet-revival + (push `(apply yas--snippet-revive ,yas-snippet-beg ,yas-snippet-end ,snippet) buffer-undo-list) ;; Dismember the snippet... this is useful if we get called - ;; again from `yas/take-care-of-redo'.... - (setf (yas/snippet-fields snippet) nil)) - - ;; XXX: `yas/after-exit-snippet-hook' should be run with - ;; `yas/snippet-beg' and `yas/snippet-end' bound. That might not - ;; be the case if the main overlay had somehow already - ;; disappeared, which sometimes happens when the snippet's messed - ;; up... - ;; - (unless no-hooks (run-hooks 'yas/after-exit-snippet-hook))) + ;; again from `yas--take-care-of-redo'.... + (setf (yas--snippet-fields snippet) nil))) + + (yas--message 3 "Snippet %s exited." (yas--snippet-id snippet))) - (message "[yas] snippet exited.")) +(defun yas--safely-run-hooks (hook-var) + (condition-case error + (run-hooks hook-var) + (error + (yas--message 3 "%s error: %s" hook-var (error-message-string error))))) + + +(defun yas--check-commit-snippet () + "Check if point exited the currently active field of the snippet. -(defun yas/check-commit-snippet () - "Checks if point exited the currently active field of the -snippet, if so cleans up the whole snippet up." - (let* ((snippets (yas/snippets-at-point 'all-snippets)) - (snippets-left snippets)) +If so cleans up the whole snippet up." + (let* ((snippets (yas--snippets-at-point 'all-snippets)) + (snippets-left snippets) + (snippet-exit-transform)) (dolist (snippet snippets) - (let ((active-field (yas/snippet-active-field snippet))) - (cond ((or (prog1 (yas/snippet-force-exit snippet) - (setf (yas/snippet-force-exit snippet) nil)) - (not (and active-field (yas/field-contains-point-p active-field)))) + (let ((active-field (yas--snippet-active-field snippet))) + (setq snippet-exit-transform (yas--snippet-force-exit snippet)) + (cond ((or snippet-exit-transform + (not (and active-field (yas--field-contains-point-p active-field)))) (setq snippets-left (delete snippet snippets-left)) - (yas/commit-snippet snippet snippets-left)) + (setf (yas--snippet-force-exit snippet) nil) + (yas--commit-snippet snippet)) ((and active-field - (or (not yas/active-field-overlay) - (not (overlay-buffer yas/active-field-overlay)))) + (or (not yas--active-field-overlay) + (not (overlay-buffer yas--active-field-overlay)))) ;; ;; stacked expansion: this case is mainly for recent ;; snippet exits that place us back int the field of ;; another snippet ;; (save-excursion - (yas/move-to-field snippet active-field) - (yas/update-mirrors snippet))) + (yas--move-to-field snippet active-field) + (yas--update-mirrors snippet))) (t nil)))) - (unless snippets-left - (remove-hook 'post-command-hook 'yas/post-command-handler 'local) - (remove-hook 'pre-command-hook 'yas/pre-command-handler 'local)))) + (unless (or (null snippets) snippets-left) + (if snippet-exit-transform + (yas--eval-lisp-no-saves snippet-exit-transform)) + (yas--safely-run-hooks 'yas-after-exit-snippet-hook)))) -(defun yas/field-contains-point-p (field &optional point) +;; Apropos markers-to-points: +;; +;; This was found useful for performance reasons, so that an +;; excessive number of live markers aren't kept around in the +;; `buffer-undo-list'. However, in `markers-to-points', the +;; set-to-nil markers can't simply be discarded and replaced with +;; fresh ones in `points-to-markers'. The original marker that was +;; just set to nil has to be reused. +;; +;; This shouldn't bring horrible problems with undo/redo, but it +;; you never know +;; +(defun yas--markers-to-points (snippet) + "Convert all markers in SNIPPET to a cons (POINT . MARKER) +where POINT is the original position of the marker and MARKER is +the original marker object with the position set to nil." + (dolist (field (yas--snippet-fields snippet)) + (let ((start (marker-position (yas--field-start field))) + (end (marker-position (yas--field-end field)))) + (set-marker (yas--field-start field) nil) + (set-marker (yas--field-end field) nil) + (setf (yas--field-start field) (cons start (yas--field-start field))) + (setf (yas--field-end field) (cons end (yas--field-end field)))) + (dolist (mirror (yas--field-mirrors field)) + (let ((start (marker-position (yas--mirror-start mirror))) + (end (marker-position (yas--mirror-end mirror)))) + (set-marker (yas--mirror-start mirror) nil) + (set-marker (yas--mirror-end mirror) nil) + (setf (yas--mirror-start mirror) (cons start (yas--mirror-start mirror))) + (setf (yas--mirror-end mirror) (cons end (yas--mirror-end mirror)))))) + (let ((snippet-exit (yas--snippet-exit snippet))) + (when snippet-exit + (let ((exit (marker-position (yas--exit-marker snippet-exit)))) + (set-marker (yas--exit-marker snippet-exit) nil) + (setf (yas--exit-marker snippet-exit) (cons exit (yas--exit-marker snippet-exit))))))) + +(defun yas--points-to-markers (snippet) + "Convert all cons (POINT . MARKER) in SNIPPET to markers. + +This is done by setting MARKER to POINT with `set-marker'." + (dolist (field (yas--snippet-fields snippet)) + (setf (yas--field-start field) (set-marker (cdr (yas--field-start field)) + (car (yas--field-start field)))) + (setf (yas--field-end field) (set-marker (cdr (yas--field-end field)) + (car (yas--field-end field)))) + (dolist (mirror (yas--field-mirrors field)) + (setf (yas--mirror-start mirror) (set-marker (cdr (yas--mirror-start mirror)) + (car (yas--mirror-start mirror)))) + (setf (yas--mirror-end mirror) (set-marker (cdr (yas--mirror-end mirror)) + (car (yas--mirror-end mirror)))))) + (let ((snippet-exit (yas--snippet-exit snippet))) + (when snippet-exit + (setf (yas--exit-marker snippet-exit) (set-marker (cdr (yas--exit-marker snippet-exit)) + (car (yas--exit-marker snippet-exit))))))) + +(defun yas--field-contains-point-p (field &optional point) (let ((point (or point (point)))) - (and (>= point (yas/field-start field)) - (<= point (yas/field-end field))))) + (and (>= point (yas--field-start field)) + (<= point (yas--field-end field))))) -(defun yas/field-text-for-display (field) - "Return the propertized display text for field FIELD. " - (buffer-substring (yas/field-start field) (yas/field-end field))) +(defun yas--field-text-for-display (field) + "Return the propertized display text for field FIELD." + (buffer-substring (yas--field-start field) (yas--field-end field))) -(defun yas/undo-in-progress () - "True if some kind of undo is in progress" +(defun yas--undo-in-progress () + "True if some kind of undo is in progress." (or undo-in-progress (eq this-command 'undo) (eq this-command 'redo))) -(defun yas/make-control-overlay (snippet start end) - "Creates the control overlay that surrounds the snippet and +(defun yas--make-control-overlay (snippet start end) + "Create the control overlay that surrounds the snippet and holds the keymap." (let ((overlay (make-overlay start end nil nil t))) - (overlay-put overlay 'keymap yas/keymap) - (overlay-put overlay 'yas/snippet snippet) + (overlay-put overlay 'keymap yas-keymap) + (overlay-put overlay 'priority 100) + (overlay-put overlay 'yas--snippet snippet) overlay)) -(defun yas/skip-and-clear-or-delete-char (&optional field) +(defun yas-skip-and-clear-or-delete-char (&optional field) "Clears unmodified field if at field start, skips to next tab. Otherwise deletes a character normally by calling `delete-char'." (interactive) (let ((field (or field - (and yas/active-field-overlay - (overlay-buffer yas/active-field-overlay) - (overlay-get yas/active-field-overlay 'yas/field))))) + (and yas--active-field-overlay + (overlay-buffer yas--active-field-overlay) + (overlay-get yas--active-field-overlay 'yas--field))))) (cond ((and field - (not (yas/field-modified-p field)) - (eq (point) (marker-position (yas/field-start field)))) - (yas/skip-and-clear field) - (yas/next-field 1)) + (not (yas--field-modified-p field)) + (eq (point) (marker-position (yas--field-start field)))) + (yas--skip-and-clear field) + (yas-next-field 1)) (t (call-interactively 'delete-char))))) -(defun yas/skip-and-clear (field) - "Deletes the region of FIELD and sets it modified state to t" - (setf (yas/field-modified-p field) t) - (delete-region (yas/field-start field) (yas/field-end field))) - -(defun yas/make-move-active-field-overlay (snippet field) +(defun yas--skip-and-clear (field) + "Deletes the region of FIELD and sets it's modified state to t." + ;; Just before skipping-and-clearing the field, mark its children + ;; fields as modified, too. If the children have mirrors-in-fields + ;; this prevents them from updating erroneously (we're skipping and + ;; deleting!). + ;; + (yas--mark-this-and-children-modified field) + (delete-region (yas--field-start field) (yas--field-end field))) + +(defun yas--mark-this-and-children-modified (field) + (setf (yas--field-modified-p field) t) + (let ((fom (yas--field-next field))) + (while (and fom + (yas--fom-parent-field fom)) + (when (and (eq (yas--fom-parent-field fom) field) + (yas--field-p fom)) + (yas--mark-this-and-children-modified fom)) + (setq fom (yas--fom-next fom))))) + +(defun yas--make-move-active-field-overlay (snippet field) "Place the active field overlay in SNIPPET's FIELD. Move the overlay, or create it if it does not exit." - (if (and yas/active-field-overlay - (overlay-buffer yas/active-field-overlay)) - (move-overlay yas/active-field-overlay - (yas/field-start field) - (yas/field-end field)) - (setq yas/active-field-overlay - (make-overlay (yas/field-start field) - (yas/field-end field) + (if (and yas--active-field-overlay + (overlay-buffer yas--active-field-overlay)) + (move-overlay yas--active-field-overlay + (yas--field-start field) + (yas--field-end field)) + (setq yas--active-field-overlay + (make-overlay (yas--field-start field) + (yas--field-end field) nil nil t)) - (overlay-put yas/active-field-overlay 'priority 100) - (overlay-put yas/active-field-overlay 'face 'yas/field-highlight-face) - (overlay-put yas/active-field-overlay 'yas/snippet snippet) - (overlay-put yas/active-field-overlay 'modification-hooks '(yas/on-field-overlay-modification)) - (overlay-put yas/active-field-overlay 'insert-in-front-hooks - '(yas/on-field-overlay-modification)) - (overlay-put yas/active-field-overlay 'insert-behind-hooks - '(yas/on-field-overlay-modification)))) - -(defun yas/on-field-overlay-modification (overlay after? beg end &optional length) + (overlay-put yas--active-field-overlay 'priority 100) + (overlay-put yas--active-field-overlay 'face 'yas-field-highlight-face) + (overlay-put yas--active-field-overlay 'yas--snippet snippet) + (overlay-put yas--active-field-overlay 'modification-hooks '(yas--on-field-overlay-modification)) + (overlay-put yas--active-field-overlay 'insert-in-front-hooks + '(yas--on-field-overlay-modification)) + (overlay-put yas--active-field-overlay 'insert-behind-hooks + '(yas--on-field-overlay-modification)))) + +(defun yas--on-field-overlay-modification (overlay after? _beg _end &optional _length) "Clears the field and updates mirrors, conditionally. Only clears the field if it hasn't been modified and it point it -at field start. This hook doesn't do anything if an undo is in +at field start. This hook doesn't do anything if an undo is in progress." - (unless (yas/undo-in-progress) - (let ((field (overlay-get yas/active-field-overlay 'yas/field))) + (unless (or yas--inhibit-overlay-hooks + (yas--undo-in-progress)) + (let* ((field (overlay-get overlay 'yas--field)) + (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (cond (after? - (yas/advance-end-maybe field (overlay-end overlay)) -;;; primary field transform: normal calls to expression - (let ((saved-point (point))) - (yas/field-update-display field (car (yas/snippets-at-point))) - (goto-char saved-point)) - (yas/update-mirrors (car (yas/snippets-at-point)))) + (yas--advance-end-maybe field (overlay-end overlay)) + (save-excursion + (yas--field-update-display field)) + (yas--update-mirrors snippet)) (field (when (and (not after?) - (not (yas/field-modified-p field)) - (eq (point) (if (markerp (yas/field-start field)) - (marker-position (yas/field-start field)) - (yas/field-start field)))) - (yas/skip-and-clear field)) - (setf (yas/field-modified-p field) t)))))) + (not (yas--field-modified-p field)) + (eq (point) (if (markerp (yas--field-start field)) + (marker-position (yas--field-start field)) + (yas--field-start field)))) + (yas--skip-and-clear field)) + (setf (yas--field-modified-p field) t)))))) ;;; Apropos protection overlays: -;;; -;;; These exist for nasty users who will try to delete parts of the -;;; snippet outside the active field. Actual protection happens in -;;; `yas/on-protection-overlay-modification'. -;;; -;;; Currently this signals an error which inhibits the command. For -;;; commands that move point (like `kill-line'), point is restored in -;;; the `yas/post-command-handler' using a global -;;; `yas/protection-violation' variable. -;;; -;;; Alternatively, I've experimented with an implementation that -;;; commits the snippet before actually calling `this-command' -;;; interactively, and then signals an eror, which is ignored. but -;;; blocks all other million modification hooks. This presented some -;;; problems with stacked expansion. -;;; - -(defun yas/make-move-field-protection-overlays (snippet field) +;; +;; These exist for nasty users who will try to delete parts of the +;; snippet outside the active field. Actual protection happens in +;; `yas--on-protection-overlay-modification'. +;; +;; As of github #537 this no longer inhibits the command by issuing an +;; error: all the snippets at point, including nested snippets, are +;; automatically commited and the current command can proceed. +;; +(defun yas--make-move-field-protection-overlays (snippet field) "Place protection overlays surrounding SNIPPET's FIELD. Move the overlays, or create them if they do not exit." - (let ((start (yas/field-start field)) - (end (yas/field-end field))) + (let ((start (yas--field-start field)) + (end (yas--field-end field))) ;; First check if the (1+ end) is contained in the buffer, ;; otherwise we'll have to do a bit of cheating and silently ;; insert a newline. the `(1+ (buffer-size))' should prevent this @@ -2756,424 +3451,476 @@ Move the overlays, or create them if they do not exit." ;; (when (< (buffer-size) end) (save-excursion - (let ((inhibit-modification-hooks t)) + (yas--inhibit-overlay-hooks (goto-char (point-max)) (newline)))) ;; go on to normal overlay creation/moving ;; - (cond ((and yas/field-protection-overlays - (every #'overlay-buffer yas/field-protection-overlays)) - (move-overlay (first yas/field-protection-overlays) (1- start) start) - (move-overlay (second yas/field-protection-overlays) end (1+ end))) + (cond ((and yas--field-protection-overlays + (every #'overlay-buffer yas--field-protection-overlays)) + (move-overlay (first yas--field-protection-overlays) (1- start) start) + (move-overlay (second yas--field-protection-overlays) end (1+ end))) (t - (setq yas/field-protection-overlays + (setq yas--field-protection-overlays (list (make-overlay (1- start) start nil t nil) (make-overlay end (1+ end) nil t nil))) - (dolist (ov yas/field-protection-overlays) - (overlay-put ov 'face 'yas/field-debug-face) - (overlay-put ov 'yas/snippet snippet) + (dolist (ov yas--field-protection-overlays) + (overlay-put ov 'face 'yas--field-debug-face) + (overlay-put ov 'yas--snippet snippet) ;; (overlay-put ov 'evaporate t) - (overlay-put ov 'modification-hooks '(yas/on-protection-overlay-modification))))))) - -(defvar yas/protection-violation nil - "When non-nil, signals attempts to erronesly exit or modify the snippet. - -Functions in the `post-command-hook', for example -`yas/post-command-handler' can check it and reset its value to -nil. The variables value is the point where the violation -originated") + (overlay-put ov 'modification-hooks '(yas--on-protection-overlay-modification))))))) -(defun yas/on-protection-overlay-modification (overlay after? beg end &optional length) +(defun yas--on-protection-overlay-modification (_overlay after? _beg _end &optional _length) "Signals a snippet violation, then issues error. The error should be ignored in `debug-ignored-errors'" - (cond ((not (or after? - (yas/undo-in-progress))) - (setq yas/protection-violation (point)) - (error "Exit the snippet first!")))) + (unless (or yas--inhibit-overlay-hooks + after? + (yas--undo-in-progress)) + (let ((snippets (yas--snippets-at-point))) + (yas--message 3 "Comitting snippets. Action would destroy a protection overlay.") + (cl-loop for snippet in snippets + do (yas--commit-snippet snippet))))) (add-to-list 'debug-ignored-errors "^Exit the snippet first!$") -;;; Apropos stacked expansion: -;;; -;;; the parent snippet does not run its fields modification hooks -;;; (`yas/on-field-overlay-modification' and -;;; `yas/on-protection-overlay-modification') while the child snippet -;;; is active. This means, among other things, that the mirrors of the -;;; parent snippet are not updated, this only happening when one exits -;;; the child snippet. -;;; -;;; Unfortunately, this also puts some ugly (and not fully-tested) -;;; bits of code in `yas/expand-snippet' and -;;; `yas/commit-snippet'. I've tried to mark them with "stacked -;;; expansion:". -;;; -;;; This was thought to be safer in in an undo/redo perpective, but -;;; maybe the correct implementation is to make the globals -;;; `yas/active-field-overlay' and `yas/field-protection-overlays' be -;;; snippet-local and be active even while the child snippet is -;;; running. This would mean a lot of overlay modification hooks -;;; running, but if managed correctly (including overlay priorities) -;;; they should account for all situations... -;;; - -(defun yas/expand-snippet (template &optional start end expand-env) - "Expand snippet at current point. Text between START and END -will be deleted before inserting template." - (run-hooks 'yas/before-expand-snippet-hook) - - ;; If a region is active, set `yas/selected-text' - (setq yas/selected-text - (when mark-active - (prog1 (buffer-substring-no-properties (region-beginning) - (region-end)) - (unless start (setq start (region-beginning)) - (unless end (setq end (region-end))))))) +;;; Snippet expansion and "stacked" expansion: +;; +;; Stacked expansion is when you try to expand a snippet when already +;; inside a snippet expansion. +;; +;; The parent snippet does not run its fields modification hooks +;; (`yas--on-field-overlay-modification' and +;; `yas--on-protection-overlay-modification') while the child snippet +;; is active. This means, among other things, that the mirrors of the +;; parent snippet are not updated, this only happening when one exits +;; the child snippet. +;; +;; Unfortunately, this also puts some ugly (and not fully-tested) +;; bits of code in `yas-expand-snippet' and +;; `yas--commit-snippet'. I've tried to mark them with "stacked +;; expansion:". +;; +;; This was thought to be safer in an undo/redo perspective, but +;; maybe the correct implementation is to make the globals +;; `yas--active-field-overlay' and `yas--field-protection-overlays' be +;; snippet-local and be active even while the child snippet is +;; running. This would mean a lot of overlay modification hooks +;; running, but if managed correctly (including overlay priorities) +;; they should account for all situations... +;; +(defun yas-expand-snippet (content &optional start end expand-env) + "Expand snippet CONTENT at current point. - (when start - (goto-char start)) +Text between START and END will be deleted before inserting +template. EXPAND-ENV is are let-style variable to value bindings +considered when expanding the snippet." + (run-hooks 'yas-before-expand-snippet-hook) - ;; stacked expansion: shoosh the overlay modification hooks ;; - (let ((to-delete (and start end (buffer-substring-no-properties start end))) - (start (or start (point))) - (end (or end (point))) - (inhibit-modification-hooks t) - (column (current-column)) - snippet) - + (let* ((yas-selected-text (or yas-selected-text + (and (region-active-p) + (buffer-substring-no-properties (region-beginning) + (region-end))))) + (start (or start + (and (region-active-p) + (region-beginning)) + (point))) + (end (or end + (and (region-active-p) + (region-end)) + (point))) + (to-delete (and start + end + (buffer-substring-no-properties start end))) + snippet) + (goto-char start) + (setq yas--indent-original-column (current-column)) ;; Delete the region to delete, this *does* get undo-recorded. ;; (when (and to-delete (> end start)) - (delete-region start end) - (setq yas/deleted-text to-delete)) - - ;; Narrow the region down to the template, shoosh the - ;; `buffer-undo-list', and create the snippet, the new snippet - ;; updates its mirrors once, so we are left with some plain text. - ;; The undo action for deleting this plain text will get recorded - ;; at the end of this function. - (save-restriction - (narrow-to-region start start) - (let ((buffer-undo-list t)) - ;; snippet creation might evaluate users elisp, which - ;; might generate errors, so we have to be ready to catch - ;; them mostly to make the undo information - ;; - (setq yas/start-column (save-restriction (widen) (current-column))) - (insert template) - - (setq snippet - (if expand-env - (let ((read-vars (condition-case err - (read expand-env) - (error nil)))) - (eval `(let ,read-vars - (yas/snippet-create (point-min) (point-max))))) - (yas/snippet-create (point-min) (point-max)))))) - - ;; stacked-expansion: This checks for stacked expansion, save the - ;; `yas/previous-active-field' and advance its boudary. - ;; - (let ((existing-field (and yas/active-field-overlay - (overlay-buffer yas/active-field-overlay) - (overlay-get yas/active-field-overlay 'yas/field)))) - (when existing-field - (setf (yas/snippet-previous-active-field snippet) existing-field) - (yas/advance-end-maybe existing-field (overlay-end yas/active-field-overlay)))) - - ;; Exit the snippet immediately if no fields - ;; - (unless (yas/snippet-fields snippet) - (yas/exit-snippet snippet)) - - ;; Push two undo actions: the deletion of the inserted contents of - ;; the new snippet (without the "key") followed by an apply of - ;; `yas/take-care-of-redo' on the newly inserted snippet boundaries - ;; - (let ((start (overlay-start (yas/snippet-control-overlay snippet))) - (end (overlay-end (yas/snippet-control-overlay snippet)))) - (push (cons start end) buffer-undo-list) - (push `(apply yas/take-care-of-redo ,start ,end ,snippet) - buffer-undo-list)) - ;; Now, move to the first field - ;; - (let ((first-field (car (yas/snippet-fields snippet)))) - (when first-field - (yas/move-to-field snippet first-field)))) - (message "[yas] snippet expanded.")) + (delete-region start end)) -(defun yas/take-care-of-redo (beg end snippet) - "Commits SNIPPET, which in turn pushes an undo action for -reviving it. + (cond ((listp content) + ;; x) This is a snippet-command + ;; + (yas--eval-lisp-no-saves content)) + (t + ;; x) This is a snippet-snippet :-) + ;; + ;; Narrow the region down to the content, shoosh the + ;; `buffer-undo-list', and create the snippet, the new + ;; snippet updates its mirrors once, so we are left with + ;; some plain text. The undo action for deleting this + ;; plain text will get recorded at the end. + ;; + ;; stacked expansion: also shoosh the overlay modification hooks + (let ((buffer-undo-list t)) + ;; snippet creation might evaluate users elisp, which + ;; might generate errors, so we have to be ready to catch + ;; them mostly to make the undo information + ;; + (setq yas--start-column (current-column)) + (yas--inhibit-overlay-hooks + (setq snippet + (if expand-env + (eval `(let* ,expand-env + (insert content) + (yas--snippet-create start (point)))) + (insert content) + (yas--snippet-create start (point)))))) + + ;; stacked-expansion: This checks for stacked expansion, save the + ;; `yas--previous-active-field' and advance its boundary. + ;; + (let ((existing-field (and yas--active-field-overlay + (overlay-buffer yas--active-field-overlay) + (overlay-get yas--active-field-overlay 'yas--field)))) + (when existing-field + (setf (yas--snippet-previous-active-field snippet) existing-field) + (yas--advance-end-maybe existing-field (overlay-end yas--active-field-overlay)))) + + ;; Exit the snippet immediately if no fields + ;; + (unless (yas--snippet-fields snippet) + (yas-exit-snippet snippet)) + + ;; Push two undo actions: the deletion of the inserted contents of + ;; the new snippet (without the "key") followed by an apply of + ;; `yas--take-care-of-redo' on the newly inserted snippet boundaries + ;; + ;; A small exception, if `yas-also-auto-indent-first-line' + ;; is t and `yas--indent' decides to indent the line to a + ;; point before the actual expansion point, undo would be + ;; messed up. We call the early point "newstart"". case, + ;; and attempt to fix undo. + ;; + (let ((newstart (overlay-start (yas--snippet-control-overlay snippet))) + (end (overlay-end (yas--snippet-control-overlay snippet)))) + (when (< newstart start) + (push (cons (make-string (- start newstart) ? ) newstart) buffer-undo-list)) + (push (cons newstart end) buffer-undo-list) + (push `(apply yas--take-care-of-redo ,start ,end ,snippet) + buffer-undo-list)) + ;; Now, schedule a move to the first field + ;; + (let ((first-field (car (yas--snippet-fields snippet)))) + (when first-field + (sit-for 0) ;; fix issue 125 + (yas--move-to-field snippet first-field))) + (yas--message 3 "snippet expanded.") + t)))) + +(defun yas--take-care-of-redo (_beg _end snippet) + "Commits SNIPPET, which in turn pushes an undo action for reviving it. Meant to exit in the `buffer-undo-list'." ;; slightly optimize: this action is only needed for snippets with ;; at least one field - (when (yas/snippet-fields snippet) - (yas/commit-snippet snippet 'no-hooks))) + (when (yas--snippet-fields snippet) + (yas--commit-snippet snippet))) -(defun yas/snippet-revive (beg end snippet) - "Revives the SNIPPET and creates a control overlay from BEG to -END. +(defun yas--snippet-revive (beg end snippet) + "Revives SNIPPET and creates a control overlay from BEG to END. -BEG and END are, we hope, the original snippets boudaries. All -the markers/points exiting existing inside SNIPPET should point +BEG and END are, we hope, the original snippets boundaries. +All the markers/points exiting existing inside SNIPPET should point to their correct locations *at the time the snippet is revived*. -After revival, push the `yas/take-care-of-redo' in the +After revival, push the `yas--take-care-of-redo' in the `buffer-undo-list'" ;; Reconvert all the points to markers ;; - (yas/points-to-markers snippet) + (yas--points-to-markers snippet) ;; When at least one editable field existed in the zombie snippet, ;; try to revive the whole thing... ;; - (let ((target-field (or (yas/snippet-active-field snippet) - (car (yas/snippet-fields snippet))))) + (let ((target-field (or (yas--snippet-active-field snippet) + (car (yas--snippet-fields snippet))))) (when target-field - (setf (yas/snippet-control-overlay snippet) (yas/make-control-overlay snippet beg end)) - (overlay-put (yas/snippet-control-overlay snippet) 'yas/snippet snippet) - - (yas/move-to-field snippet target-field) + (setf (yas--snippet-control-overlay snippet) (yas--make-control-overlay snippet beg end)) + (overlay-put (yas--snippet-control-overlay snippet) 'yas--snippet snippet) - (add-hook 'post-command-hook 'yas/post-command-handler nil t) - (add-hook 'pre-command-hook 'yas/pre-command-handler t t) + (yas--move-to-field snippet target-field) - (push `(apply yas/take-care-of-redo ,beg ,end ,snippet) + (push `(apply yas--take-care-of-redo ,beg ,end ,snippet) buffer-undo-list)))) -(defun yas/snippet-create (begin end) - "Creates a snippet from an template inserted between BEGIN and END. +(defun yas--snippet-create (begin end) + "Create a snippet from a template inserted at BEGIN to END. Returns the newly created snippet." - (let ((snippet (yas/make-snippet))) - (goto-char begin) - (yas/snippet-parse-create snippet) + (save-restriction + (narrow-to-region begin end) + (let ((snippet (yas--make-snippet))) + (goto-char begin) + (yas--snippet-parse-create snippet) - ;; Sort and link each field - (yas/snippet-sort-fields snippet) + ;; Sort and link each field + (yas--snippet-sort-fields snippet) - ;; Create keymap overlay for snippet - (setf (yas/snippet-control-overlay snippet) - (yas/make-control-overlay snippet (point-min) (point-max))) + ;; Create keymap overlay for snippet + (setf (yas--snippet-control-overlay snippet) + (yas--make-control-overlay snippet (point-min) (point-max))) - ;; Move to end - (goto-char (point-max)) - - ;; Setup hooks - (add-hook 'post-command-hook 'yas/post-command-handler nil t) - (add-hook 'pre-command-hook 'yas/pre-command-handler t t) + ;; Move to end + (goto-char (point-max)) - snippet)) + snippet))) -;;; Apropos adjacencies: Once the $-constructs bits like "$n" and -;;; "${:n" are deleted in the recently expanded snippet, we might -;;; actually have many fields, mirrors (and the snippet exit) in the -;;; very same position in the buffer. Therefore we need to single-link -;;; the fields-or-mirrors-or-exit, which I have called "fom", -;;; according to their original positions in the buffer. -;;; -;;; Then we have operation `yas/advance-end-maybe' and -;;; `yas/advance-start-maybe', which conditionally push the starts and -;;; ends of these foms down the chain. -;;; -;;; This allows for like the printf with the magic ",": -;;; -;;; printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);")} \ -;;; $2${1:$(if (string-match "%" text) "\);" "")}$0 -;;; +;;; Apropos adjacencies and "fom's": +;; +;; Once the $-constructs bits like "$n" and "${:n" are deleted in the +;; recently expanded snippet, we might actually have many fields, +;; mirrors (and the snippet exit) in the very same position in the +;; buffer. Therefore we need to single-link the +;; fields-or-mirrors-or-exit (which I have abbreviated to "fom") +;; according to their original positions in the buffer. +;; +;; Then we have operation `yas--advance-end-maybe' and +;; `yas--advance-start-maybe', which conditionally push the starts and +;; ends of these foms down the chain. +;; +;; This allows for like the printf with the magic ",": +;; +;; printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);")} \ +;; $2${1:$(if (string-match "%" text) "\);" "")}$0 +;; +(defun yas--fom-start (fom) + (cond ((yas--field-p fom) + (yas--field-start fom)) + ((yas--mirror-p fom) + (yas--mirror-start fom)) + (t + (yas--exit-marker fom)))) -(defun yas/fom-start (fom) - (cond ((yas/field-p fom) - (yas/field-start fom)) - ((yas/mirror-p fom) - (yas/mirror-start fom)) +(defun yas--fom-end (fom) + (cond ((yas--field-p fom) + (yas--field-end fom)) + ((yas--mirror-p fom) + (yas--mirror-end fom)) (t - (yas/exit-marker fom)))) + (yas--exit-marker fom)))) -(defun yas/fom-end (fom) - (cond ((yas/field-p fom) - (yas/field-end fom)) - ((yas/mirror-p fom) - (yas/mirror-end fom)) +(defun yas--fom-next (fom) + (cond ((yas--field-p fom) + (yas--field-next fom)) + ((yas--mirror-p fom) + (yas--mirror-next fom)) (t - (yas/exit-marker fom)))) + (yas--exit-next fom)))) -(defun yas/fom-next (fom) - (cond ((yas/field-p fom) - (yas/field-next fom)) - ((yas/mirror-p fom) - (yas/mirror-next fom)) +(defun yas--fom-parent-field (fom) + (cond ((yas--field-p fom) + (yas--field-parent-field fom)) + ((yas--mirror-p fom) + (yas--mirror-parent-field fom)) (t - (yas/exit-next fom)))) + nil))) -(defun yas/calculate-adjacencies (snippet) +(defun yas--calculate-adjacencies (snippet) "Calculate adjacencies for fields or mirrors of SNIPPET. This is according to their relative positions in the buffer, and has to be called before the $-constructs are deleted." - (flet ((yas/fom-set-next-fom (fom nextfom) - (cond ((yas/field-p fom) - (setf (yas/field-next fom) nextfom)) - ((yas/mirror-p fom) - (setf (yas/mirror-next fom) nextfom)) - (t - (setf (yas/exit-next fom) nextfom)))) - (yas/compare-fom-begs (fom1 fom2) - (> (yas/fom-start fom2) (yas/fom-start fom1))) - (yas/link-foms (fom1 fom2) - (yas/fom-set-next-fom fom1 fom2))) - ;; make some yas/field, yas/mirror and yas/exit soup + (let* ((fom-set-next-fom + (lambda (fom nextfom) + (cond ((yas--field-p fom) + (setf (yas--field-next fom) nextfom)) + ((yas--mirror-p fom) + (setf (yas--mirror-next fom) nextfom)) + (t + (setf (yas--exit-next fom) nextfom))))) + (compare-fom-begs + (lambda (fom1 fom2) + (if (= (yas--fom-start fom2) (yas--fom-start fom1)) + (yas--mirror-p fom2) + (>= (yas--fom-start fom2) (yas--fom-start fom1))))) + (link-foms fom-set-next-fom)) + ;; make some yas--field, yas--mirror and yas--exit soup (let ((soup)) - (when (yas/snippet-exit snippet) - (push (yas/snippet-exit snippet) soup)) - (dolist (field (yas/snippet-fields snippet)) + (when (yas--snippet-exit snippet) + (push (yas--snippet-exit snippet) soup)) + (dolist (field (yas--snippet-fields snippet)) (push field soup) - (dolist (mirror (yas/field-mirrors field)) + (dolist (mirror (yas--field-mirrors field)) (push mirror soup))) (setq soup - (sort soup - #'yas/compare-fom-begs)) + (sort soup compare-fom-begs)) (when soup - (reduce #'yas/link-foms soup))))) - -(defun yas/advance-end-maybe (fom newend) + (reduce link-foms soup))))) + +(defun yas--calculate-mirrors-in-fields (snippet mirror) + "Attempt to assign a parent field of SNIPPET to the mirror MIRROR. + +Use the tightest containing field if more than one field contains +the mirror. Intended to be called *before* the dollar-regions are +deleted." + (let ((min (point-min)) + (max (point-max))) + (dolist (field (yas--snippet-fields snippet)) + (when (and (<= (yas--field-start field) (yas--mirror-start mirror)) + (<= (yas--mirror-end mirror) (yas--field-end field)) + (< min (yas--field-start field)) + (< (yas--field-end field) max)) + (setq min (yas--field-start field) + max (yas--field-end field)) + (setf (yas--mirror-parent-field mirror) field))))) + +(defun yas--advance-end-maybe (fom newend) "Maybe advance FOM's end to NEWEND if it needs it. If it does, also: -* call `yas/advance-start-maybe' on FOM's next fom. +* call `yas--advance-start-maybe' on FOM's next fom. + +* in case FOM is field call `yas--advance-end-maybe' on its parent + field -* in case FOM is field call `yas/advance-end-maybe' on its parent - field" - (when (and fom (< (yas/fom-end fom) newend)) - (set-marker (yas/fom-end fom) newend) - (yas/advance-start-maybe (yas/fom-next fom) newend) - (if (and (yas/field-p fom) - (yas/field-parent-field fom)) - (yas/advance-end-maybe (yas/field-parent-field fom) newend)))) +Also, if FOM is an exit-marker, always call +`yas--advance-start-maybe' on its next fom. This is because +exit-marker have identical start and end markers." + (cond ((and fom (< (yas--fom-end fom) newend)) + (set-marker (yas--fom-end fom) newend) + (yas--advance-start-maybe (yas--fom-next fom) newend) + (yas--advance-end-of-parents-maybe (yas--fom-parent-field fom) newend)) + ((yas--exit-p fom) + (yas--advance-start-maybe (yas--fom-next fom) newend)))) -(defun yas/advance-start-maybe (fom newstart) +(defun yas--advance-start-maybe (fom newstart) "Maybe advance FOM's start to NEWSTART if it needs it. -If it does, also call `yas/advance-end-maybe' on FOM." - (when (and fom (< (yas/fom-start fom) newstart)) - (set-marker (yas/fom-start fom) newstart) - (yas/advance-end-maybe fom newstart))) +If it does, also call `yas--advance-end-maybe' on FOM." + (when (and fom (< (yas--fom-start fom) newstart)) + (set-marker (yas--fom-start fom) newstart) + (yas--advance-end-maybe fom newstart))) + +(defun yas--advance-end-of-parents-maybe (field newend) + "Like `yas--advance-end-maybe' but for parent fields. -(defvar yas/dollar-regions nil +Only works for fields and doesn't care about the start of the +next FOM. Works its way up recursively for parents of parents." + (when (and field + (< (yas--field-end field) newend)) + (set-marker (yas--field-end field) newend) + (yas--advance-end-of-parents-maybe (yas--field-parent-field field) newend))) + +(defvar yas--dollar-regions nil "When expanding the snippet the \"parse-create\" functions add - cons cells to this var") +cons cells to this var.") + +(defvar yas--backquote-markers-and-strings nil + "List of (MARKER . STRING) marking where the values from +backquoted Lisp expressions should be inserted at the end of +expansion.") -(defun yas/snippet-parse-create (snippet) +(defun yas--snippet-parse-create (snippet) "Parse a recently inserted snippet template, creating all necessary fields, mirrors and exit points. Meant to be called in a narrowed buffer, does various passes" (let ((parse-start (point))) - ;; Reset the yas/dollar-regions + ;; Reset the yas--dollar-regions ;; - (setq yas/dollar-regions nil) - ;; protect escaped quote, backquotes and backslashes + (setq yas--dollar-regions nil) + ;; protect just the backquotes ;; - (yas/protect-escapes nil '(?\\ ?` ?')) + (yas--protect-escapes nil '(?`)) ;; replace all backquoted expressions ;; (goto-char parse-start) - (yas/replace-backquotes) - ;; protect escapes again since previous steps might have generated - ;; more characters needing escaping + (yas--save-backquotes) + ;; protect escaped characters ;; - (goto-char parse-start) - (yas/protect-escapes) + (yas--protect-escapes) ;; parse fields with {} ;; (goto-char parse-start) - (yas/field-parse-create snippet) + (yas--field-parse-create snippet) ;; parse simple mirrors and fields ;; (goto-char parse-start) - (yas/simple-mirror-parse-create snippet) + (yas--simple-mirror-parse-create snippet) ;; parse mirror transforms ;; (goto-char parse-start) - (yas/transform-mirror-parse-create snippet) + (yas--transform-mirror-parse-create snippet) ;; calculate adjacencies of fields and mirrors ;; - (yas/calculate-adjacencies snippet) + (yas--calculate-adjacencies snippet) ;; Delete $-constructs ;; - (yas/delete-regions yas/dollar-regions) + (save-restriction (widen) (yas--delete-regions yas--dollar-regions)) + ;; restore backquoted expression values + ;; + (yas--restore-backquotes) ;; restore escapes ;; (goto-char parse-start) - (yas/restore-escapes) + (yas--restore-escapes) ;; update mirrors for the first time ;; - (yas/update-mirrors snippet) + (yas--update-mirrors snippet) ;; indent the best we can ;; (goto-char parse-start) - (yas/indent snippet))) + (yas--indent snippet))) -(defun yas/indent-according-to-mode (snippet-markers) - "Indent current line according to mode, preserving -SNIPPET-MARKERS." - ;; XXX: Here seems to be the indent problem: +(defun yas--indent-according-to-mode (snippet-markers) + "Indent current line according to mode, preserving SNIPPET-MARKERS." + ;;; Apropos indenting problems.... ;; - ;; `indent-according-to-mode' uses whatever - ;; `indent-line-function' is available. Some - ;; implementations of these functions delete text - ;; before they insert. If there happens to be a marker - ;; just after the text being deleted, the insertion - ;; actually happens after the marker, which misplaces - ;; it. + ;; `indent-according-to-mode' uses whatever `indent-line-function' + ;; is available. Some implementations of these functions delete text + ;; before they insert. If there happens to be a marker just after + ;; the text being deleted, the insertion actually happens after the + ;; marker, which misplaces it. ;; - ;; This would also happen if we had used overlays with - ;; the `front-advance' property set to nil. + ;; This would also happen if we had used overlays with the + ;; `front-advance' property set to nil. ;; ;; This is why I have these `trouble-markers', they are the ones at ;; they are the ones at the first non-whitespace char at the line - ;; (i.e. at `yas/real-line-beginning'. After indentation takes place + ;; (i.e. at `yas--real-line-beginning'. After indentation takes place ;; we should be at the correct to restore them to. All other ;; non-trouble-markers have been *pushed* and don't need special ;; attention. ;; - (goto-char (yas/real-line-beginning)) + (goto-char (yas--real-line-beginning)) (let ((trouble-markers (remove-if-not #'(lambda (marker) (= marker (point))) snippet-markers))) (save-restriction (widen) - (condition-case err + (condition-case _ (indent-according-to-mode) - (error (message "[yas] warning: yas/indent-according-to-mode habing problems running %s" indent-line-function) + (error (yas--message 3 "Warning: `yas--indent-according-to-mode' having problems running %s" indent-line-function) nil))) (mapc #'(lambda (marker) (set-marker marker (point))) trouble-markers))) -(defun yas/indent (snippet) - (let ((snippet-markers (yas/collect-snippet-markers snippet))) +(defvar yas--indent-original-column nil) +(defun yas--indent (snippet) + (let ((snippet-markers (yas--collect-snippet-markers snippet))) ;; Look for those $> (save-excursion (while (re-search-forward "$>" nil t) (delete-region (match-beginning 0) (match-end 0)) - (when (not (eq yas/indent-line 'auto)) - (yas/indent-according-to-mode snippet-markers)))) + (when (not (eq yas-indent-line 'auto)) + (yas--indent-according-to-mode snippet-markers)))) ;; Now do stuff for 'fixed and 'auto (save-excursion - (cond ((eq yas/indent-line 'fixed) + (cond ((eq yas-indent-line 'fixed) (while (and (zerop (forward-line)) (zerop (current-column))) - (indent-to-column column))) - ((eq yas/indent-line 'auto) + (indent-to-column yas--indent-original-column))) + ((eq yas-indent-line 'auto) (let ((end (set-marker (make-marker) (point-max))) - (indent-first-line-p yas/also-auto-indent-first-line)) + (indent-first-line-p yas-also-auto-indent-first-line)) (while (and (zerop (if indent-first-line-p (prog1 (forward-line 0) @@ -3181,38 +3928,38 @@ SNIPPET-MARKERS." (forward-line 1))) (not (eobp)) (<= (point) end)) - (yas/indent-according-to-mode snippet-markers)))) + (yas--indent-according-to-mode snippet-markers)))) (t nil))))) -(defun yas/collect-snippet-markers (snippet) +(defun yas--collect-snippet-markers (snippet) "Make a list of all the markers used by SNIPPET." (let (markers) - (dolist (field (yas/snippet-fields snippet)) - (push (yas/field-start field) markers) - (push (yas/field-end field) markers) - (dolist (mirror (yas/field-mirrors field)) - (push (yas/mirror-start mirror) markers) - (push (yas/mirror-end mirror) markers))) - (let ((snippet-exit (yas/snippet-exit snippet))) + (dolist (field (yas--snippet-fields snippet)) + (push (yas--field-start field) markers) + (push (yas--field-end field) markers) + (dolist (mirror (yas--field-mirrors field)) + (push (yas--mirror-start mirror) markers) + (push (yas--mirror-end mirror) markers))) + (let ((snippet-exit (yas--snippet-exit snippet))) (when (and snippet-exit - (marker-buffer (yas/exit-marker snippet-exit))) - (push (yas/exit-marker snippet-exit) markers))) + (marker-buffer (yas--exit-marker snippet-exit))) + (push (yas--exit-marker snippet-exit) markers))) markers)) -(defun yas/real-line-beginning () +(defun yas--real-line-beginning () (let ((c (char-after (line-beginning-position))) (n (line-beginning-position))) (while (or (eql c ?\ ) (eql c ?\t)) - (incf n) + (cl-incf n) (setq c (char-after n))) n)) -(defun yas/escape-string (escaped) +(defun yas--escape-string (escaped) (concat "YASESCAPE" (format "%d" escaped) "PROTECTGUARD")) -(defun yas/protect-escapes (&optional text escaped) +(defun yas--protect-escapes (&optional text escaped) "Protect all escaped characters with their numeric ASCII value. With optional string TEXT do it in string instead of buffer." @@ -3220,13 +3967,13 @@ With optional string TEXT do it in string instead of buffer." (text-provided-p text)) (mapc #'(lambda (escaped) (setq changed-text - (yas/replace-all (concat "\\" (char-to-string escaped)) - (yas/escape-string escaped) + (yas--replace-all (concat "\\" (char-to-string escaped)) + (yas--escape-string escaped) (when text-provided-p changed-text)))) - (or escaped yas/escaped-characters)) + (or escaped yas--escaped-characters)) changed-text)) -(defun yas/restore-escapes (&optional text escaped) +(defun yas--restore-escapes (&optional text escaped) "Restore all escaped characters from their numeric ASCII value. With optional string TEXT do it in string instead of the buffer." @@ -3234,51 +3981,75 @@ With optional string TEXT do it in string instead of the buffer." (text-provided-p text)) (mapc #'(lambda (escaped) (setq changed-text - (yas/replace-all (yas/escape-string escaped) + (yas--replace-all (yas--escape-string escaped) (char-to-string escaped) (when text-provided-p changed-text)))) - (or escaped yas/escaped-characters)) + (or escaped yas--escaped-characters)) changed-text)) -(defun yas/replace-backquotes () - "Replace all the \"`(lisp-expression)`\"-style expression - with their evaluated value" - (while (re-search-forward yas/backquote-lisp-expression-regexp nil t) - (let ((transformed (yas/read-and-eval-string (yas/restore-escapes (match-string 1))))) - (goto-char (match-end 0)) - (when transformed (insert transformed)) - (delete-region (match-beginning 0) (match-end 0))))) - -(defun yas/scan-sexps (from count) - (condition-case err +(defun yas--save-backquotes () + "Save all the \"`(lisp-expression)`\"-style expressions +with their evaluated value into `yas--backquote-markers-and-strings'." + (while (re-search-forward yas--backquote-lisp-expression-regexp nil t) + (let ((current-string (match-string-no-properties 1)) transformed) + (save-restriction (widen) + (delete-region (match-beginning 0) (match-end 0))) + (setq transformed (yas--eval-lisp (yas--read-lisp (yas--restore-escapes current-string '(?`))))) + (goto-char (match-beginning 0)) + (when transformed + (let ((marker (make-marker))) + (save-restriction + (widen) + (insert "Y") ;; quite horrendous, I love it :) + (set-marker marker (point)) + (insert "Y")) + (push (cons marker transformed) yas--backquote-markers-and-strings)))))) + +(defun yas--restore-backquotes () + "Replace markers in `yas--backquote-markers-and-strings' with their values." + (while yas--backquote-markers-and-strings + (let* ((marker-and-string (pop yas--backquote-markers-and-strings)) + (marker (car marker-and-string)) + (string (cdr marker-and-string))) + (save-excursion + (goto-char marker) + (save-restriction + (widen) + (delete-char -1) + (insert string) + (delete-char 1)) + (set-marker marker nil))))) + +(defun yas--scan-sexps (from count) + (condition-case _ (with-syntax-table (standard-syntax-table) (scan-sexps from count)) (error nil))) -(defun yas/make-marker (pos) - "Create a marker at POS with `nil' `marker-insertion-type'" +(defun yas--make-marker (pos) + "Create a marker at POS with nil `marker-insertion-type'." (let ((marker (set-marker (make-marker) pos))) (set-marker-insertion-type marker nil) marker)) -(defun yas/field-parse-create (snippet &optional parent-field) - "Parse most field expressions, except for the simple one \"$n\". +(defun yas--field-parse-create (snippet &optional parent-field) + "Parse most field expressions in SNIPPET, except for the simple one \"$n\". The following count as a field: * \"${n: text}\", for a numbered field with default text, as long as N is not 0; -* \"${n: text$(expression)}, the same with a lisp expression; - this is caught with the curiously named `yas/multi-dollar-lisp-expression-regexp' +* \"${n: text$(expression)}, the same with a Lisp expression; + this is caught with the curiously named `yas--multi-dollar-lisp-expression-regexp' * the same as above but unnumbered, (no N:) and number is calculated automatically. When multiple expressions are found, only the last one counts." ;; (save-excursion - (while (re-search-forward yas/field-regexp nil t) - (let* ((real-match-end-0 (yas/scan-sexps (1+ (match-beginning 0)) 1)) + (while (re-search-forward yas--field-regexp nil t) + (let* ((real-match-end-0 (yas--scan-sexps (1+ (match-beginning 0)) 1)) (number (and (match-string-no-properties 1) (string-to-number (match-string-no-properties 1)))) (brand-new-field (and real-match-end-0 @@ -3289,98 +4060,116 @@ When multiple expressions are found, only the last one counts." (not (save-match-data (eq (string-match "$[ \t\n]*(" (match-string-no-properties 2)) 0))) - (not (and number (zerop number))) - (yas/make-field number - (yas/make-marker (match-beginning 2)) - (yas/make-marker (1- real-match-end-0)) + ;; allow ${0: some exit text} + ;; (not (and number (zerop number))) + (yas--make-field number + (yas--make-marker (match-beginning 2)) + (yas--make-marker (1- real-match-end-0)) parent-field)))) (when brand-new-field (goto-char real-match-end-0) (push (cons (1- real-match-end-0) real-match-end-0) - yas/dollar-regions) + yas--dollar-regions) (push (cons (match-beginning 0) (match-beginning 2)) - yas/dollar-regions) - (push brand-new-field (yas/snippet-fields snippet)) + yas--dollar-regions) + (push brand-new-field (yas--snippet-fields snippet)) (save-excursion (save-restriction - (narrow-to-region (yas/field-start brand-new-field) (yas/field-end brand-new-field)) + (narrow-to-region (yas--field-start brand-new-field) (yas--field-end brand-new-field)) (goto-char (point-min)) - (yas/field-parse-create snippet brand-new-field))))))) + (yas--field-parse-create snippet brand-new-field))))))) ;; if we entered from a parent field, now search for the - ;; `yas/multi-dollar-lisp-expression-regexp'. THis is used for + ;; `yas--multi-dollar-lisp-expression-regexp'. This is used for ;; primary field transformations - ;; + ;; (when parent-field (save-excursion - (while (re-search-forward yas/multi-dollar-lisp-expression-regexp nil t) - (let* ((real-match-end-1 (yas/scan-sexps (match-beginning 1) 1))) - ;; commit the primary field transformation if we don't find - ;; it in yas/dollar-regions (a subnested field) might have - ;; already caught it. + (while (re-search-forward yas--multi-dollar-lisp-expression-regexp nil t) + (let* ((real-match-end-1 (yas--scan-sexps (match-beginning 1) 1))) + ;; commit the primary field transformation if: + ;; + ;; 1. we don't find it in yas--dollar-regions (a subnested + ;; field) might have already caught it. + ;; + ;; 2. we really make sure we have either two '$' or some + ;; text and a '$' after the colon ':'. This is a FIXME: work + ;; my regular expressions and end these ugly hacks. + ;; (when (and real-match-end-1 (not (member (cons (match-beginning 0) real-match-end-1) - yas/dollar-regions))) + yas--dollar-regions)) + (not (eq ?: + (char-before (1- (match-beginning 1)))))) (let ((lisp-expression-string (buffer-substring-no-properties (match-beginning 1) real-match-end-1))) - (setf (yas/field-transform parent-field) (yas/restore-escapes lisp-expression-string))) + (setf (yas--field-transform parent-field) + (yas--read-lisp (yas--restore-escapes lisp-expression-string)))) (push (cons (match-beginning 0) real-match-end-1) - yas/dollar-regions))))))) + yas--dollar-regions))))))) -(defun yas/transform-mirror-parse-create (snippet) - "Parse the \"${n:$(lisp-expression)}\" mirror transformations." - (while (re-search-forward yas/transform-mirror-regexp nil t) - (let* ((real-match-end-0 (yas/scan-sexps (1+ (match-beginning 0)) 1)) +(defun yas--transform-mirror-parse-create (snippet) + "Parse the \"${n:$(lisp-expression)}\" mirror transformations in SNIPPET." + (while (re-search-forward yas--transform-mirror-regexp nil t) + (let* ((real-match-end-0 (yas--scan-sexps (1+ (match-beginning 0)) 1)) (number (string-to-number (match-string-no-properties 1))) (field (and number (not (zerop number)) - (yas/snippet-find-field snippet number)))) - (when (and real-match-end-0 - field) - (push (yas/make-mirror (yas/make-marker (match-beginning 0)) - (yas/make-marker (match-beginning 0)) - (yas/restore-escapes - (buffer-substring-no-properties (match-beginning 2) - (1- real-match-end-0)))) - (yas/field-mirrors field)) - (push (cons (match-beginning 0) real-match-end-0) yas/dollar-regions))))) - -(defun yas/simple-mirror-parse-create (snippet) - "Parse the simple \"$n\" mirrors and the exit-marker." - (while (re-search-forward yas/simple-mirror-regexp nil t) + (yas--snippet-find-field snippet number))) + (brand-new-mirror + (and real-match-end-0 + field + (yas--make-mirror (yas--make-marker (match-beginning 0)) + (yas--make-marker (match-beginning 0)) + (yas--read-lisp + (yas--restore-escapes + (buffer-substring-no-properties (match-beginning 2) + (1- real-match-end-0)))))))) + (when brand-new-mirror + (push brand-new-mirror + (yas--field-mirrors field)) + (yas--calculate-mirrors-in-fields snippet brand-new-mirror) + (push (cons (match-beginning 0) real-match-end-0) yas--dollar-regions))))) + +(defun yas--simple-mirror-parse-create (snippet) + "Parse the simple \"$n\" fields/mirrors/exitmarkers in SNIPPET." + (while (re-search-forward yas--simple-mirror-regexp nil t) (let ((number (string-to-number (match-string-no-properties 1)))) (cond ((zerop number) - (setf (yas/snippet-exit snippet) - (yas/make-exit (yas/make-marker (match-end 0)))) + (setf (yas--snippet-exit snippet) + (yas--make-exit (yas--make-marker (match-end 0)))) (save-excursion (goto-char (match-beginning 0)) - (when yas/wrap-around-region - (cond (yas/selected-text - (insert yas/selected-text)) - ((and (eq yas/wrap-around-region 'cua) + (when yas-wrap-around-region + (cond (yas-selected-text + (insert yas-selected-text)) + ((and (eq yas-wrap-around-region 'cua) cua-mode (get-register ?0)) (insert (prog1 (get-register ?0) (set-register ?0 nil)))))) - (push (cons (point) (yas/exit-marker (yas/snippet-exit snippet))) - yas/dollar-regions))) + (push (cons (point) (yas--exit-marker (yas--snippet-exit snippet))) + yas--dollar-regions))) (t - (let ((field (yas/snippet-find-field snippet number))) + (let ((field (yas--snippet-find-field snippet number))) (if field - (push (yas/make-mirror (yas/make-marker (match-beginning 0)) - (yas/make-marker (match-beginning 0)) - nil) - (yas/field-mirrors field)) - (push (yas/make-field number - (yas/make-marker (match-beginning 0)) - (yas/make-marker (match-beginning 0)) + (let ((brand-new-mirror (yas--make-mirror + (yas--make-marker (match-beginning 0)) + (yas--make-marker (match-beginning 0)) + nil))) + (push brand-new-mirror + (yas--field-mirrors field)) + (yas--calculate-mirrors-in-fields snippet brand-new-mirror)) + (push (yas--make-field number + (yas--make-marker (match-beginning 0)) + (yas--make-marker (match-beginning 0)) nil) - (yas/snippet-fields snippet)))) + (yas--snippet-fields snippet)))) (push (cons (match-beginning 0) (match-end 0)) - yas/dollar-regions)))))) + yas--dollar-regions)))))) -(defun yas/delete-regions (regions) +(defun yas--delete-regions (regions) "Sort disjuct REGIONS by start point, then delete from the back." (mapc #'(lambda (reg) (delete-region (car reg) (cdr reg))) @@ -3388,220 +4177,240 @@ When multiple expressions are found, only the last one counts." #'(lambda (r1 r2) (>= (car r1) (car r2)))))) -(defun yas/update-mirrors (snippet) - "Updates all the mirrors of SNIPPET." +(defun yas--calculate-mirror-depth (mirror &optional traversed) + (let* ((parent (yas--mirror-parent-field mirror)) + (parents-mirrors (and parent + (yas--field-mirrors parent)))) + (or (yas--mirror-depth mirror) + (setf (yas--mirror-depth mirror) + (cond ((memq mirror traversed) + 0) + ((and parent parents-mirrors) + (1+ (reduce #'max + (mapcar #'(lambda (m) + (yas--calculate-mirror-depth m + (cons mirror + traversed))) + parents-mirrors)))) + (parent + 1) + (t + 0)))))) + +(defun yas--update-mirrors (snippet) + "Update all the mirrors of SNIPPET." (save-excursion - (dolist (field (yas/snippet-fields snippet)) - (dolist (mirror (yas/field-mirrors field)) - ;; stacked expansion: I added an `inhibit-modification-hooks' - ;; here, for safety, may need to remove if we the mechanism is - ;; altered. + (dolist (field-and-mirror (sort + ;; make a list of ((F1 . M1) (F1 . M2) (F2 . M3) (F2 . M4) ...) + ;; where F is the field that M is mirroring + ;; + (mapcan #'(lambda (field) + (mapcar #'(lambda (mirror) + (cons field mirror)) + (yas--field-mirrors field))) + (yas--snippet-fields snippet)) + ;; then sort this list so that entries with mirrors with parent + ;; fields appear before. This was important for fixing #290, and + ;; luckily also handles the case where a mirror in a field causes + ;; another mirror to need reupdating + ;; + #'(lambda (field-and-mirror1 field-and-mirror2) + (> (yas--calculate-mirror-depth (cdr field-and-mirror1)) + (yas--calculate-mirror-depth (cdr field-and-mirror2)))))) + (let* ((field (car field-and-mirror)) + (mirror (cdr field-and-mirror)) + (parent-field (yas--mirror-parent-field mirror))) + ;; before updating a mirror with a parent-field, maybe advance + ;; its start (#290) ;; - (let ((inhibit-modification-hooks t)) - (yas/mirror-update-display mirror field) - ;; `yas/place-overlays' is needed if the active field and - ;; protected overlays have been changed because of insertions - ;; in `yas/mirror-update-display' - ;; - (when (eq field (yas/snippet-active-field snippet)) - (yas/place-overlays snippet field))))))) + (when parent-field + (yas--advance-start-maybe mirror (yas--fom-start parent-field))) + ;; update this mirror + ;; + (yas--mirror-update-display mirror field) + ;; `yas--place-overlays' is needed if the active field and + ;; protected overlays have been changed because of insertions + ;; in `yas--mirror-update-display' + ;; + (when (eq field (yas--snippet-active-field snippet)) + (yas--place-overlays snippet field)))))) -(defun yas/mirror-update-display (mirror field) +(defun yas--mirror-update-display (mirror field) "Update MIRROR according to FIELD (and mirror transform)." - (let ((reflection (or (yas/apply-transform mirror field) - (yas/field-text-for-display field)))) + + (let* ((mirror-parent-field (yas--mirror-parent-field mirror)) + (reflection (and (not (and mirror-parent-field + (yas--field-modified-p mirror-parent-field))) + (or (yas--apply-transform mirror field 'empty-on-nil) + (yas--field-text-for-display field))))) (when (and reflection - (not (string= reflection (buffer-substring-no-properties (yas/mirror-start mirror) - (yas/mirror-end mirror))))) - (goto-char (yas/mirror-start mirror)) - (insert reflection) - (if (> (yas/mirror-end mirror) (point)) - (delete-region (point) (yas/mirror-end mirror)) - (set-marker (yas/mirror-end mirror) (point)) - (yas/advance-start-maybe (yas/mirror-next mirror) (point)))))) - -(defun yas/field-update-display (field snippet) - "Much like `yas/mirror-update-display', but for fields" - (when (yas/field-transform field) - (let ((inhibit-modification-hooks t) - (transformed (yas/apply-transform field field)) - (point (point))) + (not (string= reflection (buffer-substring-no-properties (yas--mirror-start mirror) + (yas--mirror-end mirror))))) + (goto-char (yas--mirror-start mirror)) + (yas--inhibit-overlay-hooks + (insert reflection)) + (if (> (yas--mirror-end mirror) (point)) + (delete-region (point) (yas--mirror-end mirror)) + (set-marker (yas--mirror-end mirror) (point)) + (yas--advance-start-maybe (yas--mirror-next mirror) (point)) + ;; super-special advance + (yas--advance-end-of-parents-maybe mirror-parent-field (point)))))) + +(defun yas--field-update-display (field) + "Much like `yas--mirror-update-display', but for fields." + (when (yas--field-transform field) + (let ((transformed (and (not (eq (yas--field-number field) 0)) + (yas--apply-transform field field)))) (when (and transformed - (not (string= transformed (buffer-substring-no-properties (yas/field-start field) - (yas/field-end field))))) - (setf (yas/field-modified-p field) t) - (goto-char (yas/field-start field)) - (insert transformed) - (if (> (yas/field-end field) (point)) - (delete-region (point) (yas/field-end field)) - (set-marker (yas/field-end field) (point)) - (yas/advance-start-maybe (yas/field-next field) (point))) - t)))) + (not (string= transformed (buffer-substring-no-properties (yas--field-start field) + (yas--field-end field))))) + (setf (yas--field-modified-p field) t) + (goto-char (yas--field-start field)) + (yas--inhibit-overlay-hooks + (insert transformed) + (if (> (yas--field-end field) (point)) + (delete-region (point) (yas--field-end field)) + (set-marker (yas--field-end field) (point)) + (yas--advance-start-maybe (yas--field-next field) (point))) + t))))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Pre- and post-command hooks +;;; Post-command hook: ;; -(defun yas/pre-command-handler () ) - -(defun yas/post-command-handler () +(defun yas--post-command-handler () "Handles various yasnippet conditions after each command." - (cond (yas/protection-violation - (goto-char yas/protection-violation) - (setq yas/protection-violation nil)) - ((eq 'undo this-command) + (cond ((eq 'undo this-command) ;; ;; After undo revival the correct field is sometimes not ;; restored correctly, this condition handles that ;; - (let* ((snippet (car (yas/snippets-at-point))) + (let* ((snippet (car (yas--snippets-at-point))) (target-field (and snippet (find-if-not #'(lambda (field) - (yas/field-probably-deleted-p snippet field)) + (yas--field-probably-deleted-p snippet field)) (remove nil - (cons (yas/snippet-active-field snippet) - (yas/snippet-fields snippet))))))) + (cons (yas--snippet-active-field snippet) + (yas--snippet-fields snippet))))))) (when target-field - (yas/move-to-field snippet target-field)))) - ((not (yas/undo-in-progress)) - ;; When not in an undo, check if we must commit the snippet (use exited it). - (yas/check-commit-snippet)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Debug functions. Use (or change) at will whenever needed. -;; -;; some useful debug code for looking up snippet tables + (yas--move-to-field snippet target-field)))) + ((not (yas--undo-in-progress)) + ;; When not in an undo, check if we must commit the snippet + ;; (user exited it). + (yas--check-commit-snippet)))) + +;;; Fancy docs: ;; -;; (insert (pp -;; (let ((shit)) -;; (maphash #'(lambda (k v) -;; (push k shit)) -;; (yas/snippet-table-hash (gethash 'ruby-mode yas/snippet-tables))) -;; shit))) +;; The docstrings for some functions are generated dynamically +;; depending on the context. ;; +(put 'yas-expand 'function-documentation + '(yas--expand-from-trigger-key-doc t)) +(defun yas--expand-from-trigger-key-doc (context) + "A doc synthesizer for `yas--expand-from-trigger-key-doc'." + (let* ((yas-fallback-behavior (and context yas-fallback-behavior)) + (fallback-description + (cond ((eq yas-fallback-behavior 'call-other-command) + (let* ((fallback (yas--keybinding-beyond-yasnippet))) + (or (and fallback + (format "call command `%s'." + (pp-to-string fallback))) + "do nothing (`yas-expand' doesn't shadow\nanything)."))) + ((eq yas-fallback-behavior 'return-nil) + "do nothing.") + (t "defer to `yas-fallback-behavior' (which see).")))) + (concat "Expand a snippet before point. If no snippet +expansion is possible, " + fallback-description + "\n\nOptional argument FIELD is for non-interactive use and is an +object satisfying `yas--field-p' to restrict the expansion to."))) + +(put 'yas-expand-from-keymap 'function-documentation + '(yas--expand-from-keymap-doc t)) +(defun yas--expand-from-keymap-doc (context) + "A doc synthesizer for `yas--expand-from-keymap-doc'." + (add-hook 'temp-buffer-show-hook 'yas--snippet-description-finish-runonce) + (concat "Expand/run snippets from keymaps, possibly falling back to original binding.\n" + (when (and context (eq this-command 'describe-key)) + (let* ((vec (this-single-command-keys)) + (templates (mapcan #'(lambda (table) + (yas--fetch table vec)) + (yas--get-snippet-tables))) + (yas--direct-keymaps nil) + (fallback (key-binding vec))) + (concat "In this case, " + (when templates + (concat "these snippets are bound to this key:\n" + (yas--template-pretty-list templates) + "\n\nIf none of these expands, ")) + (or (and fallback + (format "fallback `%s' will be called." (pp-to-string fallback))) + "no fallback keybinding is called.")))))) + +(defun yas--template-pretty-list (templates) + (let ((acc) + (yas-buffer-local-condition 'always)) + (dolist (plate templates) + (setq acc (concat acc "\n*) " + (propertize (concat "\\\\snippet `" (car plate) "'") + 'yasnippet (cdr plate))))) + acc)) + +(define-button-type 'help-snippet-def + :supertype 'help-xref + 'help-function (lambda (template) (yas--visit-snippet-file-1 template)) + 'help-echo (purecopy "mouse-2, RET: find snippets's definition")) + +(defun yas--snippet-description-finish-runonce () + "Final adjustments for the help buffer when snippets are concerned." + (yas--create-snippet-xrefs) + (remove-hook 'temp-buffer-show-hook 'yas--snippet-description-finish-runonce)) + +(defun yas--create-snippet-xrefs () + (save-excursion + (goto-char (point-min)) + (while (search-forward-regexp "\\\\\\\\snippet[ \s\t]+`\\([^']+\\)'" nil t) + (let ((template (get-text-property (match-beginning 1) + 'yasnippet))) + (when template + (help-xref-button 1 'help-snippet-def template) + (kill-region (match-end 1) (match-end 0)) + (kill-region (match-beginning 0) (match-beginning 1))))))) + +;;; Utils -(defun yas/debug-tables () - (interactive) - (with-output-to-temp-buffer "*YASnippet tables*" - (dolist (symbol (remove nil (append (list major-mode) - (if (listp yas/mode-symbol) - yas/mode-symbol - (list yas/mode-symbol))))) - (princ (format "Snippet table hash keys for %s:\n\n" symbol)) - (let ((keys)) - (maphash #'(lambda (k v) - (push k keys)) - (yas/snippet-table-hash (gethash symbol yas/snippet-tables))) - (princ keys)) +(defvar yas-verbosity 4 + "Log level for `yas--message' 4 means trace most anything, 0 means nothing.") - (princ (format "Keymap for %s:\n\n" symbol)) - (princ (gethash symbol yas/menu-table))))) +(defun yas--message (level message &rest args) + "When LEVEL is above `yas-verbosity-level', log MESSAGE and ARGS." + (when (> yas-verbosity level) + (message "%s" (apply #'yas--format message args)))) -(defun yas/debug-snippet-vars () - "Debug snippets, fields, mirrors and the `buffer-undo-list'." - (interactive) - (with-output-to-temp-buffer "*YASnippet trace*" - (princ "Interesting YASnippet vars: \n\n") - - (princ (format "\nPost command hook: %s\n" post-command-hook)) - (princ (format "\nPre command hook: %s\n" pre-command-hook)) - - (princ (format "%s live snippets in total\n" (length (yas/snippets-at-point (quote all-snippets))))) - (princ (format "%s overlays in buffer:\n\n" (length (overlays-in (point-min) (point-max))))) - (princ (format "%s live snippets at point:\n\n" (length (yas/snippets-at-point)))) - - - (dolist (snippet (yas/snippets-at-point)) - (princ (format "\tsid: %d control overlay from %d to %d\n" - (yas/snippet-id snippet) - (overlay-start (yas/snippet-control-overlay snippet)) - (overlay-end (yas/snippet-control-overlay snippet)))) - (princ (format "\tactive field: %d from %s to %s covering \"%s\"\n" - (yas/field-number (yas/snippet-active-field snippet)) - (marker-position (yas/field-start (yas/snippet-active-field snippet))) - (marker-position (yas/field-end (yas/snippet-active-field snippet))) - (buffer-substring-no-properties (yas/field-start (yas/snippet-active-field snippet)) (yas/field-end (yas/snippet-active-field snippet))))) - (when (yas/snippet-exit snippet) - (princ (format "\tsnippet-exit: at %s next: %s\n" - (yas/exit-marker (yas/snippet-exit snippet)) - (yas/exit-next (yas/snippet-exit snippet))))) - (dolist (field (yas/snippet-fields snippet)) - (princ (format "\tfield: %d from %s to %s covering \"%s\" next: %s\n" - (yas/field-number field) - (marker-position (yas/field-start field)) - (marker-position (yas/field-end field)) - (buffer-substring-no-properties (yas/field-start field) (yas/field-end field)) - (yas/debug-format-fom-concise (yas/field-next field)))) - (dolist (mirror (yas/field-mirrors field)) - (princ (format "\t\tmirror: from %s to %s covering \"%s\" next: %s\n" - (marker-position (yas/mirror-start mirror)) - (marker-position (yas/mirror-end mirror)) - (buffer-substring-no-properties (yas/mirror-start mirror) (yas/mirror-end mirror)) - (yas/debug-format-fom-concise (yas/mirror-next mirror))))))) - - (princ (format "\nUndo is %s and point-max is %s.\n" - (if (eq buffer-undo-list t) - "DISABLED" - "ENABLED") - (point-max))) - (unless (eq buffer-undo-list t) - (princ (format "Undpolist has %s elements. First 10 elements follow:\n" (length buffer-undo-list))) - (let ((first-ten (subseq buffer-undo-list 0 19))) - (dolist (undo-elem first-ten) - (princ (format "%2s: %s\n" (position undo-elem first-ten) (truncate-string-to-width (format "%s" undo-elem) 70)))))))) - -(defun yas/debug-format-fom-concise (fom) - (when fom - (cond ((yas/field-p fom) - (format "field %d from %d to %d" - (yas/field-number fom) - (marker-position (yas/field-start fom)) - (marker-position (yas/field-end fom)))) - ((yas/mirror-p fom) - (format "mirror from %d to %d" - (marker-position (yas/mirror-start fom)) - (marker-position (yas/mirror-end fom)))) - (t - (format "snippet exit at %d" - (marker-position (yas/fom-start fom))))))) +(defun yas--warning (format-control &rest format-args) + (let ((msg (apply #'format format-control format-args))) + (display-warning 'yasnippet msg :warning) + (yas--message 1 msg))) +(defun yas--format (format-control &rest format-args) + (apply #'format (concat "[yas] " format-control) format-args)) -(defun yas/exterminate-package () - (interactive) - (yas/global-mode -1) - (yas/minor-mode -1) - (yas/kill-snippet-keybindings) - (mapatoms #'(lambda (atom) - (when (string-match "yas/" (symbol-name atom)) - (unintern atom))))) - -(defun yas/debug-test (&optional quiet) - (interactive "P") - (yas/load-directory (or (and (listp yas/root-directory) - (first yas/root-directory)) - yas/root-directory - "~/Source/yasnippet/snippets/")) - (set-buffer (switch-to-buffer "*YAS TEST*")) - (mapc #'yas/commit-snippet (yas/snippets-at-point 'all-snippets)) - (erase-buffer) - (setq buffer-undo-list nil) - (setq undo-in-progress nil) - (snippet-mode) - (yas/minor-mode 1) - (let ((abbrev)) - (setq abbrev "$f") - (insert abbrev)) - (unless quiet - (add-hook 'post-command-hook 'yas/debug-snippet-vars 't 'local))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; `locate-dominating-file' is added for compatibility in emacs < 23 -(unless (or (eq emacs-major-version 23) - (fboundp 'locate-dominating-file)) - (defvar locate-dominating-stop-dir-regexp - "\\`\\(?:[\\/][\\/][^\\/]+[\\/]\\|/\\(?:net\\|afs\\|\\.\\.\\.\\)/\\)\\'" - "Regexp of directory names which stop the search in `locate-dominating-file'. + +;;; Some hacks: +;; +;; The functions +;; +;; `locate-dominating-file' +;; `region-active-p' +;; +;; added for compatibility in emacsen < 23 +(unless (>= emacs-major-version 23) + (unless (fboundp 'region-active-p) + (defun region-active-p () (and transient-mark-mode mark-active))) + + (unless (fboundp 'locate-dominating-file) + (defvar locate-dominating-stop-dir-regexp + "\\`\\(?:[\\/][\\/][^\\/]+[\\/]\\|/\\(?:net\\|afs\\|\\.\\.\\.\\)/\\)\\'" + "Regexp of directory names which stop the search in `locate-dominating-file'. Any directory whose name matches this regexp will be treated like a kind of root directory by `locate-dominating-file' which will stop its search when it bumps into it. @@ -3609,68 +4418,186 @@ The default regexp prevents fruitless and time-consuming attempts to find special files in directories in which filenames are interpreted as hostnames, or mount points potentially requiring authentication as a different user.") - (defun locate-dominating-file (file name) - "Look up the directory hierarchy from FILE for a file named NAME. + (defun locate-dominating-file (file name) + "Look up the directory hierarchy from FILE for a file named NAME. Stop at the first parent directory containing a file NAME, and return the directory. Return nil if not found." - ;; We used to use the above locate-dominating-files code, but the - ;; directory-files call is very costly, so we're much better off doing - ;; multiple calls using the code in here. - ;; - ;; Represent /home/luser/foo as ~/foo so that we don't try to look for - ;; `name' in /home or in /. - (setq file (abbreviate-file-name file)) - (let ((root nil) - (prev-file file) - ;; `user' is not initialized outside the loop because - ;; `file' may not exist, so we may have to walk up part of the - ;; hierarchy before we find the "initial UID". - (user nil) - try) - (while (not (or root - (null file) - ;; FIXME: Disabled this heuristic because it is sometimes - ;; inappropriate. - ;; As a heuristic, we stop looking up the hierarchy of - ;; directories as soon as we find a directory belonging - ;; to another user. This should save us from looking in - ;; things like /net and /afs. This assumes that all the - ;; files inside a project belong to the same user. - ;; (let ((prev-user user)) - ;; (setq user (nth 2 (file-attributes file))) - ;; (and prev-user (not (equal user prev-user)))) - (string-match locate-dominating-stop-dir-regexp file))) - (setq try (file-exists-p (expand-file-name name file))) - (cond (try (setq root file)) - ((equal file (setq prev-file file - file (file-name-directory - (directory-file-name file)))) - (setq file nil)))) - root))) - -(provide 'yasnippet) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Monkey patching for other functions that's causing -;; problems to yasnippet. For details on why I patch -;; those functions, refer to -;; http://code.google.com/p/yasnippet/wiki/MonkeyPatching -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defadvice c-neutralize-syntax-in-CPP - (around yas-mp/c-neutralize-syntax-in-CPP activate) - "Adviced `c-neutralize-syntax-in-CPP' to properly -handle the end-of-buffer error fired in it by calling -`forward-char' at the end of buffer." - (condition-case err - ad-do-it - (error (message (error-message-string err))))) - -;; disable c-electric-* serial command in YAS fields -(add-hook 'c-mode-common-hook - '(lambda () - (dolist (k '(":" ">" ";" "<" "{" "}")) - (define-key (symbol-value (make-local-variable 'yas/keymap)) - k 'self-insert-command)))) + ;; We used to use the above locate-dominating-files code, but the + ;; directory-files call is very costly, so we're much better off doing + ;; multiple calls using the code in here. + ;; + ;; Represent /home/luser/foo as ~/foo so that we don't try to look for + ;; `name' in /home or in /. + (setq file (abbreviate-file-name file)) + (let ((root nil) + try) + (while (not (or root + (null file) + ;; FIXME: Disabled this heuristic because it is sometimes + ;; inappropriate. + ;; As a heuristic, we stop looking up the hierarchy of + ;; directories as soon as we find a directory belonging + ;; to another user. This should save us from looking in + ;; things like /net and /afs. This assumes that all the + ;; files inside a project belong to the same user. + ;; (let ((prev-user user)) + ;; (setq user (nth 2 (file-attributes file))) + ;; (and prev-user (not (equal user prev-user)))) + (string-match locate-dominating-stop-dir-regexp file))) + (setq try (file-exists-p (expand-file-name name file))) + (cond (try (setq root file)) + ((equal file (setq file (file-name-directory + (directory-file-name file)))) + (setq file nil)))) + root)))) + +;;; Backward compatibility to yasnippet <= 0.7 + +(defun yas-initialize () + "For backward compatibility, enable `yas-minor-mode' globally." + (yas-global-mode 1)) + +(defvar yas--backported-syms '(;; `defcustom's + ;; + yas-snippet-dirs + yas-prompt-functions + yas-indent-line + yas-also-auto-indent-first-line + yas-snippet-revival + yas-triggers-in-field + yas-fallback-behavior + yas-choose-keys-first + yas-choose-tables-first + yas-use-menu + yas-trigger-symbol + yas-wrap-around-region + yas-good-grace + yas-visit-from-menu + yas-expand-only-for-last-commands + yas-field-highlight-face + + ;; these vars can be customized as well + ;; + yas-keymap + yas-verbosity + yas-extra-modes + yas-key-syntaxes + yas-after-exit-snippet-hook + yas-before-expand-snippet-hook + yas-buffer-local-condition + yas-dont-activate + + ;; prompting functions + ;; + yas-x-prompt + yas-ido-prompt + yas-no-prompt + yas-completing-prompt + yas-dropdown-prompt + + ;; interactive functions + ;; + yas-expand + yas-minor-mode + yas-global-mode + yas-direct-keymaps-reload + yas-minor-mode-on + yas-load-directory + yas-reload-all + yas-compile-directory + yas-recompile-all + yas-about + yas-expand-from-trigger-key + yas-expand-from-keymap + yas-insert-snippet + yas-visit-snippet-file + yas-new-snippet + yas-load-snippet-buffer + yas-tryout-snippet + yas-describe-tables + yas-next-field-or-maybe-expand + yas-next-field + yas-prev-field + yas-abort-snippet + yas-exit-snippet + yas-exit-all-snippets + yas-skip-and-clear-or-delete-char + yas-initialize + + ;; symbols that I "exported" for use + ;; in snippets and hookage + ;; + yas-expand-snippet + yas-define-snippets + yas-define-menu + yas-snippet-beg + yas-snippet-end + yas-modified-p + yas-moving-away-p + yas-substr + yas-choose-value + yas-key-to-value + yas-throw + yas-verify-value + yas-field-value + yas-text + yas-selected-text + yas-default-from-field + yas-inside-string + yas-unimplemented + yas-define-condition-cache + yas-hippie-try-expand + + ;; debug definitions + ;; yas-debug-snippet-vars + ;; yas-exterminate-package + ;; yas-debug-test + + ;; testing definitions + ;; yas-should-expand + ;; yas-should-not-expand + ;; yas-mock-insert + ;; yas-make-file-or-dirs + ;; yas-variables + ;; yas-saving-variables + ;; yas-call-with-snippet-dirs + ;; yas-with-snippet-dirs +) + "Backported yasnippet symbols. + +They are mapped to \"yas/*\" variants.") + +(dolist (sym yas--backported-syms) + (let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym))))) + (when (boundp sym) + (make-obsolete-variable backported sym "yasnippet 0.8") + (defvaralias backported sym)) + (when (fboundp sym) + (make-obsolete backported sym "yasnippet 0.8") + (defalias backported sym)))) + +(defvar yas--exported-syms + (let (exported) + (mapatoms (lambda (atom) + (if (and (or (and (boundp atom) + (not (get atom 'byte-obsolete-variable))) + (and (fboundp atom) + (not (get atom 'byte-obsolete-info)))) + (string-match-p "^yas-[^-]" (symbol-name atom))) + (push atom exported)))) + exported) + "Exported yasnippet symbols. + +i.e. the ones with \"yas-\" single dash prefix. I will try to +keep them in future yasnippet versions and other elisp libraries +can more or less safely rely upon them.") + +(provide 'yasnippet) +;; Local Variables: +;; coding: utf-8 +;; indent-tabs-mode: nil +;; byte-compile-warnings: (not cl-functions) +;; End: ;;; yasnippet.el ends here diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/beginend b/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/beginend deleted file mode 100644 index 68303e2..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/beginend +++ /dev/null @@ -1,3 +0,0 @@ -#name : v.begin(), v.end() -# -- -${1:v}.begin(), $1.end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/class b/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/class deleted file mode 100644 index 820fc6c..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/class +++ /dev/null @@ -1,8 +0,0 @@ -#name : class ... { ... } -# -- -class ${1:Name} -{ -public: - ${1:$(yas/substr text "[^: ]*")}($2); - virtual ~${1:$(yas/substr text "[^: ]*")}(); -}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/ns b/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/ns deleted file mode 100644 index 0c2513f..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/ns +++ /dev/null @@ -1,3 +0,0 @@ -#name : namespace ... -# -- -namespace \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/template b/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/template deleted file mode 100644 index 7e50616..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/template +++ /dev/null @@ -1,3 +0,0 @@ -#name : template -# -- -template \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/using b/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/using deleted file mode 100644 index 13d0f5d..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c++-mode/using +++ /dev/null @@ -1,4 +0,0 @@ -#name : using namespace ... -# -- -using namespace ${std}; -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/fopen b/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/fopen deleted file mode 100644 index 044c743..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/fopen +++ /dev/null @@ -1,3 +0,0 @@ -#name : FILE *fp = fopen(..., ...); -# -- -FILE *${fp} = fopen(${"file"}, "${r}"); diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/printf b/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/printf deleted file mode 100644 index 055461d..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/c-mode/printf +++ /dev/null @@ -1,6 +0,0 @@ -# -*- mode: snippet -*- -# name : printf -# contributor : joaotavora -# -- -printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);") -}$2${1:$(if (string-match "%" text) "\);" "")} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib deleted file mode 100644 index 9e14e22..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : private attribute ....; -# -- -/// -/// $3 -/// -private $1 $2; diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.1 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.1 deleted file mode 100644 index 099cc7b..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.1 +++ /dev/null @@ -1,21 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : private attribute ....; public property ... ... { ... } -# -- -/// -/// $3 -/// -private $1 $2; - -/// -/// $4 -/// -/// $5 -public $1 $2 -{ - get { - return this.$2; - } - set { - this.$2 = value; - } -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.2 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.2 deleted file mode 100644 index 566eacf..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/attrib.2 +++ /dev/null @@ -1,21 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : private _attribute ....; public Property ... ... { ... } -# -- -/// -/// $3 -/// -private $1 ${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")}; - -/// -/// ${3:Description} -/// -/// $1 -public ${1:Type} ${2:Name} -{ - get { - return this.${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")}; - } - set { - this.${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")} = value; - } -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/class b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/class deleted file mode 100644 index 1cce2e8..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/class +++ /dev/null @@ -1,21 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : class ... { ... } -# -- -${5:public} class ${1:Name} -{ - #region Ctor & Destructor - /// - /// ${3:Standard Constructor} - /// - public $1($2) - { - } - - /// - /// ${4:Default Destructor} - /// - public ~$1() - { - } - #endregion -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment deleted file mode 100644 index 3bd20d3..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : /// ... -# -- -/// -/// $1 -/// diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.1 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.1 deleted file mode 100644 index 3c14ad9..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.1 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : /// ... -# -- -/// $2 diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.2 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.2 deleted file mode 100644 index 63a6a20..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.2 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : /// ... -# -- -/// $1 diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.3 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.3 deleted file mode 100644 index 394c323..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/comment.3 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : /// ... -# -- -/// $2 diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/method b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/method deleted file mode 100644 index e9a5906..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/method +++ /dev/null @@ -1,10 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : public void Method { ... } -# -- -/// -/// ${5:Description} -/// ${2:$(if (string= (upcase text) "VOID") "" (format "%s%s%s" "\n/// " text ""))} -${1:public} ${2:void} ${3:MethodName}($4) -{ -$0 -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/namespace b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/namespace deleted file mode 100644 index af7c928..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/namespace +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : namespace .. { ... } -# -- -namespace $1 -{ -$0 -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/prop b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/prop deleted file mode 100644 index df9df91..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/prop +++ /dev/null @@ -1,16 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : property ... ... { ... } -# -- -/// -/// $5 -/// -/// $6 -$1 $2 $3 -{ - get { - return this.$4; - } - set { - this.$4 = value; - } -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/region b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/region deleted file mode 100644 index 83f9a24..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/region +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : #region ... #endregion -# -- -#region $1 -$0 -#endregion diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using deleted file mode 100644 index 704637e..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : using ...; -# -- -using $1; diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.1 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.1 deleted file mode 100644 index e9f0bb0..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.1 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : using System; -# -- -using System; diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.2 b/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.2 deleted file mode 100644 index 0a3c07d..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/csharp-mode/using.2 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : using System....; -# -- -using System.$1; diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/do b/.emacs.d/mysnippets/text-mode/cc-mode/do deleted file mode 100644 index 5f7a313..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/do +++ /dev/null @@ -1,6 +0,0 @@ -#name : do { ... } while (...) -# -- -do -{ - $0 -} while (${1:condition}); \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/for b/.emacs.d/mysnippets/text-mode/cc-mode/for deleted file mode 100644 index c4cade6..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/for +++ /dev/null @@ -1,6 +0,0 @@ -#name : for (...; ...; ...) { ... } -# -- -for (${1:int i = 0}; ${2:i < N}; ${3:++i}) -{ - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/if b/.emacs.d/mysnippets/text-mode/cc-mode/if deleted file mode 100644 index c3fe10d..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/if +++ /dev/null @@ -1,6 +0,0 @@ -#name : if (...) { ... } -# -- -if (${1:condition}) -{ - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/inc b/.emacs.d/mysnippets/text-mode/cc-mode/inc deleted file mode 100644 index ae33328..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/inc +++ /dev/null @@ -1,3 +0,0 @@ -#name : #include "..." -# -- -#include "$1" diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/inc.1 b/.emacs.d/mysnippets/text-mode/cc-mode/inc.1 deleted file mode 100644 index 66326cd..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/inc.1 +++ /dev/null @@ -1,3 +0,0 @@ -#name : #include <...> -# -- -#include <$1> diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/main b/.emacs.d/mysnippets/text-mode/cc-mode/main deleted file mode 100644 index 9249049..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/main +++ /dev/null @@ -1,7 +0,0 @@ -#name: int main(argc, argv) { ... } -# -- -int main(int argc, char *argv[]) -{ - $0 - return 0; -} diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/objc-mode/prop b/.emacs.d/mysnippets/text-mode/cc-mode/objc-mode/prop deleted file mode 100644 index 4d585db..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/objc-mode/prop +++ /dev/null @@ -1,13 +0,0 @@ -#name : foo { ... } ; setFoo { ... } -# -- -- (${1:id})${2:foo} -{ - return $2; -} - -- (void)set${2:$(capitalize text)}:($1)aValue -{ - [$2 autorelease]; - $2 = [aValue retain]; -} -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/once b/.emacs.d/mysnippets/text-mode/cc-mode/once deleted file mode 100644 index 1b63c39..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/once +++ /dev/null @@ -1,8 +0,0 @@ -#name : #ifndef XXX; #define XXX; #endif -# -- -#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_} -#define $1 - -$0 - -#endif /* $1 */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/cc-mode/struct b/.emacs.d/mysnippets/text-mode/cc-mode/struct deleted file mode 100644 index f50dabf..0000000 --- a/.emacs.d/mysnippets/text-mode/cc-mode/struct +++ /dev/null @@ -1,6 +0,0 @@ -#name : struct ... { ... } -# -- -struct ${1:name} -{ - $0 -}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/css-mode/bg b/.emacs.d/mysnippets/text-mode/css-mode/bg deleted file mode 100644 index d731807..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/bg +++ /dev/null @@ -1,3 +0,0 @@ -#name : background-color: ... -# -- -background-color: #${1:DDD}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/css-mode/bg.1 b/.emacs.d/mysnippets/text-mode/css-mode/bg.1 deleted file mode 100644 index d31f540..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/bg.1 +++ /dev/null @@ -1,3 +0,0 @@ -#name : background-image: ... -# -- -background-image: url($1); \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/css-mode/bor b/.emacs.d/mysnippets/text-mode/css-mode/bor deleted file mode 100644 index eb3a2b4..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/bor +++ /dev/null @@ -1,3 +0,0 @@ -#name : border size style color -# -- -border: ${1:1px} ${2:solid} #${3:999}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/css-mode/cl b/.emacs.d/mysnippets/text-mode/css-mode/cl deleted file mode 100644 index 4fc7a8d..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/cl +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : clear: ... -# -- -clear: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/disp.block b/.emacs.d/mysnippets/text-mode/css-mode/disp.block deleted file mode 100644 index f74ea3c..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/disp.block +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : display: block -# -- -display: block; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/disp.inline b/.emacs.d/mysnippets/text-mode/css-mode/disp.inline deleted file mode 100644 index 30275a8..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/disp.inline +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : display: inline -# -- -display: inline; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/disp.none b/.emacs.d/mysnippets/text-mode/css-mode/disp.none deleted file mode 100644 index 80632a5..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/disp.none +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : display: none -# -- -display: none; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/ff b/.emacs.d/mysnippets/text-mode/css-mode/ff deleted file mode 100644 index a7352cf..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/ff +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : font-family: ... -# -- -font-family: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/fs b/.emacs.d/mysnippets/text-mode/css-mode/fs deleted file mode 100644 index c28cdbb..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/fs +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : font-size: ... -# -- -font-size: ${12px}; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.bottom b/.emacs.d/mysnippets/text-mode/css-mode/mar.bottom deleted file mode 100644 index 9672f60..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.bottom +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin-bottom: ... -# -- -margin-bottom: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.left b/.emacs.d/mysnippets/text-mode/css-mode/mar.left deleted file mode 100644 index 414353e..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.left +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin-left: ... -# -- -margin-left: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.mar b/.emacs.d/mysnippets/text-mode/css-mode/mar.mar deleted file mode 100644 index 13354db..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.mar +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin: ... -# -- -margin: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.margin b/.emacs.d/mysnippets/text-mode/css-mode/mar.margin deleted file mode 100644 index 97de70c..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.margin +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin top right bottom left -# -- -margin: ${top} ${right} ${bottom} ${left}; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.right b/.emacs.d/mysnippets/text-mode/css-mode/mar.right deleted file mode 100644 index 47a4973..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.right +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin-right: ... -# -- -margin-right: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/mar.top b/.emacs.d/mysnippets/text-mode/css-mode/mar.top deleted file mode 100644 index c805754..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/mar.top +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : margin-top: ... -# -- -margin-top: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.bottom b/.emacs.d/mysnippets/text-mode/css-mode/pad.bottom deleted file mode 100644 index 3b9495e..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.bottom +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding-bottom: ... -# -- -padding-bottom: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.left b/.emacs.d/mysnippets/text-mode/css-mode/pad.left deleted file mode 100644 index ecae515..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.left +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding-left: ... -# -- -padding-left: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.pad b/.emacs.d/mysnippets/text-mode/css-mode/pad.pad deleted file mode 100644 index ee3a682..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.pad +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding: ... -# -- -padding: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.padding b/.emacs.d/mysnippets/text-mode/css-mode/pad.padding deleted file mode 100644 index c1009d3..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.padding +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding: top right bottom left -# -- -padding: ${top} ${right} ${bottom} ${left}; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.right b/.emacs.d/mysnippets/text-mode/css-mode/pad.right deleted file mode 100644 index 98a9e12..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.right +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding-right: ... -# -- -padding-right: $1; diff --git a/.emacs.d/mysnippets/text-mode/css-mode/pad.top b/.emacs.d/mysnippets/text-mode/css-mode/pad.top deleted file mode 100644 index 34987f6..0000000 --- a/.emacs.d/mysnippets/text-mode/css-mode/pad.top +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : rejeep -#name : padding-top: ... -# -- -padding-top: $1; diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/.read_me b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/.read_me deleted file mode 100644 index 9e6e532..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/.read_me +++ /dev/null @@ -1,11 +0,0 @@ -TITLE: Emacs Idiom Template Set. Version 1. 2009-02-22 - -DESCRIPTION: Some useful templates for emacs lisp. This template set is based on useful elisp idioms on common tasks. - -LICENSING: GPL version 3. - -AUTHOR: Xah Lee - -Home Page: latest version at: -• Emacs Lisp Idiom Templates - http://xahlee.org/emacs/elisp_idiom_templates.html diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/defun b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/defun deleted file mode 100644 index 0105d20..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/defun +++ /dev/null @@ -1,11 +0,0 @@ -#name : function template -#contributor : Xah Lee -# -- -(defun $1 () - "thisandthat." - (interactive) - (let (var1) - (setq var1 some) - $0 - ) -) \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/dired.process_marked b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/dired.process_marked deleted file mode 100644 index 1b42597..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/dired.process_marked +++ /dev/null @@ -1,16 +0,0 @@ -#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 diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.process b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.process deleted file mode 100644 index abd1a33..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.process +++ /dev/null @@ -1,17 +0,0 @@ -#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"))) diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines deleted file mode 100644 index b4a1942..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines +++ /dev/null @@ -1,17 +0,0 @@ -#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") -) \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace deleted file mode 100644 index cefcf51..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace +++ /dev/null @@ -1,17 +0,0 @@ -#name : find and replace on region -#contributor : Xah Lee -# -- -(defun replace-html-chars-region (start end) - "Replace “<” to “<” 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 "&" nil t)) - (goto-char (point-min)) - (while (search-forward "<" nil t) (replace-match "<" nil t)) - (goto-char (point-min)) - (while (search-forward ">" nil t) (replace-match ">" nil t)) - ) - ) diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabstring b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabstring deleted file mode 100644 index 55600b1..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabstring +++ /dev/null @@ -1,4 +0,0 @@ -#name : grab buffer substring -#contributor : Xah Lee -# -- -(setq $0 (buffer-substring-no-properties myStartPos myEndPos)) diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabthing b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabthing deleted file mode 100644 index 772b8dc..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/grabthing +++ /dev/null @@ -1,4 +0,0 @@ -#name : grab word under cursor -#contributor : Xah Lee -# -- -(setq $0 (thing-at-point 'symbol)) diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/traverse_dir b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/traverse_dir deleted file mode 100644 index 2859cbd..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/traverse_dir +++ /dev/null @@ -1,6 +0,0 @@ -#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$")) diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/word-or-region b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/word-or-region deleted file mode 100644 index 66a59e4..0000000 --- a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/word-or-region +++ /dev/null @@ -1,27 +0,0 @@ -#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 - - ) -) diff --git a/.emacs.d/mysnippets/text-mode/email b/.emacs.d/mysnippets/text-mode/email deleted file mode 100644 index 1ac7f94..0000000 --- a/.emacs.d/mysnippets/text-mode/email +++ /dev/null @@ -1,3 +0,0 @@ -#name : (user's email) -# -- -`(replace-regexp-in-string "@" "@NOSPAM." user-mail-address)` \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/after b/.emacs.d/mysnippets/text-mode/erlang-mode/after deleted file mode 100644 index 264e201..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/after +++ /dev/null @@ -1,4 +0,0 @@ -#name : after ... -> -# -- -after - $1 -> $0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/begin b/.emacs.d/mysnippets/text-mode/erlang-mode/begin deleted file mode 100644 index 7b48494..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/begin +++ /dev/null @@ -1,5 +0,0 @@ -#name : begin ... end -# -- -begin - $0 -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/beh b/.emacs.d/mysnippets/text-mode/erlang-mode/beh deleted file mode 100644 index 4975b26..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/beh +++ /dev/null @@ -1,4 +0,0 @@ -#name : -behaviour(...). -# -- --behaviour(${1:gen_server}). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/case b/.emacs.d/mysnippets/text-mode/erlang-mode/case deleted file mode 100644 index 5bed114..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/case +++ /dev/null @@ -1,5 +0,0 @@ -#name : case ... of ... end -# -- -case $1 of - $0 -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/compile b/.emacs.d/mysnippets/text-mode/erlang-mode/compile deleted file mode 100644 index ae3a4d8..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/compile +++ /dev/null @@ -1,4 +0,0 @@ -#name : -compile(...). -# -- --compile([${1:export_all}]). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/def b/.emacs.d/mysnippets/text-mode/erlang-mode/def deleted file mode 100644 index 6fb92f1..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/def +++ /dev/null @@ -1,4 +0,0 @@ -#name : -define(...,...). -# -- --define($1,$2). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/exp b/.emacs.d/mysnippets/text-mode/erlang-mode/exp deleted file mode 100644 index 67f56da..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/exp +++ /dev/null @@ -1,5 +0,0 @@ -#name : -export([]). -#contributor : hitesh -# -- --export([${1:start/0}]). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/fun b/.emacs.d/mysnippets/text-mode/erlang-mode/fun deleted file mode 100644 index 77f8293..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/fun +++ /dev/null @@ -1,3 +0,0 @@ -#name : fun (...) -> ... end -# -- -fun ($1) -> $0 end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/if b/.emacs.d/mysnippets/text-mode/erlang-mode/if deleted file mode 100644 index 45674c4..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/if +++ /dev/null @@ -1,6 +0,0 @@ -#name : if ... -> ... ; true -> ... end -# -- -if - $1 -> $2; - true -> $0 -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/ifdef b/.emacs.d/mysnippets/text-mode/erlang-mode/ifdef deleted file mode 100644 index ea89ecf..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/ifdef +++ /dev/null @@ -1,5 +0,0 @@ -#name : -ifdef(...). ... -endif. -# -- --ifdef($1). -$0 --endif. diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/ifndef b/.emacs.d/mysnippets/text-mode/erlang-mode/ifndef deleted file mode 100644 index dcd67a7..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/ifndef +++ /dev/null @@ -1,5 +0,0 @@ -#name : -ifndef(...). ... -endif. -# -- --ifndef($1). -$0 --endif. diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/imp b/.emacs.d/mysnippets/text-mode/erlang-mode/imp deleted file mode 100644 index c035ddd..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/imp +++ /dev/null @@ -1,5 +0,0 @@ -#name : -import([]). -#contributor : hitesh -# -- --import(${1:lists}, [${2:map/2, sum/1}]). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/inc b/.emacs.d/mysnippets/text-mode/erlang-mode/inc deleted file mode 100644 index f7b2161..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/inc +++ /dev/null @@ -1,4 +0,0 @@ -#name : -include("..."). -# -- --include("$1"). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/inc.lib b/.emacs.d/mysnippets/text-mode/erlang-mode/inc.lib deleted file mode 100644 index 09a6723..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/inc.lib +++ /dev/null @@ -1,4 +0,0 @@ -#name : -include_lib("..."). -# -- --include_lib("$1"). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/loop b/.emacs.d/mysnippets/text-mode/erlang-mode/loop deleted file mode 100644 index 0205802..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/loop +++ /dev/null @@ -1,8 +0,0 @@ -#name : loop(...) -> receive _ -> loop(...) end. -# -- -${1:loop}($2) -> - receive - ${3:_} -> - $1($2) - end. -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/mod b/.emacs.d/mysnippets/text-mode/erlang-mode/mod deleted file mode 100644 index 7275d39..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/mod +++ /dev/null @@ -1,6 +0,0 @@ -#name : -module(). -#contributor : hitesh -# -- --module(${1:`(file-name-nondirectory - (file-name-sans-extension (or (buffer-file-name) (buffer-name))))`}). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/rcv b/.emacs.d/mysnippets/text-mode/erlang-mode/rcv deleted file mode 100644 index 804fb3f..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/rcv +++ /dev/null @@ -1,5 +0,0 @@ -#name : receive ... -> ... end -# -- -receive - $1 -> $0 -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/rcv.after b/.emacs.d/mysnippets/text-mode/erlang-mode/rcv.after deleted file mode 100644 index 51046df..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/rcv.after +++ /dev/null @@ -1,6 +0,0 @@ -#name : receive after ... -> ... end -# -- -receive -after - $1 -> $0 -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/rec b/.emacs.d/mysnippets/text-mode/erlang-mode/rec deleted file mode 100644 index 0d67834..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/rec +++ /dev/null @@ -1,4 +0,0 @@ -#name : -record(...,{...}). -# -- --record($1,{$2}). -$0 diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/try b/.emacs.d/mysnippets/text-mode/erlang-mode/try deleted file mode 100644 index fa5c9c2..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/try +++ /dev/null @@ -1,7 +0,0 @@ -#name : try ... of ... catch after end -# -- -try $1 of - $0 -catch -after -end diff --git a/.emacs.d/mysnippets/text-mode/erlang-mode/undef b/.emacs.d/mysnippets/text-mode/erlang-mode/undef deleted file mode 100644 index 7ab5dd4..0000000 --- a/.emacs.d/mysnippets/text-mode/erlang-mode/undef +++ /dev/null @@ -1,4 +0,0 @@ -#name : -undef(...). -# -- --undef($1). -$0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/au b/.emacs.d/mysnippets/text-mode/f90-mode/au deleted file mode 100644 index 1f0af73..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/au +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : automatic -# -- -automatic $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/bd b/.emacs.d/mysnippets/text-mode/f90-mode/bd deleted file mode 100644 index 8840102..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/bd +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : block data -# -- -block data $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/c b/.emacs.d/mysnippets/text-mode/f90-mode/c deleted file mode 100644 index c7182e4..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/c +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : continue -# -- -continue $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ch b/.emacs.d/mysnippets/text-mode/f90-mode/ch deleted file mode 100644 index 7e6b4cb..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ch +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : character -# -- -character $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/cx b/.emacs.d/mysnippets/text-mode/f90-mode/cx deleted file mode 100644 index 8feb41e..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/cx +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : complex -# -- -complex $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/dc b/.emacs.d/mysnippets/text-mode/f90-mode/dc deleted file mode 100644 index 1992b1b..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/dc +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : double complex -# -- -double complex $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/do b/.emacs.d/mysnippets/text-mode/f90-mode/do deleted file mode 100644 index 2c117fd..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/do +++ /dev/null @@ -1,6 +0,0 @@ -#contributor: Li Zhu -#name : do while (...) end do -# -- -do while (${1:condition}) - $0 -end do diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/dp b/.emacs.d/mysnippets/text-mode/f90-mode/dp deleted file mode 100644 index ad014b7..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/dp +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : double precision -# -- -double precision $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/eq b/.emacs.d/mysnippets/text-mode/f90-mode/eq deleted file mode 100644 index 0c6d09f..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/eq +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : equivalence -# -- -equivalence $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ib b/.emacs.d/mysnippets/text-mode/f90-mode/ib deleted file mode 100644 index 9275a12..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ib +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit byte -# -- -implicit byte $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ic b/.emacs.d/mysnippets/text-mode/f90-mode/ic deleted file mode 100644 index 79842ea..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ic +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit complex -# -- -implicit complex $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ich b/.emacs.d/mysnippets/text-mode/f90-mode/ich deleted file mode 100644 index 53c7f81..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ich +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit character -# -- -implicit character $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/if b/.emacs.d/mysnippets/text-mode/f90-mode/if deleted file mode 100644 index b4fb526..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/if +++ /dev/null @@ -1,6 +0,0 @@ -#contributor: Li Zhu -#name : if then end if -# -- -if ( ${1:condition} ) then - $0 -end if diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ii b/.emacs.d/mysnippets/text-mode/f90-mode/ii deleted file mode 100644 index 4b1fee5..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ii +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit integer -# -- -implicit integer $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/il b/.emacs.d/mysnippets/text-mode/f90-mode/il deleted file mode 100644 index 8658af5..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/il +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit logical -# -- -implicit logical $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/in b/.emacs.d/mysnippets/text-mode/f90-mode/in deleted file mode 100644 index 0c1d5e1..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/in +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit none -# -- -implicit none diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/inc b/.emacs.d/mysnippets/text-mode/f90-mode/inc deleted file mode 100644 index dd649c4..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/inc +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : include -# -- -include $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/intr b/.emacs.d/mysnippets/text-mode/f90-mode/intr deleted file mode 100644 index 147fffd..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/intr +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : intrinsic -# -- -intrinsic $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/ir b/.emacs.d/mysnippets/text-mode/f90-mode/ir deleted file mode 100644 index fb37082..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/ir +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : implicit real -# -- -implicit real $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/l b/.emacs.d/mysnippets/text-mode/f90-mode/l deleted file mode 100644 index 8605d69..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/l +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : logical -# -- -logical $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/pa b/.emacs.d/mysnippets/text-mode/f90-mode/pa deleted file mode 100644 index 1b1b503..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/pa +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : parameter -# -- -parameter $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/pr b/.emacs.d/mysnippets/text-mode/f90-mode/pr deleted file mode 100644 index e0f8baa..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/pr +++ /dev/null @@ -1,6 +0,0 @@ -#contributor: Li Zhu -#name : program ... end program ... -# -- -program ${1:name} - $0 -end program ${1:name} diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/re b/.emacs.d/mysnippets/text-mode/f90-mode/re deleted file mode 100644 index 08c7ba0..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/re +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : read (*,*) -# -- -read (${1:*},${2:*}) $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/st b/.emacs.d/mysnippets/text-mode/f90-mode/st deleted file mode 100644 index 23ae7d0..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/st +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : structure -# -- -structure $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/su b/.emacs.d/mysnippets/text-mode/f90-mode/su deleted file mode 100644 index d3857b8..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/su +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : subroutine -# -- -subroutine $0 diff --git a/.emacs.d/mysnippets/text-mode/f90-mode/wr b/.emacs.d/mysnippets/text-mode/f90-mode/wr deleted file mode 100644 index 1ac3eb9..0000000 --- a/.emacs.d/mysnippets/text-mode/f90-mode/wr +++ /dev/null @@ -1,4 +0,0 @@ -#contributor: Li Zhu -#name : write (*,*) -# -- -write (${1:*},${2:*}) $0 diff --git a/.emacs.d/mysnippets/text-mode/html-mode/body b/.emacs.d/mysnippets/text-mode/html-mode/body deleted file mode 100644 index c924f8c..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/body +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/br b/.emacs.d/mysnippets/text-mode/html-mode/br deleted file mode 100644 index 3492098..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/br +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name :
-# -- -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/code b/.emacs.d/mysnippets/text-mode/html-mode/code deleted file mode 100644 index 6f558ec..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/code +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/code.class b/.emacs.d/mysnippets/text-mode/html-mode/code.class deleted file mode 100644 index b910eb7..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/code.class +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/dd b/.emacs.d/mysnippets/text-mode/html-mode/dd deleted file mode 100644 index 8120b13..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/dd +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Rodrigo Setti -#name :
...
-#group : list -# -- -
$1
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/div b/.emacs.d/mysnippets/text-mode/html-mode/div deleted file mode 100644 index 1c9c0c8..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/div +++ /dev/null @@ -1,3 +0,0 @@ -#name : ... -# -- -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/div.class b/.emacs.d/mysnippets/text-mode/html-mode/div.class deleted file mode 100644 index 11c12d6..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/div.class +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
...
-# -- -
- $0 -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/div.id b/.emacs.d/mysnippets/text-mode/html-mode/div.id deleted file mode 100644 index ccde64d..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/div.id +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
...
-# -- -
- $0 -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/div.id-class b/.emacs.d/mysnippets/text-mode/html-mode/div.id-class deleted file mode 100644 index bce8920..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/div.id-class +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
...
-# -- -
- $0 -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/dl b/.emacs.d/mysnippets/text-mode/html-mode/dl deleted file mode 100644 index be11bb5..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/dl +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Rodrigo Setti -#name :
...
-#group : list -# -- -
- $0 -
diff --git a/.emacs.d/mysnippets/text-mode/html-mode/dl.id b/.emacs.d/mysnippets/text-mode/html-mode/dl.id deleted file mode 100644 index 16aba53..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/dl.id +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Rodrigo Setti -#name :
...
-#group : list -# -- -
- $0 -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/doctype b/.emacs.d/mysnippets/text-mode/html-mode/doctype deleted file mode 100644 index a60dfb6..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/doctype +++ /dev/null @@ -1,4 +0,0 @@ -#name : Doctype HTML 4.01 Strict -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhml1 b/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhml1 deleted file mode 100644 index 5d95e07..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhml1 +++ /dev/null @@ -1,4 +0,0 @@ -#name : DocType XHTML 1.0 frameset -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_1 b/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_1 deleted file mode 100644 index fec46d7..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_1 +++ /dev/null @@ -1,4 +0,0 @@ -#name : DocType XHTML 1.1 -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_strict b/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_strict deleted file mode 100644 index 20d95d3..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_strict +++ /dev/null @@ -1,4 +0,0 @@ -#name : DocType XHTML 1.0 Strict -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_transitional b/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_transitional deleted file mode 100644 index c5255fc..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/doctype.xhtml1_transitional +++ /dev/null @@ -1,4 +0,0 @@ -#name : DocType XHTML 1.0 Transitional -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/dov b/.emacs.d/mysnippets/text-mode/html-mode/dov deleted file mode 100644 index e8341ea..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/dov +++ /dev/null @@ -1,11 +0,0 @@ -#name : ... -# -- -a mirror up here $3 - - - - $0 - - - actually some other shit and $3 - diff --git a/.emacs.d/mysnippets/text-mode/html-mode/dt b/.emacs.d/mysnippets/text-mode/html-mode/dt deleted file mode 100644 index f385cec..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/dt +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Rodrigo Setti -#name :
...
-#group : list -# -- -
$1
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/form b/.emacs.d/mysnippets/text-mode/html-mode/form deleted file mode 100644 index f1c066d..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/form +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
-# -- -
- $0 -
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h1 b/.emacs.d/mysnippets/text-mode/html-mode/h1 deleted file mode 100644 index 414e457..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h1 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :

...

-#group : header -# -- -

$1

\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h2 b/.emacs.d/mysnippets/text-mode/html-mode/h2 deleted file mode 100644 index 3722a29..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h2 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :

...

-#group : header -# -- -

$1

\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h3 b/.emacs.d/mysnippets/text-mode/html-mode/h3 deleted file mode 100644 index a1eaab1..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h3 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :

...

-#group : header -# -- -

$1

\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h4 b/.emacs.d/mysnippets/text-mode/html-mode/h4 deleted file mode 100644 index df71628..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h4 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :

...

-#group : header -# -- -

$1

\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h5 b/.emacs.d/mysnippets/text-mode/html-mode/h5 deleted file mode 100644 index 0109822..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h5 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :
...
-#group : header -# -- -
$1
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/h6 b/.emacs.d/mysnippets/text-mode/html-mode/h6 deleted file mode 100644 index 21c718f..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/h6 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :
...
-#group : header -# -- -
$1
\ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/head b/.emacs.d/mysnippets/text-mode/html-mode/head deleted file mode 100644 index d639a73..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/head +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/hr b/.emacs.d/mysnippets/text-mode/html-mode/hr deleted file mode 100644 index c2c330c..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/hr +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name :
-# -- -
diff --git a/.emacs.d/mysnippets/text-mode/html-mode/href b/.emacs.d/mysnippets/text-mode/html-mode/href deleted file mode 100644 index 121d589..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/href +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/html b/.emacs.d/mysnippets/text-mode/html-mode/html deleted file mode 100644 index 958aa6d..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/html +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - diff --git a/.emacs.d/mysnippets/text-mode/html-mode/html.xmlns b/.emacs.d/mysnippets/text-mode/html-mode/html.xmlns deleted file mode 100644 index 7dd7ee4..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/html.xmlns +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- - - $0 - diff --git a/.emacs.d/mysnippets/text-mode/html-mode/img b/.emacs.d/mysnippets/text-mode/html-mode/img deleted file mode 100644 index 897f605..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/img +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$3 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/input b/.emacs.d/mysnippets/text-mode/html-mode/input deleted file mode 100644 index c79ba87..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/input +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/li b/.emacs.d/mysnippets/text-mode/html-mode/li deleted file mode 100644 index c5139fa..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/li +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :
  • ...
  • -#group : list -# -- -
  • $1
  • \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/li.class b/.emacs.d/mysnippets/text-mode/html-mode/li.class deleted file mode 100644 index 90f0c65..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/li.class +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name :
  • ...
  • -#group : list -# -- -
  • $2
  • \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet b/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet deleted file mode 100644 index 6c9de74..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet-ie b/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet-ie deleted file mode 100644 index 4f6a776..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/link.stylesheet-ie +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/mailto b/.emacs.d/mysnippets/text-mode/html-mode/mailto deleted file mode 100644 index 419f2a5..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/mailto +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/meta b/.emacs.d/mysnippets/text-mode/html-mode/meta deleted file mode 100644 index 30319ef..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/meta +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#group : meta -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/meta.http-equiv b/.emacs.d/mysnippets/text-mode/html-mode/meta.http-equiv deleted file mode 100644 index c059a44..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/meta.http-equiv +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name : -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ol b/.emacs.d/mysnippets/text-mode/html-mode/ol deleted file mode 100644 index 58899fa..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ol +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ol.class b/.emacs.d/mysnippets/text-mode/html-mode/ol.class deleted file mode 100644 index b091f08..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ol.class +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ol.id b/.emacs.d/mysnippets/text-mode/html-mode/ol.id deleted file mode 100644 index 13c7c06..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ol.id +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/p b/.emacs.d/mysnippets/text-mode/html-mode/p deleted file mode 100644 index 649d9a2..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/p +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name :

    ...

    -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/pre b/.emacs.d/mysnippets/text-mode/html-mode/pre deleted file mode 100644 index bfebb3c..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/pre +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
    ...
    -# -- -
    -  $0
    -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/quote b/.emacs.d/mysnippets/text-mode/html-mode/quote deleted file mode 100644 index 65ded74..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/quote +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name :
    ...
    -# -- -
    - $1 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/script.javascript b/.emacs.d/mysnippets/text-mode/html-mode/script.javascript deleted file mode 100644 index bf0c3b5..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/script.javascript +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/script.javascript-src b/.emacs.d/mysnippets/text-mode/html-mode/script.javascript-src deleted file mode 100644 index b64c4dc..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/script.javascript-src +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/span b/.emacs.d/mysnippets/text-mode/html-mode/span deleted file mode 100644 index 149758d..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/span +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$1 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/span.class b/.emacs.d/mysnippets/text-mode/html-mode/span.class deleted file mode 100644 index 2d5ee55..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/span.class +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/span.id b/.emacs.d/mysnippets/text-mode/html-mode/span.id deleted file mode 100644 index 30a81bc..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/span.id +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/style b/.emacs.d/mysnippets/text-mode/html-mode/style deleted file mode 100644 index 300bead..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/style +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/table b/.emacs.d/mysnippets/text-mode/html-mode/table deleted file mode 100644 index 561614f..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/table +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name : ...
    -#group : table -# -- - - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/td b/.emacs.d/mysnippets/text-mode/html-mode/td deleted file mode 100644 index 4f494eb..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/td +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -#group : table -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/textarea b/.emacs.d/mysnippets/text-mode/html-mode/textarea deleted file mode 100644 index 058498f..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/textarea +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/th b/.emacs.d/mysnippets/text-mode/html-mode/th deleted file mode 100644 index 3b5fab1..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/th +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -#group : table -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/title b/.emacs.d/mysnippets/text-mode/html-mode/title deleted file mode 100644 index 21794cd..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/title +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -# -- -$1 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/tr b/.emacs.d/mysnippets/text-mode/html-mode/tr deleted file mode 100644 index 3878a1c..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/tr +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name : ... -#group : table -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ul b/.emacs.d/mysnippets/text-mode/html-mode/ul deleted file mode 100644 index 981e6e7..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ul +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ul.class b/.emacs.d/mysnippets/text-mode/html-mode/ul.class deleted file mode 100644 index c1e3e91..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ul.class +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/html-mode/ul.id b/.emacs.d/mysnippets/text-mode/html-mode/ul.id deleted file mode 100644 index ababf37..0000000 --- a/.emacs.d/mysnippets/text-mode/html-mode/ul.id +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Jimmy Wu -#name :
      ...
    -#group : list -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/latex-mode/begin b/.emacs.d/mysnippets/text-mode/latex-mode/begin deleted file mode 100644 index dc42d2f..0000000 --- a/.emacs.d/mysnippets/text-mode/latex-mode/begin +++ /dev/null @@ -1,7 +0,0 @@ -#contributor : Rodrigo Setti -#name : \begin{environment} ... \end{environment} -# -- - -\begin{${1:environment}} -$0 -\end{$1} diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/+ b/.emacs.d/mysnippets/text-mode/markdown-mode/+ deleted file mode 100644 index 0407169..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/+ +++ /dev/null @@ -1,5 +0,0 @@ -#name : Unordered List -#contributor: Peng Deng -# -- -+ ${1:Text} -+$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/- b/.emacs.d/mysnippets/text-mode/markdown-mode/- deleted file mode 100644 index 9d5c51d..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/- +++ /dev/null @@ -1,5 +0,0 @@ -#name : Unordered List -#contributor: Peng Deng -# -- -- ${1:Text} --$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/_ b/.emacs.d/mysnippets/text-mode/markdown-mode/_ deleted file mode 100644 index 50ab476..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/_ +++ /dev/null @@ -1,4 +0,0 @@ -#name : Emphasis -#contributor: Peng Deng -# -- -_${1:Text}_ $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/__ b/.emacs.d/mysnippets/text-mode/markdown-mode/__ deleted file mode 100644 index b6304f3..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/__ +++ /dev/null @@ -1,4 +0,0 @@ -#name : Strong -#contributor: Peng Deng -# -- -**${1:Text}** $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/` b/.emacs.d/mysnippets/text-mode/markdown-mode/` deleted file mode 100644 index ae58211..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/` +++ /dev/null @@ -1,4 +0,0 @@ -#name : Inline Code -#contributor: Peng Deng -# -- -\`${1:Code}\` $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h1.1 b/.emacs.d/mysnippets/text-mode/markdown-mode/h1.1 deleted file mode 100644 index 8bb7ea2..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h1.1 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 1 (#) -#contributor: Peng Deng -# -- -# ${1:Header 1} # - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h1.2 b/.emacs.d/mysnippets/text-mode/markdown-mode/h1.2 deleted file mode 100644 index d2e7b5b..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h1.2 +++ /dev/null @@ -1,7 +0,0 @@ -#name : Header 1 (=) -#contributor: Peng Deng -# -- -${1:Header 1} -${1:$(make-string (string-width text) ?\=)} - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h2.1 b/.emacs.d/mysnippets/text-mode/markdown-mode/h2.1 deleted file mode 100644 index bfee3fc..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h2.1 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 2 (##) -#contributor: Peng Deng -# -- -## ${1:Header 1} ## - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h2.2 b/.emacs.d/mysnippets/text-mode/markdown-mode/h2.2 deleted file mode 100644 index af06045..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h2.2 +++ /dev/null @@ -1,7 +0,0 @@ -#name : Header 2 (-) -#contributor: Peng Deng -# -- -${1:Header 2} -${1:$(make-string (string-width text) ?\-)} - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h3 b/.emacs.d/mysnippets/text-mode/markdown-mode/h3 deleted file mode 100644 index 44a6104..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h3 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 3 -#contributor: Peng Deng -# -- -### ${1:Header 3} ### - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h4 b/.emacs.d/mysnippets/text-mode/markdown-mode/h4 deleted file mode 100644 index 315140a..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h4 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 4 -#contributor: Peng Deng -# -- -#### ${1:Header 4} #### - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h5 b/.emacs.d/mysnippets/text-mode/markdown-mode/h5 deleted file mode 100644 index f50a785..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h5 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 5 -#contributor: Peng Deng -# -- -##### ${1:Header 5} ##### - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/h6 b/.emacs.d/mysnippets/text-mode/markdown-mode/h6 deleted file mode 100644 index 1cdfebb..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/h6 +++ /dev/null @@ -1,6 +0,0 @@ -#name : Header 6 -#contributor: Peng Deng -# -- -###### ${1:Header 6} ###### - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/hr.1 b/.emacs.d/mysnippets/text-mode/markdown-mode/hr.1 deleted file mode 100644 index 5fbe4f4..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/hr.1 +++ /dev/null @@ -1,7 +0,0 @@ -#name : Horizontal Rule (-) -#contributor: Peng Deng -# -- - ----------- - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/hr.2 b/.emacs.d/mysnippets/text-mode/markdown-mode/hr.2 deleted file mode 100644 index 2d4de22..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/hr.2 +++ /dev/null @@ -1,7 +0,0 @@ -#name : Horizontal Rule (*) -#contributor: Peng Deng -# -- - -******* - -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/img b/.emacs.d/mysnippets/text-mode/markdown-mode/img deleted file mode 100644 index 69ee77d..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/img +++ /dev/null @@ -1,4 +0,0 @@ -#name : Image -#contributor: Peng Deng -# -- -![${1:Alt Text}](${2:URL} $3) $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/link b/.emacs.d/mysnippets/text-mode/markdown-mode/link deleted file mode 100644 index dd7f99b..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/link +++ /dev/null @@ -1,4 +0,0 @@ -#name : Link -#contributor: Peng Deng -# -- -[${1:Link Text}](${2:URL} $3) $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/ol b/.emacs.d/mysnippets/text-mode/markdown-mode/ol deleted file mode 100644 index e715669..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/ol +++ /dev/null @@ -1,5 +0,0 @@ -#name : Ordered List -#contributor: Peng Deng -# -- -${1:1}. ${2:Text} -${1:$(number-to-string (1+ (string-to-number text)))}. $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/rimg b/.emacs.d/mysnippets/text-mode/markdown-mode/rimg deleted file mode 100644 index caafb60..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/rimg +++ /dev/null @@ -1,4 +0,0 @@ -#name : Referenced Image -#contributor: Peng Deng -# -- -![${1:Alt Text}][$2] $0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/rlb b/.emacs.d/mysnippets/text-mode/markdown-mode/rlb deleted file mode 100644 index 681d9f0..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/rlb +++ /dev/null @@ -1,5 +0,0 @@ -#name : Reference Label -#contributor: Peng Deng -# -- -[${1:Reference}]: ${2:URL} $3 -$0 diff --git a/.emacs.d/mysnippets/text-mode/markdown-mode/rlink b/.emacs.d/mysnippets/text-mode/markdown-mode/rlink deleted file mode 100644 index e35a0c0..0000000 --- a/.emacs.d/mysnippets/text-mode/markdown-mode/rlink +++ /dev/null @@ -1,4 +0,0 @@ -#name : Reference Link -#contributor: Peng Deng -# -- -[${1:Link Text}][$2] $0 diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/body b/.emacs.d/mysnippets/text-mode/nxml-mode/body deleted file mode 100644 index ddcf0cf..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/body +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/br b/.emacs.d/mysnippets/text-mode/nxml-mode/br deleted file mode 100644 index ba35773..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/br +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    -# -- -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/code b/.emacs.d/mysnippets/text-mode/nxml-mode/code deleted file mode 100644 index b7c43fd..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/code +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/div b/.emacs.d/mysnippets/text-mode/nxml-mode/div deleted file mode 100644 index 90fbc2e..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/div +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype b/.emacs.d/mysnippets/text-mode/nxml-mode/doctype deleted file mode 100644 index 3fdcf17..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : DocType XHTML 1.1 -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_strict b/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_strict deleted file mode 100644 index eca5860..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_strict +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : DocType XHTML 1.0 Strict -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_transitional b/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_transitional deleted file mode 100644 index fba232a..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/doctype.xhtml1_transitional +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : DocType XHTML 1.0 Transitional -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/form b/.emacs.d/mysnippets/text-mode/nxml-mode/form deleted file mode 100644 index 252253e..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/form +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    -# -- -
    - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h1 b/.emacs.d/mysnippets/text-mode/nxml-mode/h1 deleted file mode 100644 index bc72fd6..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h1 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :

    ...

    -#group : header -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h2 b/.emacs.d/mysnippets/text-mode/nxml-mode/h2 deleted file mode 100644 index b790e56..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h2 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :

    ...

    -#group : header -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h3 b/.emacs.d/mysnippets/text-mode/nxml-mode/h3 deleted file mode 100644 index 7dfd9d7..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h3 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :

    ...

    -#group : header -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h4 b/.emacs.d/mysnippets/text-mode/nxml-mode/h4 deleted file mode 100644 index b782998..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h4 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :

    ...

    -#group : header -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h5 b/.emacs.d/mysnippets/text-mode/nxml-mode/h5 deleted file mode 100644 index 13a51a1..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h5 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    ...
    -#group : header -# -- -
    $1
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/h6 b/.emacs.d/mysnippets/text-mode/nxml-mode/h6 deleted file mode 100644 index b2f0c55..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/h6 +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    ...
    -#group : header -# -- -
    $1
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/head b/.emacs.d/mysnippets/text-mode/nxml-mode/head deleted file mode 100644 index 91347b9..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/head +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/hr b/.emacs.d/mysnippets/text-mode/nxml-mode/hr deleted file mode 100644 index a17e1db..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/hr +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    -# -- -
    diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/href b/.emacs.d/mysnippets/text-mode/nxml-mode/href deleted file mode 100644 index 0db2fae..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/href +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/html b/.emacs.d/mysnippets/text-mode/nxml-mode/html deleted file mode 100644 index 85e09f7..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/html +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- - - $0 - diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/img b/.emacs.d/mysnippets/text-mode/nxml-mode/img deleted file mode 100644 index 1f4382b..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/img +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/input b/.emacs.d/mysnippets/text-mode/nxml-mode/input deleted file mode 100644 index 80c3503..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/input +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/li b/.emacs.d/mysnippets/text-mode/nxml-mode/li deleted file mode 100644 index c952682..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/li +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
  • ...
  • -# -- -
  • $1
  • \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/link b/.emacs.d/mysnippets/text-mode/nxml-mode/link deleted file mode 100644 index d93b7a5..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/link +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/meta b/.emacs.d/mysnippets/text-mode/nxml-mode/meta deleted file mode 100644 index dfee1f2..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/meta +++ /dev/null @@ -1,5 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : -#group : meta -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/name b/.emacs.d/mysnippets/text-mode/nxml-mode/name deleted file mode 100644 index 592d0da..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/name +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/ol b/.emacs.d/mysnippets/text-mode/nxml-mode/ol deleted file mode 100644 index 16cfe8d..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/ol +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
      ...
    -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/p b/.emacs.d/mysnippets/text-mode/nxml-mode/p deleted file mode 100644 index 6845ba5..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/p +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :

    ...

    -# -- -

    $1

    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/pre b/.emacs.d/mysnippets/text-mode/nxml-mode/pre deleted file mode 100644 index d70b722..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/pre +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    ...
    -# -- -
    -  $0
    -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/quote b/.emacs.d/mysnippets/text-mode/nxml-mode/quote deleted file mode 100644 index 20fed1e..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/quote +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
    ...
    -# -- -
    - $1 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/span b/.emacs.d/mysnippets/text-mode/nxml-mode/span deleted file mode 100644 index a0bba2a..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/span +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$1 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/style b/.emacs.d/mysnippets/text-mode/nxml-mode/style deleted file mode 100644 index b80be1c..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/style +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : -# -- - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/table b/.emacs.d/mysnippets/text-mode/nxml-mode/table deleted file mode 100644 index 03fd119..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/table +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ...
    -# -- - - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/tag.1l b/.emacs.d/mysnippets/text-mode/nxml-mode/tag.1l deleted file mode 100644 index 8988635..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/tag.1l +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -<${1:tag}>$2$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/tag.2l b/.emacs.d/mysnippets/text-mode/nxml-mode/tag.2l deleted file mode 100644 index 08b4a26..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/tag.2l +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : \n...\n -# -- -<${1:tag}> - $2 -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/td b/.emacs.d/mysnippets/text-mode/nxml-mode/td deleted file mode 100644 index f4615a7..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/td +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/th b/.emacs.d/mysnippets/text-mode/nxml-mode/th deleted file mode 100644 index d988b20..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/th +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$2 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/title b/.emacs.d/mysnippets/text-mode/nxml-mode/title deleted file mode 100644 index 7cd238a..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/title +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- -$1 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/tr b/.emacs.d/mysnippets/text-mode/nxml-mode/tr deleted file mode 100644 index c72daf2..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/tr +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name : ... -# -- - - $0 - \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/nxml-mode/ul b/.emacs.d/mysnippets/text-mode/nxml-mode/ul deleted file mode 100644 index dac5a66..0000000 --- a/.emacs.d/mysnippets/text-mode/nxml-mode/ul +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen -#name :
      ...
    -# -- -
      - $0 -
    \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/eval b/.emacs.d/mysnippets/text-mode/perl-mode/eval deleted file mode 100644 index c1f1e1b..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/eval +++ /dev/null @@ -1,8 +0,0 @@ -#name : eval { ... } if ($@) { ... } -# -- -eval { - ${1:# do something risky...} -}; -if (\$@) { - ${2:# handle failure...} -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/for b/.emacs.d/mysnippets/text-mode/perl-mode/for deleted file mode 100644 index ec5532f..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/for +++ /dev/null @@ -1,5 +0,0 @@ -#name : for (...) { ... } -# -- -for (my \$${1:var} = 0; \$$1 < ${2:expression}; \$$1++) { - ${3:# body...} -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/fore b/.emacs.d/mysnippets/text-mode/perl-mode/fore deleted file mode 100644 index c878a0e..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/fore +++ /dev/null @@ -1,5 +0,0 @@ -#name : foreach ... { ... } -# -- -foreach my \$${1:x} (@${2:array}) { - ${3:# body...} -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/if b/.emacs.d/mysnippets/text-mode/perl-mode/if deleted file mode 100644 index 3191b97..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/if +++ /dev/null @@ -1,5 +0,0 @@ -#name : if (...) { ... } -# -- -if ($1) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/ife b/.emacs.d/mysnippets/text-mode/perl-mode/ife deleted file mode 100644 index 23f7cf6..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/ife +++ /dev/null @@ -1,7 +0,0 @@ -#name : if (...) { ... } else { ... } -# -- -if ($1) { - $2 -} else { - $3 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/ifee b/.emacs.d/mysnippets/text-mode/perl-mode/ifee deleted file mode 100644 index 7c187d1..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/ifee +++ /dev/null @@ -1,9 +0,0 @@ -#name : if, elsif, else ... -# -- -if ($1) { - ${2:# body...} -} elsif ($3) { - ${4:# elsif...} -} else { - ${5:# else...} -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/sub b/.emacs.d/mysnippets/text-mode/perl-mode/sub deleted file mode 100644 index 5ab54d7..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/sub +++ /dev/null @@ -1,5 +0,0 @@ -#name : sub ... { ... } -# -- -sub ${1:function_name} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/unless b/.emacs.d/mysnippets/text-mode/perl-mode/unless deleted file mode 100644 index baeffa2..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/unless +++ /dev/null @@ -1,5 +0,0 @@ -#name : unless (...) { ... } -# -- -unless ($1) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/while b/.emacs.d/mysnippets/text-mode/perl-mode/while deleted file mode 100644 index 9c2c470..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/while +++ /dev/null @@ -1,5 +0,0 @@ -#name : while (...) { ... } -# -- -while ($1) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/xfore b/.emacs.d/mysnippets/text-mode/perl-mode/xfore deleted file mode 100644 index 58e455d..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/xfore +++ /dev/null @@ -1,3 +0,0 @@ -#name : ... foreach ... -# -- -${1:expression} foreach @${2:array}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/xif b/.emacs.d/mysnippets/text-mode/perl-mode/xif deleted file mode 100644 index 1d4dba8..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/xif +++ /dev/null @@ -1,3 +0,0 @@ -#name : ... if ... -# -- -${1:expression} if ${2:condition} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/xunless b/.emacs.d/mysnippets/text-mode/perl-mode/xunless deleted file mode 100644 index f456db3..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/xunless +++ /dev/null @@ -1,3 +0,0 @@ -#name : ... unless ... -# -- -${1:expression} unless ${2:condition} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/perl-mode/xwhile b/.emacs.d/mysnippets/text-mode/perl-mode/xwhile deleted file mode 100644 index 2515586..0000000 --- a/.emacs.d/mysnippets/text-mode/perl-mode/xwhile +++ /dev/null @@ -1,3 +0,0 @@ -#name : ... while ... -# -- -${1:expression} while ${2:condition}; \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/php-mode/ife b/.emacs.d/mysnippets/text-mode/php-mode/ife deleted file mode 100644 index eca1f01..0000000 --- a/.emacs.d/mysnippets/text-mode/php-mode/ife +++ /dev/null @@ -1,10 +0,0 @@ -#name : php if (...) { ... } else { ... } -# -- -if (${1:condition}) -{ - $0 -} -else -{ - -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/php-mode/ppf b/.emacs.d/mysnippets/text-mode/php-mode/ppf deleted file mode 100644 index e526c42..0000000 --- a/.emacs.d/mysnippets/text-mode/php-mode/ppf +++ /dev/null @@ -1,6 +0,0 @@ -#name : php public function -# -- -public function ${1:name}() -{ - $0 -} diff --git a/.emacs.d/mysnippets/text-mode/php-mode/ppg b/.emacs.d/mysnippets/text-mode/php-mode/ppg deleted file mode 100644 index b648335..0000000 --- a/.emacs.d/mysnippets/text-mode/php-mode/ppg +++ /dev/null @@ -1,6 +0,0 @@ -#name : php public function -# -- -public function get${1:name}() -{ - return $this->$0; -} diff --git a/.emacs.d/mysnippets/text-mode/php-mode/pps b/.emacs.d/mysnippets/text-mode/php-mode/pps deleted file mode 100644 index 4eb0fad..0000000 --- a/.emacs.d/mysnippets/text-mode/php-mode/pps +++ /dev/null @@ -1,6 +0,0 @@ -#name : php public function -# -- -public function set${1:name}(${2:value}) -{ - $this->$0$2 = $2; -} diff --git a/.emacs.d/mysnippets/text-mode/python-mode/__ b/.emacs.d/mysnippets/text-mode/python-mode/__ deleted file mode 100644 index a67dc49..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/__ +++ /dev/null @@ -1,3 +0,0 @@ -#name : __...__ -# -- -__${init}__ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/python-mode/class b/.emacs.d/mysnippets/text-mode/python-mode/class deleted file mode 100644 index 72f339b..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/class +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# name: class -# contributor: Orestis Markou -# contributor: Nishio Hirokazu -# contributor: Yasser González Fernández -# -- -class ${1:ClassName}(${2:object}): - """$3 - """ - - def __init__(self, $4): - """$5 - ${4:$ - (let* ((indent - (concat "\n" (make-string (current-column) 32))) - (args - (mapconcat - '(lambda (x) - (if (not (string= (nth 0 x) "")) - (concat "- " (char-to-string 96) (nth 0 x) - (char-to-string 96) ":"))) - (mapcar - '(lambda (x) - (mapcar - (lambda (x) - (replace-regexp-in-string "[[:blank:]]*$" "" - (replace-regexp-in-string "^[[:blank:]]*" "" x))) x)) - (mapcar '(lambda (x) (split-string x "=")) - (split-string text ","))) - indent))) - (if (string= args "") - (make-string 3 34) - (mapconcat - 'identity - (list "" "Arguments:" args (make-string 3 34)) - indent))) - } - ${4:$ - (mapconcat - '(lambda (x) - (if (not (string= (nth 0 x) "")) - (concat "self._" (nth 0 x) " = " (nth 0 x)))) - (mapcar - '(lambda (x) - (mapcar - '(lambda (x) - (replace-regexp-in-string "[[:blank:]]*$" "" - (replace-regexp-in-string "^[[:blank:]]*" "" x))) - x)) - (mapcar '(lambda (x) (split-string x "=")) - (split-string text ","))) - (concat "\n" (make-string (current-column) 32))) - } - $0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/def b/.emacs.d/mysnippets/text-mode/python-mode/def deleted file mode 100644 index f82f791..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/def +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# name: def -# contributor: Orestis Markou -# contributor: Yasser González Fernández -# -- -def ${1:name}($2): - """$3 - ${2:$ - (let* - ((indent - (concat "\n" (make-string (current-column) 32))) - (args - (mapconcat - '(lambda (x) - (if (not (string= (nth 0 x) "")) - (concat "- " (char-to-string 96) (nth 0 x) - (char-to-string 96) ":"))) - (mapcar - '(lambda (x) - (mapcar - '(lambda (x) - (replace-regexp-in-string "[[:blank:]]*$" "" - (replace-regexp-in-string "^[[:blank:]]*" "" x))) - x)) - (mapcar '(lambda (x) (split-string x "=")) - (split-string text ","))) - indent))) - (if (string= args "") - (make-string 3 34) - (mapconcat - 'identity - (list "" "Arguments:" args (make-string 3 34)) - indent))) - } - $0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/defm b/.emacs.d/mysnippets/text-mode/python-mode/defm deleted file mode 100644 index dc25827..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/defm +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# name: defm -# contributor: Yasser Gonz¨¢lez Fern¨¢ndez -# -- -def ${1:name}(self, $2): - """$3 - ${2:$ - (let* ((indent - (concat "\n" (make-string (current-column) 32))) - (args - (mapconcat - '(lambda (x) - (if (not (string= (nth 0 x) "")) - (concat "- " (char-to-string 96) (nth 0 x) - (char-to-string 96) ":"))) - (mapcar - '(lambda (x) - (mapcar - '(lambda (x) - (replace-regexp-in-string "[[:blank:]]*$" "" - (replace-regexp-in-string "^[[:blank:]]*" "" x))) - x)) - (mapcar '(lambda (x) (split-string x "=")) - (split-string text ","))) - indent))) - (if (string= args "") - (make-string 3 34) - (mapconcat - 'identity - (list "" "Arguments:" args (make-string 3 34)) - indent))) - } - $0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/for b/.emacs.d/mysnippets/text-mode/python-mode/for deleted file mode 100644 index 84f3ddd..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/for +++ /dev/null @@ -1,4 +0,0 @@ -#name : for ... in ... : ... -# -- -for ${var} in ${collection}: - $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/python-mode/ifmain b/.emacs.d/mysnippets/text-mode/python-mode/ifmain deleted file mode 100644 index 6224923..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/ifmain +++ /dev/null @@ -1,4 +0,0 @@ -#name : if __name__ == '__main__': ... -# -- -if __name__ == '__main__': - $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/python-mode/mprop b/.emacs.d/mysnippets/text-mode/python-mode/mprop deleted file mode 100644 index 8a17317..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/mprop +++ /dev/null @@ -1,23 +0,0 @@ -#contributor : Simeon Simeonov -#name : @property foo ... getter & setter & deleter -#expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil)) -# -- -@property -def ${1:foo}(self): - """ - """ - return self._$1 - -@$1.setter -def $1(self, value): - """ - """ - self._$1 = value - -@$1.deleter -def $1(self): - """ - """ - pass - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/mpropg b/.emacs.d/mysnippets/text-mode/python-mode/mpropg deleted file mode 100644 index eb60b49..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/mpropg +++ /dev/null @@ -1,11 +0,0 @@ -#contributor : Simeon Simeonov -#name : @property foo ... getter -#expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil)) -# -- -@property -def ${1:foo}(self): - """ - """ - return self._$1 - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/mpropsg b/.emacs.d/mysnippets/text-mode/python-mode/mpropsg deleted file mode 100644 index 0665f5e..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/mpropsg +++ /dev/null @@ -1,17 +0,0 @@ -#contributor : Simeon Simeonov -#name : @property foo ... getter & setter -#expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil)) -# -- -@property -def ${1:foo}(self): - """ - """ - return self._$1 - -@$1.setter -def $1(self, value): - """ - """ - self._$1 = value - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/prop b/.emacs.d/mysnippets/text-mode/python-mode/prop deleted file mode 100644 index 107730a..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/prop +++ /dev/null @@ -1,15 +0,0 @@ -# contributor: Mads D. Kristensen -# name: prop -# -- -def ${1:foo}(): - doc = """${2:Doc string}""" - def fget(self): - return self._$1 - def fset(self, value): - self._$1 = value - def fdel(self): - del self._$1 - return locals() -$1 = property(**$1()) - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/propg b/.emacs.d/mysnippets/text-mode/python-mode/propg deleted file mode 100644 index 7e994b6..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/propg +++ /dev/null @@ -1,9 +0,0 @@ -#contributor : Julio Carlos Menendez -#name : _get_foo ... foo=property(...) -# -- -def _get_${1:foo}(self): - return self._$1 - -$1 = property(_get_$1) - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/propsg b/.emacs.d/mysnippets/text-mode/python-mode/propsg deleted file mode 100644 index e09d82a..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/propsg +++ /dev/null @@ -1,12 +0,0 @@ -#contributor : Julio Carlos Menendez -#name : _get_foo ... _set_foo ... foo=property(...) -# -- -def _set_${1:foo}(self, value): - self._$1 = value - -def _get_$1(self): - return self._$1 - -$1 = property(_get_$1, _set_$1) - -$0 diff --git a/.emacs.d/mysnippets/text-mode/python-mode/pscript b/.emacs.d/mysnippets/text-mode/python-mode/pscript deleted file mode 100644 index 8fdb376..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/pscript +++ /dev/null @@ -1,12 +0,0 @@ -#contributor : Simeon Simeonov -#name : script setup -#expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil)) -# -- -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -def main(): - $0 - -if __name__ == '__main__': - main() diff --git a/.emacs.d/mysnippets/text-mode/python-mode/while b/.emacs.d/mysnippets/text-mode/python-mode/while deleted file mode 100644 index 704dd7c..0000000 --- a/.emacs.d/mysnippets/text-mode/python-mode/while +++ /dev/null @@ -1,4 +0,0 @@ -#name : while ... : ... -# -- -while ${condition}: - $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/rst-mode/chap b/.emacs.d/mysnippets/text-mode/rst-mode/chap deleted file mode 100644 index 6474c00..0000000 --- a/.emacs.d/mysnippets/text-mode/rst-mode/chap +++ /dev/null @@ -1,6 +0,0 @@ -#name : Chapter title -# -- -${1:Chapter} -${1:$(make-string (string-width text) ?\=)} - -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/rst-mode/sec b/.emacs.d/mysnippets/text-mode/rst-mode/sec deleted file mode 100644 index 76087ed..0000000 --- a/.emacs.d/mysnippets/text-mode/rst-mode/sec +++ /dev/null @@ -1,6 +0,0 @@ -#name : Section title -# -- -${1:Section} -${1:$(make-string (string-width text) ?\-)} - -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/rst-mode/tit b/.emacs.d/mysnippets/text-mode/rst-mode/tit deleted file mode 100644 index cac2e77..0000000 --- a/.emacs.d/mysnippets/text-mode/rst-mode/tit +++ /dev/null @@ -1,7 +0,0 @@ -#name : Document title -# -- -${1:$(make-string (string-width text) ?\=)} -${1:Title} -${1:$(make-string (string-width text) ?\=)} - -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/# b/.emacs.d/mysnippets/text-mode/ruby-mode/# deleted file mode 100644 index 33581c8..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/# +++ /dev/null @@ -1,4 +0,0 @@ -#name : # => -#group : general -# -- -# => \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/=b b/.emacs.d/mysnippets/text-mode/ruby-mode/=b deleted file mode 100644 index 22a013f..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/=b +++ /dev/null @@ -1,6 +0,0 @@ -#name : =begin rdoc ... =end -#group : general -# -- -=begin rdoc - $0 -=end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/Comp b/.emacs.d/mysnippets/text-mode/ruby-mode/Comp deleted file mode 100644 index 03f2b35..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/Comp +++ /dev/null @@ -1,8 +0,0 @@ -#name : include Comparable; def <=> ... end -#group : definitions -# -- -include Comparable - -def <=> other - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/all b/.emacs.d/mysnippets/text-mode/ruby-mode/all deleted file mode 100644 index a98a9f4..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/all +++ /dev/null @@ -1,4 +0,0 @@ -#name : all? { |...| ... } -#group : collections -# -- -all? { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/am b/.emacs.d/mysnippets/text-mode/ruby-mode/am deleted file mode 100644 index 7675a97..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/am +++ /dev/null @@ -1,4 +0,0 @@ -#name : alias_method new, old -#group : definitions -# -- -alias_method :${new_name}, :${old_name} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/any b/.emacs.d/mysnippets/text-mode/ruby-mode/any deleted file mode 100644 index d0b6dd2..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/any +++ /dev/null @@ -1,4 +0,0 @@ -#name : any? { |...| ... } -#group : collections -# -- -any? { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/app b/.emacs.d/mysnippets/text-mode/ruby-mode/app deleted file mode 100644 index 19bf60a..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/app +++ /dev/null @@ -1,6 +0,0 @@ -#name : if __FILE__ == $PROGRAM_NAME ... end -#group : general -# -- -if __FILE__ == $PROGRAM_NAME - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/bm b/.emacs.d/mysnippets/text-mode/ruby-mode/bm deleted file mode 100644 index 4789f64..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/bm +++ /dev/null @@ -1,6 +0,0 @@ -#name : Benchmark.bmbm(...) do ... end -#group : general -# -- -Benchmark.bmbm(${1:10}) do |x| - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/case b/.emacs.d/mysnippets/text-mode/ruby-mode/case deleted file mode 100644 index 40c3529..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/case +++ /dev/null @@ -1,7 +0,0 @@ -#name : case ... end -#group : general -# -- -case ${1:object} -when ${2:condition} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/cla b/.emacs.d/mysnippets/text-mode/ruby-mode/cla deleted file mode 100644 index 81ccf45..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/cla +++ /dev/null @@ -1,6 +0,0 @@ -#name : class << self ... end -#group : definitions -# -- -class << ${self} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/classify b/.emacs.d/mysnippets/text-mode/ruby-mode/classify deleted file mode 100644 index 2378afa..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/classify +++ /dev/null @@ -1,4 +0,0 @@ -#name : classify { |...| ... } -#group : collections -# -- -classify { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/cls b/.emacs.d/mysnippets/text-mode/ruby-mode/cls deleted file mode 100644 index da28fb7..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/cls +++ /dev/null @@ -1,13 +0,0 @@ -#name : class ... end -#contributor : hitesh -#group : definitions -# -- -class ${1:`(let ((fn (capitalize (file-name-nondirectory - (file-name-sans-extension - (or (buffer-file-name) - (buffer-name (current-buffer)))))))) - (cond - ((string-match "_" fn) (replace-match "" nil nil fn)) - (t fn)))`} - $0 -end diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/collect b/.emacs.d/mysnippets/text-mode/ruby-mode/collect deleted file mode 100644 index 934014a..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/collect +++ /dev/null @@ -1,4 +0,0 @@ -#name : collect { |...| ... } -#group : collections -# -- -collect { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/dee b/.emacs.d/mysnippets/text-mode/ruby-mode/dee deleted file mode 100644 index 56d0a18..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/dee +++ /dev/null @@ -1,4 +0,0 @@ -#name : deep_copy(...) -#group : general -# -- -Marshal.load(Marshal.dump($0)) \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/deli b/.emacs.d/mysnippets/text-mode/ruby-mode/deli deleted file mode 100644 index 843b154..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/deli +++ /dev/null @@ -1,4 +0,0 @@ -#name : delete_if { |...| ... } -#group : collections -# -- -delete_if { |${e} $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/det b/.emacs.d/mysnippets/text-mode/ruby-mode/det deleted file mode 100644 index 6a17da9..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/det +++ /dev/null @@ -1,4 +0,0 @@ -#name : detect { |...| ... } -#group : collections -# -- -detect { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/dow b/.emacs.d/mysnippets/text-mode/ruby-mode/dow deleted file mode 100644 index 3b65271..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/dow +++ /dev/null @@ -1,6 +0,0 @@ -#name : downto(...) { |n| ... } -#group : control structure -# -- -downto(${0}) { |${n}| - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/ea b/.emacs.d/mysnippets/text-mode/ruby-mode/ea deleted file mode 100644 index 9cdf8dc..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/ea +++ /dev/null @@ -1,4 +0,0 @@ -#name : each { |...| ... } -#group : collections -# -- -each { |${e}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/eac b/.emacs.d/mysnippets/text-mode/ruby-mode/eac deleted file mode 100644 index f0d9cb1..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/eac +++ /dev/null @@ -1,4 +0,0 @@ -#name : each_cons(...) { |...| ... } -#group : collections -# -- -each_cons(${1:2}) { |${group}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/eai b/.emacs.d/mysnippets/text-mode/ruby-mode/eai deleted file mode 100644 index 5b0ed67..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/eai +++ /dev/null @@ -1,4 +0,0 @@ -#name : each_index { |i| ... } -#group : collections -# -- -each_index { |${i}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/eav b/.emacs.d/mysnippets/text-mode/ruby-mode/eav deleted file mode 100644 index 558e5b4..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/eav +++ /dev/null @@ -1,4 +0,0 @@ -#name : each_value { |val| ... } -#group : collections -# -- -each_value { |${val}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/eawi b/.emacs.d/mysnippets/text-mode/ruby-mode/eawi deleted file mode 100644 index edf8418..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/eawi +++ /dev/null @@ -1,4 +0,0 @@ -#name : each_with_index { |e, i| ... } -#group : collections -# -- -each_with_index { |${e}, ${i}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/forin b/.emacs.d/mysnippets/text-mode/ruby-mode/forin deleted file mode 100644 index 36b4387..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/forin +++ /dev/null @@ -1,6 +0,0 @@ -#name : for ... in ...; ... end -#group : control structure -# -- -for ${1:element} in ${2:collection} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/if b/.emacs.d/mysnippets/text-mode/ruby-mode/if deleted file mode 100644 index 077b097..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/if +++ /dev/null @@ -1,6 +0,0 @@ -#name : if ... end -#group : control structure -# -- -if ${1:condition} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/ife b/.emacs.d/mysnippets/text-mode/ruby-mode/ife deleted file mode 100644 index e57d395..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/ife +++ /dev/null @@ -1,8 +0,0 @@ -#name : if ... else ... end -#group : control structure -# -- -if ${1:condition} - $2 -else - $3 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/inject b/.emacs.d/mysnippets/text-mode/ruby-mode/inject deleted file mode 100644 index 37932e5..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/inject +++ /dev/null @@ -1,4 +0,0 @@ -#name : inject(...) { |...| ... } -#group : collections -# -- -inject(${1:0}) { |${2:injection}, ${3:element}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/mm b/.emacs.d/mysnippets/text-mode/ruby-mode/mm deleted file mode 100644 index 3f62b10..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/mm +++ /dev/null @@ -1,6 +0,0 @@ -#name : def method_missing ... end -#group : definitions -# -- -def method_missing(method, *args) - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/r b/.emacs.d/mysnippets/text-mode/ruby-mode/r deleted file mode 100644 index 2e7b797..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/r +++ /dev/null @@ -1,4 +0,0 @@ -#name : attr_reader ... -#group : definitions -# -- -attr_reader : \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/rb b/.emacs.d/mysnippets/text-mode/ruby-mode/rb deleted file mode 100644 index 74d26dd..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/rb +++ /dev/null @@ -1,4 +0,0 @@ -#name : /usr/bin/ruby -wKU -#group : general -# -- -#!/usr/bin/ruby -wKU diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/reject b/.emacs.d/mysnippets/text-mode/ruby-mode/reject deleted file mode 100644 index c2501bc..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/reject +++ /dev/null @@ -1,4 +0,0 @@ -#name : reject { |...| ... } -#group : collections -# -- -reject { |${1:element}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/req b/.emacs.d/mysnippets/text-mode/ruby-mode/req deleted file mode 100644 index 3e001ec..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/req +++ /dev/null @@ -1,4 +0,0 @@ -#name : require "..." -#group : general -# -- -require "$0" \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/rreq b/.emacs.d/mysnippets/text-mode/ruby-mode/rreq deleted file mode 100644 index 0b9c6a4..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/rreq +++ /dev/null @@ -1,4 +0,0 @@ -#name : require File.join(File.dirname(__FILE__), ...) -#group : general -# -- -require File.join(File.dirname(__FILE__), $0) \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/rw b/.emacs.d/mysnippets/text-mode/ruby-mode/rw deleted file mode 100644 index a364675..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/rw +++ /dev/null @@ -1,4 +0,0 @@ -#name : attr_accessor ... -#group : definitions -# -- -attr_accessor : \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/select b/.emacs.d/mysnippets/text-mode/ruby-mode/select deleted file mode 100644 index 78bca8f..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/select +++ /dev/null @@ -1,4 +0,0 @@ -#name : select { |...| ... } -#group : collections -# -- -select { |${1:element}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/tim b/.emacs.d/mysnippets/text-mode/ruby-mode/tim deleted file mode 100644 index 0da115f..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/tim +++ /dev/null @@ -1,4 +0,0 @@ -#name : times { |n| ... } -#group : control structure -# -- -times { |${n}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/until b/.emacs.d/mysnippets/text-mode/ruby-mode/until deleted file mode 100644 index 476966a..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/until +++ /dev/null @@ -1,6 +0,0 @@ -#name : until ... end -#group: control structure -# -- -until ${condition} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/upt b/.emacs.d/mysnippets/text-mode/ruby-mode/upt deleted file mode 100644 index 6fc6810..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/upt +++ /dev/null @@ -1,6 +0,0 @@ -#name : upto(...) { |n| ... } -#group : control structure -# -- -upto(${n}) { |${i}| - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/w b/.emacs.d/mysnippets/text-mode/ruby-mode/w deleted file mode 100644 index 9edbfcb..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/w +++ /dev/null @@ -1,4 +0,0 @@ -#name : attr_writer ... -#group : definitions -# -- -attr_writer : \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/when b/.emacs.d/mysnippets/text-mode/ruby-mode/when deleted file mode 100644 index 9b06f21..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/when +++ /dev/null @@ -1,6 +0,0 @@ -#name : when ... end -#group : control structure -# -- -when ${condition} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/while b/.emacs.d/mysnippets/text-mode/ruby-mode/while deleted file mode 100644 index 4c9ad35..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/while +++ /dev/null @@ -1,6 +0,0 @@ -#name : while ... end -#group : control structure -# -- -while ${condition} - $0 -end \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/y b/.emacs.d/mysnippets/text-mode/ruby-mode/y deleted file mode 100644 index 0ddf0f9..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/y +++ /dev/null @@ -1,4 +0,0 @@ -#name : :yields: arguments (rdoc) -#group : general -# -- -:yields: $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/ruby-mode/zip b/.emacs.d/mysnippets/text-mode/ruby-mode/zip deleted file mode 100644 index 56f4266..0000000 --- a/.emacs.d/mysnippets/text-mode/ruby-mode/zip +++ /dev/null @@ -1,4 +0,0 @@ -#name : zip(...) { |...| ... } -#group : collections -# -- -zip(${enums}) { |${row}| $0 } \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/act b/.emacs.d/mysnippets/text-mode/scala-mode/act deleted file mode 100644 index fce52fc..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/act +++ /dev/null @@ -1,10 +0,0 @@ -#Author : Jonas Bonèr -#name : def act = { ..} -# -- -def act = { - loop { - react { - $0 - } - } -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/act.arg b/.emacs.d/mysnippets/text-mode/scala-mode/act.arg deleted file mode 100644 index fc6df9e..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/act.arg +++ /dev/null @@ -1,10 +0,0 @@ -#Author : Jonas Bonèr -#name : def act(arg: T) = { ..} -# -- -def act(${1:arg}: ${2:type}) = { - loop { - react { - $0 - } - } -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/actor b/.emacs.d/mysnippets/text-mode/scala-mode/actor deleted file mode 100644 index d38a183..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/actor +++ /dev/null @@ -1,10 +0,0 @@ -#Author : Jonas Bonèr -#name : val a = actor { ..} -# -- -val a = actor { - loop { - react { - $0 - } - } -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ano b/.emacs.d/mysnippets/text-mode/scala-mode/ano deleted file mode 100644 index b949801..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ano +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : (args) => ... -# -- -($1) => ${2:body} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/app b/.emacs.d/mysnippets/text-mode/scala-mode/app deleted file mode 100644 index b89bab9..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/app +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : object name extends Application -# -- -object ${1:name} extends Application { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/arr.new b/.emacs.d/mysnippets/text-mode/scala-mode/arr.new deleted file mode 100644 index e3297ca..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/arr.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : Array[T](..) -# -- -Array[${1:value}](${2:args}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/arr.val-new b/.emacs.d/mysnippets/text-mode/scala-mode/arr.val-new deleted file mode 100644 index 4de4720..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/arr.val-new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val a = Array[T](..) -# -- -val ${1:arr} = Array[${2:value}](${3:args}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/asof b/.emacs.d/mysnippets/text-mode/scala-mode/asof deleted file mode 100644 index 3b2b209..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/asof +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : asInstanceOf[T] -# -- -asInstanceOf[${1:type}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ass b/.emacs.d/mysnippets/text-mode/scala-mode/ass deleted file mode 100644 index 653dcef..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ass +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : assert(x === y) -# -- -assert(${1:x} === ${2:y}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ass.true b/.emacs.d/mysnippets/text-mode/scala-mode/ass.true deleted file mode 100644 index 923c518..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ass.true +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : assert(true) -# -- -assert(true) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/at.author b/.emacs.d/mysnippets/text-mode/scala-mode/at.author deleted file mode 100644 index 82fe4cc..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/at.author +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Anders Bach Nielsen -#name : @author name -# -- -@author ${1:name} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/at.param b/.emacs.d/mysnippets/text-mode/scala-mode/at.param deleted file mode 100644 index 72b6e79..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/at.param +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Anders Bach Nielsen -#name : @param name description -# -- -@param ${1:name} ${2:description} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/at.return b/.emacs.d/mysnippets/text-mode/scala-mode/at.return deleted file mode 100644 index 9c3f41c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/at.return +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Anders Bach Nielsen -#name : @return description -# -- -@return ${1:description} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/at.version b/.emacs.d/mysnippets/text-mode/scala-mode/at.version deleted file mode 100644 index 1158ce2..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/at.version +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Anders Bach Nielsen -#name : @version number -# -- -@version ${1:0.1} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/bang b/.emacs.d/mysnippets/text-mode/scala-mode/bang deleted file mode 100644 index a547da8..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/bang +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : actor ! message -# -- -${1:actor} ! ${2:message} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/case b/.emacs.d/mysnippets/text-mode/scala-mode/case deleted file mode 100644 index 13d6aec..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/case +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : case pattern => -# -- -case ${1:pattern} => $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/case.match-all b/.emacs.d/mysnippets/text-mode/scala-mode/case.match-all deleted file mode 100644 index 028bf5f..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/case.match-all +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : case _ => -# -- -case _ => $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cast b/.emacs.d/mysnippets/text-mode/scala-mode/cast deleted file mode 100644 index 3b2b209..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cast +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : asInstanceOf[T] -# -- -asInstanceOf[${1:type}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cc b/.emacs.d/mysnippets/text-mode/scala-mode/cc deleted file mode 100644 index 7ed1142..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cc +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : case class T(arg: A) -# -- -case class ${1:name}(${2:arg}: ${3:type}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cl b/.emacs.d/mysnippets/text-mode/scala-mode/cl deleted file mode 100644 index 1fd712c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cl +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : class T { .. } -# -- -class ${1:name} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs b/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs deleted file mode 100644 index 402dec7..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : abstract class T { .. } -# -- -abstract class ${1:name} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs-arg b/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs-arg deleted file mode 100644 index fe29524..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cl.abs-arg +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : abstract class T(args) { .. } -# -- -abstract class ${1:name}(${2:args}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cl.arg b/.emacs.d/mysnippets/text-mode/scala-mode/cl.arg deleted file mode 100644 index f82460f..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cl.arg +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : class T(args) { .. } -# -- -class ${1:name}(${2:args}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/clof b/.emacs.d/mysnippets/text-mode/scala-mode/clof deleted file mode 100644 index 955726c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/clof +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : classOf[T] -# -- -classOf[${1:type}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/co b/.emacs.d/mysnippets/text-mode/scala-mode/co deleted file mode 100644 index 75b1f3b..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/co +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : case object T -# -- -case object ${1:name} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cons b/.emacs.d/mysnippets/text-mode/scala-mode/cons deleted file mode 100644 index a48e4ff..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cons +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : element1 :: element2 -# -- -${1:element1} :: ${2:element2} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/cons.nil b/.emacs.d/mysnippets/text-mode/scala-mode/cons.nil deleted file mode 100644 index c288f93..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/cons.nil +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : element1 :: Nil -# -- -${1:element1} :: Nil $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg b/.emacs.d/mysnippets/text-mode/scala-mode/def.arg deleted file mode 100644 index 7765bbf..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : def f(arg: T) = ... -# -- -def ${1:name}(${2:args}) = $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-body b/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-body deleted file mode 100644 index e6e278e..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-body +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : def f(arg: T) = {...} -# -- -def ${1:name}(${2:args}) = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret b/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret deleted file mode 100644 index dddb9ce..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : def f(arg: T): R = ... -# -- -def ${1:name}(${2:args}): ${3:Unit} = $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret-body b/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret-body deleted file mode 100644 index 862f7fd..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.arg-ret-body +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : def f(arg: T): R = {...} -# -- -def ${1:name}(${2:args}): ${3:Unit} = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.body b/.emacs.d/mysnippets/text-mode/scala-mode/def.body deleted file mode 100644 index 858908c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.body +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : def f = {...} -# -- -def ${1:name} = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.ret b/.emacs.d/mysnippets/text-mode/scala-mode/def.ret deleted file mode 100644 index e5483fb..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.ret +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : def f: R = ... -# -- -def ${1:name}: ${2:Unit} = $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.ret-body b/.emacs.d/mysnippets/text-mode/scala-mode/def.ret-body deleted file mode 100644 index f342e04..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.ret-body +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : def f: R = {...} -# -- -def ${1:name}: ${3:Unit} = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/def.simple b/.emacs.d/mysnippets/text-mode/scala-mode/def.simple deleted file mode 100644 index 4814c73..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/def.simple +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : def f = ... -# -- -def ${1:name} = $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.class b/.emacs.d/mysnippets/text-mode/scala-mode/doc.class deleted file mode 100644 index 60442f1..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.class +++ /dev/null @@ -1,8 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** cls/trt/obj name */ -# -- -/** - * `(scala-mode-find-clstrtobj-name-doc)` - * ${1:description} - * $0 - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.def b/.emacs.d/mysnippets/text-mode/scala-mode/doc.def deleted file mode 100644 index 8a3d614..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.def +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** method name */ -# -- -/** - * `(scala-mode-def-and-args-doc)` - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file b/.emacs.d/mysnippets/text-mode/scala-mode/doc.file deleted file mode 100644 index 7da4289..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file +++ /dev/null @@ -1,9 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** file name */ -# -- -/** - * `(scala-mode-file-doc)` - * $0 - * @author ${1:name} - * @version ${2:0.1} - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala b/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala deleted file mode 100644 index 6719348..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala +++ /dev/null @@ -1,16 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** scala file */ -# -- -/* __ *\ -** ________ ___ / / ___ Scala $3 ** -** / __/ __// _ | / / / _ | (c) 2005-`(format-time-string "%Y")` , LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ -/** - * $0 - * @author ${1:name} - * @version ${2:0.1} - * $Id$ - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala-api b/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala-api deleted file mode 100644 index 4a762f5..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.file-scala-api +++ /dev/null @@ -1,16 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** scala api file */ -# -- -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-`(format-time-string "%Y")`, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ -/** - * $0 - * @author ${1:name} - * @version ${2:0.1} - * $Id$ - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/doc.scaladoc b/.emacs.d/mysnippets/text-mode/scala-mode/doc.scaladoc deleted file mode 100644 index 038428c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/doc.scaladoc +++ /dev/null @@ -1,7 +0,0 @@ -#Author : Anders Bach Nielsen -#name : /** ... */ -# -- -/** - * ${1:description} - * $0 - */ \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/expect b/.emacs.d/mysnippets/text-mode/scala-mode/expect deleted file mode 100644 index 94c742c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/expect +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : expect(value) { ..} -# -- -expect(${1:reply}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ext b/.emacs.d/mysnippets/text-mode/scala-mode/ext deleted file mode 100644 index e256317..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ext +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : extends T -# -- -extends $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/for.extract b/.emacs.d/mysnippets/text-mode/scala-mode/for.extract deleted file mode 100644 index 60f1155..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/for.extract +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : x <- xs -# -- -${1:x} <- ${2:xs} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/for.if b/.emacs.d/mysnippets/text-mode/scala-mode/for.if deleted file mode 100644 index f44c544..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/for.if +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : for (x <- xs if guard) { ... } -# -- -for (${1:x} <- ${2:xs} if ${3:guard}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/for.loop b/.emacs.d/mysnippets/text-mode/scala-mode/for.loop deleted file mode 100644 index 050d5e8..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/for.loop +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : for (x <- xs) { ... } -# -- -for (${1:x} <- ${2:xs}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/for.multi b/.emacs.d/mysnippets/text-mode/scala-mode/for.multi deleted file mode 100644 index c512067..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/for.multi +++ /dev/null @@ -1,9 +0,0 @@ -#Author : Jonas Bonèr -#name : for {x <- xs \ y <- ys} { yield } -# -- -for { - ${1:x} <- ${2:xs} - ${3:x} <- ${4:xs} -} { - yield $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/foreach b/.emacs.d/mysnippets/text-mode/scala-mode/foreach deleted file mode 100644 index cafdd00..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/foreach +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : foreach(x => ..) -# -- -foreach(${1:x} => ${2:body}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/hmap.new b/.emacs.d/mysnippets/text-mode/scala-mode/hmap.new deleted file mode 100644 index dd564a0..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/hmap.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : new HashMap[K, V] -# -- -new HashMap[${1:key}, ${2:value}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/hmap.val-new b/.emacs.d/mysnippets/text-mode/scala-mode/hmap.val-new deleted file mode 100644 index 2f4a3c2..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/hmap.val-new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val m = new HashMap[K, V] -# -- -val ${1:m} = new HashMap[${2:key}, ${3:value}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/hset.new b/.emacs.d/mysnippets/text-mode/scala-mode/hset.new deleted file mode 100644 index d1be3ee..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/hset.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : new HashSet[K] -# -- -new HashSet[${1:key}] $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/hset.val-new b/.emacs.d/mysnippets/text-mode/scala-mode/hset.val-new deleted file mode 100644 index ba792a2..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/hset.val-new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val m = new HashSet[K] -# -- -val ${1:m} = new HashSet[${2:key}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/if b/.emacs.d/mysnippets/text-mode/scala-mode/if deleted file mode 100644 index 24891c0..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/if +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : if (cond) { .. } -# -- -if (${1:condition}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/if.else b/.emacs.d/mysnippets/text-mode/scala-mode/if.else deleted file mode 100644 index ebff471..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/if.else +++ /dev/null @@ -1,8 +0,0 @@ -#Author : Jonas Bonèr -#name : if (cond) { .. } else { .. } -# -- -if (${1:condition}) { - $2 -} else { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/imp b/.emacs.d/mysnippets/text-mode/scala-mode/imp deleted file mode 100644 index cf5efa1..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/imp +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : import .. -# -- -import $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/intercept b/.emacs.d/mysnippets/text-mode/scala-mode/intercept deleted file mode 100644 index 4725eaa..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/intercept +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : intercept(classOf[T]) { ..} -# -- -intercept(classOf[${1:Exception]}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/isof b/.emacs.d/mysnippets/text-mode/scala-mode/isof deleted file mode 100644 index a3538c8..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/isof +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : isInstanceOf[T] -# -- -isInstanceOf[${1:type}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ls.new b/.emacs.d/mysnippets/text-mode/scala-mode/ls.new deleted file mode 100644 index 7a28e61..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ls.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : List(..) -# -- -List(${1:args}, ${2:args}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ls.val-new b/.emacs.d/mysnippets/text-mode/scala-mode/ls.val-new deleted file mode 100644 index 37138f0..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ls.val-new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val l = List(..) -# -- -val ${1:l} = List(${2:args}, ${3:args}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/main b/.emacs.d/mysnippets/text-mode/scala-mode/main deleted file mode 100644 index ad314b3..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/main +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name: def main(args: Array[String]) = { ... } -# -- -def main(args: Array[String]) = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/map b/.emacs.d/mysnippets/text-mode/scala-mode/map deleted file mode 100644 index 17322a5..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/map +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : map(x => ..) -# -- -map(${1:x} => ${2:body}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/map.new b/.emacs.d/mysnippets/text-mode/scala-mode/map.new deleted file mode 100644 index 21c95fb..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/map.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : Map(key -> value) -# -- -Map(${1:key} -> ${2:value}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/match b/.emacs.d/mysnippets/text-mode/scala-mode/match deleted file mode 100644 index e85fac1..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/match +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : cc match { .. } -# -- -${1:cc} match { - case ${2:pattern} => $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/match.can b/.emacs.d/mysnippets/text-mode/scala-mode/match.can deleted file mode 100644 index 77d475b..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/match.can +++ /dev/null @@ -1,11 +0,0 @@ -#Author : Jonas Bonèr -#name : can match { case Full(res) => .. } -# -- -${1:option} match { - case Full(res) => $0 - - case Empty => - - case Failure(msg, _, _) => - -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/match.option b/.emacs.d/mysnippets/text-mode/scala-mode/match.option deleted file mode 100644 index 5b098f1..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/match.option +++ /dev/null @@ -1,8 +0,0 @@ -#Author : Jonas Bonèr -#name : option match { case None => .. } -# -- -${1:option} match { - case None => $0 - case Some(res) => - -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/mix b/.emacs.d/mysnippets/text-mode/scala-mode/mix deleted file mode 100644 index 5261e32..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/mix +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : trait T { .. } -# -- -trait ${1:name} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/ob b/.emacs.d/mysnippets/text-mode/scala-mode/ob deleted file mode 100644 index efbc82e..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/ob +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : object name extends T -# -- -object ${1:name} extends ${2:type} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pac b/.emacs.d/mysnippets/text-mode/scala-mode/pac deleted file mode 100644 index ed32216..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pac +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : package .. -# -- -package $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pr.newline b/.emacs.d/mysnippets/text-mode/scala-mode/pr.newline deleted file mode 100644 index 77088cb..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pr.newline +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : println(..) -# -- -println(${1:obj}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pr.simple b/.emacs.d/mysnippets/text-mode/scala-mode/pr.simple deleted file mode 100644 index 3a73f9d..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pr.simple +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : print(..) -# -- -print(${1:obj}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pr.string b/.emacs.d/mysnippets/text-mode/scala-mode/pr.string deleted file mode 100644 index 9c06ef7..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pr.string +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : println("..") -# -- -println("${1:msg}") $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pr.trace b/.emacs.d/mysnippets/text-mode/scala-mode/pr.trace deleted file mode 100644 index 9a0579c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pr.trace +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : println("obj: " + obj) -# -- -println("${1:obj}: " + ${1:obj}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pri b/.emacs.d/mysnippets/text-mode/scala-mode/pri deleted file mode 100644 index 643ef2c..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pri +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : private -# -- -private $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pri.param b/.emacs.d/mysnippets/text-mode/scala-mode/pri.param deleted file mode 100644 index e53638a..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pri.param +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : private[this] -# -- -private[${1:this}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pro b/.emacs.d/mysnippets/text-mode/scala-mode/pro deleted file mode 100644 index e4b7b59..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pro +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : protected -# -- -protected $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/pro.param b/.emacs.d/mysnippets/text-mode/scala-mode/pro.param deleted file mode 100644 index 712b050..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/pro.param +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : protected[this] -# -- -protected[${1:this}] $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/suite b/.emacs.d/mysnippets/text-mode/scala-mode/suite deleted file mode 100644 index a65cea7..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/suite +++ /dev/null @@ -1,8 +0,0 @@ -#Author : Jonas Bonèr -#name : class T extends Suite { .. } -# -- -import org.scalatest._ - -class ${1:name} extends Suite { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/test b/.emacs.d/mysnippets/text-mode/scala-mode/test deleted file mode 100644 index c4d13f6..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/test +++ /dev/null @@ -1,7 +0,0 @@ -#Author : Jonas Bonèr -#name : @Test def testX = ... -# -- -//@Test -def test${1:name} = { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/throw b/.emacs.d/mysnippets/text-mode/scala-mode/throw deleted file mode 100644 index f9a4932..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/throw +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : throw new Exception -# -- -throw new ${1:Exception}(${2:msg}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tr b/.emacs.d/mysnippets/text-mode/scala-mode/tr deleted file mode 100644 index 68d8162..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tr +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : trait T { .. } -# -- -trait ${1:name} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext b/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext deleted file mode 100644 index 2b82154..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : trait T extends C { .. } -# -- -trait ${1:name} extends ${2:class} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext-with b/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext-with deleted file mode 100644 index 8edb409..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tr.ext-with +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : trait T1 extends C with T2 { .. } -# -- -trait ${1:name} extends ${2:class} with ${3:trait} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tr.with b/.emacs.d/mysnippets/text-mode/scala-mode/tr.with deleted file mode 100644 index 19801eb..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tr.with +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Anders Bach Nielsen -#name : trait T1 with T2 { .. } -# -- -trait ${1:name} with ${2:trait} { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/try b/.emacs.d/mysnippets/text-mode/scala-mode/try deleted file mode 100644 index 0c33f10..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/try +++ /dev/null @@ -1,9 +0,0 @@ -#Author : Jonas Bonèr -#name : try { .. } catch { case e => ..} -# -- -try { - $0 -} catch { - case ${1:e}: ${2:Exception} => - ${1:println(\"ERROR: \" + e) // TODO: handle exception}\n} -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/try.catch-finally b/.emacs.d/mysnippets/text-mode/scala-mode/try.catch-finally deleted file mode 100644 index f146a20..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/try.catch-finally +++ /dev/null @@ -1,11 +0,0 @@ -#Author : Jonas Bonèr -#name : try { .. } catch { case e => ..} finally { ..} -# -- -try { - $0 -} catch { - case ${1:e}: ${2:Exception} => - ${1:println(\"ERROR: \" + e) // TODO: handle exception}\n} -} finally { - -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/try.finally b/.emacs.d/mysnippets/text-mode/scala-mode/try.finally deleted file mode 100644 index 63625f2..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/try.finally +++ /dev/null @@ -1,8 +0,0 @@ -#Author : Jonas Bonèr -#name : try { .. } finally { .. } -# -- -try { - -} finally { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tup.arrow b/.emacs.d/mysnippets/text-mode/scala-mode/tup.arrow deleted file mode 100644 index 4e7ad69..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tup.arrow +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : element1 -> element2 -# -- -${1:element1} -> ${2:element2} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/tup.paren b/.emacs.d/mysnippets/text-mode/scala-mode/tup.paren deleted file mode 100644 index 4bff202..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/tup.paren +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : (element1, element2) -# -- -(${1:element1}, ${2:element2}) $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/val b/.emacs.d/mysnippets/text-mode/scala-mode/val deleted file mode 100644 index 3067cd4..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/val +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val name = .. -# -- -val ${1:name} = ${2:obj} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/val.new b/.emacs.d/mysnippets/text-mode/scala-mode/val.new deleted file mode 100644 index 35a0c6a..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/val.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val name = new .. -# -- -val ${1:name} = new ${2:obj} $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/val.ret b/.emacs.d/mysnippets/text-mode/scala-mode/val.ret deleted file mode 100644 index 4bf4f10..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/val.ret +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : val name: T = .. -# -- -val ${1:name}: ${2:T} = ${3:obj} $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/var b/.emacs.d/mysnippets/text-mode/scala-mode/var deleted file mode 100644 index 662d6c8..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/var +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : var name = .. -# -- -var ${1:name} = ${2:obj} $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/var.new b/.emacs.d/mysnippets/text-mode/scala-mode/var.new deleted file mode 100644 index d681c4a..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/var.new +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : var name = new .. -# -- -var ${1:name} = new ${2:obj} $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/var.ret b/.emacs.d/mysnippets/text-mode/scala-mode/var.ret deleted file mode 100644 index 9d0ac3a..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/var.ret +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : var name: T = .. -# -- -var ${1:name}: ${2:T} = ${3:obj} $0 diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/whi b/.emacs.d/mysnippets/text-mode/scala-mode/whi deleted file mode 100644 index 082c139..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/whi +++ /dev/null @@ -1,6 +0,0 @@ -#Author : Jonas Bonèr -#name : while(cond) { .. } -# -- -while (${1:condition}) { - $0 -} \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/scala-mode/with b/.emacs.d/mysnippets/text-mode/scala-mode/with deleted file mode 100644 index 6bd94e4..0000000 --- a/.emacs.d/mysnippets/text-mode/scala-mode/with +++ /dev/null @@ -1,4 +0,0 @@ -#Author : Jonas Bonèr -#name : with T -# -- -with $0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/snippet-mode/field b/.emacs.d/mysnippets/text-mode/snippet-mode/field deleted file mode 100644 index bdaf0d4..0000000 --- a/.emacs.d/mysnippets/text-mode/snippet-mode/field +++ /dev/null @@ -1,5 +0,0 @@ -# name : ${ ... } field -# contributor : joaotavora -# key : $f -# -- -\${${1:${2:n}:}$3${4:\$(${5:lisp-fn})}\}$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/snippet-mode/mirror b/.emacs.d/mysnippets/text-mode/snippet-mode/mirror deleted file mode 100644 index 1c32eeb..0000000 --- a/.emacs.d/mysnippets/text-mode/snippet-mode/mirror +++ /dev/null @@ -1,5 +0,0 @@ -# name : ${n:$(...)} mirror -# key : $m -# contributor : joaotavora -# -- -\${${2:n}:${4:\$(${5:reflection-fn})}\}$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/snippet-mode/vars b/.emacs.d/mysnippets/text-mode/snippet-mode/vars deleted file mode 100644 index ea5a8c7..0000000 --- a/.emacs.d/mysnippets/text-mode/snippet-mode/vars +++ /dev/null @@ -1,9 +0,0 @@ -# name : Snippet header -# contributor : joaotavora -# -- -# name : $1${2: -# key : ${3:expand-key}}${4: -# group : ${5:group}} -# contributor : $6 -# -- -$0 \ No newline at end of file diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/column b/.emacs.d/mysnippets/text-mode/sql-mode/column deleted file mode 100644 index 90e4963..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/column +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : , ColumnName ColumnType NOT NULL... -# -- - , ${1:Name} ${2:Type} ${3:NOT NULL} diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/constraint b/.emacs.d/mysnippets/text-mode/sql-mode/constraint deleted file mode 100644 index 989e508..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/constraint +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : CONSTRAINT [..] PRIMARY KEY ... -# -- -CONSTRAINT [${1:PK_Name}] PRIMARY KEY ${2:CLUSTERED} ([${3:ColumnName}]) diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/constraint.1 b/.emacs.d/mysnippets/text-mode/sql-mode/constraint.1 deleted file mode 100644 index 98d89f0..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/constraint.1 +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : CONSTRAINT [..] FOREIGN KEY ... -# -- -CONSTRAINT [${1:FK_Name}] FOREIGN KEY ${2:CLUSTERED} ([${3:ColumnName}]) diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/create b/.emacs.d/mysnippets/text-mode/sql-mode/create deleted file mode 100644 index a34624d..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/create +++ /dev/null @@ -1,10 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : create table ... -# -- -CREATE TABLE [${1:dbo}].[${2:TableName}] -( - ${3:Id} ${4:INT IDENTITY(1,1)} ${5:NOT NULL} -$0 - CONSTRAINT [${6:PK_}] PRIMARY KEY ${7:CLUSTERED} ([$3]) -) -GO diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/create.1 b/.emacs.d/mysnippets/text-mode/sql-mode/create.1 deleted file mode 100644 index 1323daf..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/create.1 +++ /dev/null @@ -1,12 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : create procedure ... -# -- -CREATE PROCEDURE [${1:dbo}].[${2:Name}] -( - $3 $4 = ${5:NULL} ${6:OUTPUT} -) -AS -BEGIN -$0 -END -GO diff --git a/.emacs.d/mysnippets/text-mode/sql-mode/references b/.emacs.d/mysnippets/text-mode/sql-mode/references deleted file mode 100644 index f2e4eab..0000000 --- a/.emacs.d/mysnippets/text-mode/sql-mode/references +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Alejandro Espinoza Esparza -#name : REFERENCES ... -# -- -REFERENCES ${1:TableName}([${2:ColumnName}]) diff --git a/.emacs.d/mysnippets/text-mode/time b/.emacs.d/mysnippets/text-mode/time deleted file mode 100644 index d744f1a..0000000 --- a/.emacs.d/mysnippets/text-mode/time +++ /dev/null @@ -1,3 +0,0 @@ -#name : (current time) -# -- -`(current-time-string)` \ No newline at end of file diff --git a/.emacs.d/snippets/.nosearch b/.emacs.d/snippets/.nosearch new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.emacs.d/snippets/.nosearch @@ -0,0 +1 @@ + diff --git a/.emacs.d/snippets/c-mode/.yas-parents b/.emacs.d/snippets/c-mode/.yas-parents new file mode 100644 index 0000000..ce9828b --- /dev/null +++ b/.emacs.d/snippets/c-mode/.yas-parents @@ -0,0 +1 @@ +cc-mode diff --git a/.emacs.d/snippets/c-mode/assert b/.emacs.d/snippets/c-mode/assert new file mode 100644 index 0000000..964205e --- /dev/null +++ b/.emacs.d/snippets/c-mode/assert @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: assert +# key: ass +# -- +#include +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/compile b/.emacs.d/snippets/c-mode/compile new file mode 100644 index 0000000..8246a10 --- /dev/null +++ b/.emacs.d/snippets/c-mode/compile @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: compile +# key: compile +# -- +// -*- compile-command: "${1:gcc -Wall -o ${2:dest} ${3:file}}" -*- \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/define b/.emacs.d/snippets/c-mode/define new file mode 100644 index 0000000..9d5c5dd --- /dev/null +++ b/.emacs.d/snippets/c-mode/define @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: define +# key: d +# -- +#define $0 \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/fopen b/.emacs.d/snippets/c-mode/fopen new file mode 100644 index 0000000..0e48c21 --- /dev/null +++ b/.emacs.d/snippets/c-mode/fopen @@ -0,0 +1,4 @@ +#name : FILE *fp = fopen(..., ...); +# key: fopen +# -- +FILE *${fp} = fopen(${"file"}, "${r}"); \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/malloc b/.emacs.d/snippets/c-mode/malloc new file mode 100644 index 0000000..2a51de3 --- /dev/null +++ b/.emacs.d/snippets/c-mode/malloc @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: malloc +# key: malloc +# -- +malloc(sizeof($1)${2: * ${3:3}}); +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/packed b/.emacs.d/snippets/c-mode/packed new file mode 100644 index 0000000..b4eb125 --- /dev/null +++ b/.emacs.d/snippets/c-mode/packed @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: packed +# key: packed +# -- +__attribute__((__packed__))$0 \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/printf b/.emacs.d/snippets/c-mode/printf new file mode 100644 index 0000000..ccc788c --- /dev/null +++ b/.emacs.d/snippets/c-mode/printf @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: printf +# key: pr +# -- +printf("${1:format string}"${2: ,a0,a1}); \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/stdio b/.emacs.d/snippets/c-mode/stdio new file mode 100644 index 0000000..7529766 --- /dev/null +++ b/.emacs.d/snippets/c-mode/stdio @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: stdio +# key: io +# -- +#include \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/stdlib b/.emacs.d/snippets/c-mode/stdlib new file mode 100644 index 0000000..a7d117b --- /dev/null +++ b/.emacs.d/snippets/c-mode/stdlib @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: stdlib +# key: std +# -- +#include diff --git a/.emacs.d/snippets/c-mode/string b/.emacs.d/snippets/c-mode/string new file mode 100644 index 0000000..d45b757 --- /dev/null +++ b/.emacs.d/snippets/c-mode/string @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: string +# key: str +# -- +#include \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/switch b/.emacs.d/snippets/c-mode/switch new file mode 100644 index 0000000..0916059 --- /dev/null +++ b/.emacs.d/snippets/c-mode/switch @@ -0,0 +1,11 @@ +# -*- mode: snippet -*- +# name: switch +# key: case +# -- +switch (${1:ch}) { + case ${2:const}: + ${3:a = b}; + break; + ${4:default: + ${5:action}} +} diff --git a/.emacs.d/snippets/c-mode/union b/.emacs.d/snippets/c-mode/union new file mode 100644 index 0000000..b4ec5fa --- /dev/null +++ b/.emacs.d/snippets/c-mode/union @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: union +# key: union +# -- +typedef union { + $0 +} ${1:name}; \ No newline at end of file diff --git a/.emacs.d/snippets/c-mode/unistd b/.emacs.d/snippets/c-mode/unistd new file mode 100644 index 0000000..d5fca02 --- /dev/null +++ b/.emacs.d/snippets/c-mode/unistd @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: unistd +# key: uni +# -- +#include \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/.yas-parents b/.emacs.d/snippets/python-mode/.yas-parents new file mode 100644 index 0000000..75d003f --- /dev/null +++ b/.emacs.d/snippets/python-mode/.yas-parents @@ -0,0 +1 @@ +prog-mode diff --git a/.emacs.d/snippets/python-mode/.yas-setup.el b/.emacs.d/snippets/python-mode/.yas-setup.el new file mode 100644 index 0000000..6635232 --- /dev/null +++ b/.emacs.d/snippets/python-mode/.yas-setup.el @@ -0,0 +1,22 @@ +(defun python-split-args (arg-string) + "Split a python argument string into ((name, default)..) tuples" + (mapcar (lambda (x) + (split-string x "[[:blank:]]*=[[:blank:]]*" t)) + (split-string arg-string "[[:blank:]]*,[[:blank:]]*" t))) + +(defun python-args-to-docstring () + "return docstring format for the python arguments in yas-text" + (let* ((indent (concat "\n" (make-string (current-column) 32))) + (args (python-split-args yas-text)) + (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0)) + (formatted-args (mapconcat + (lambda (x) + (concat (nth 0 x) (make-string (- max-len (length (nth 0 x))) ? ) " -- " + (if (nth 1 x) (concat "\(default " (nth 1 x) "\)")))) + args + indent))) + (unless (string= formatted-args "") + (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent)))) + +(add-hook 'python-mode-hook + '(lambda () (set (make-local-variable 'yas-indent-line) 'fixed))) diff --git a/.emacs.d/snippets/python-mode/__getitem__ b/.emacs.d/snippets/python-mode/__getitem__ new file mode 100644 index 0000000..939bd1a --- /dev/null +++ b/.emacs.d/snippets/python-mode/__getitem__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __getitem__ +# key: getit +# group: dunder methods +# -- +def __getitem__(self, ${1:key}): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/__setitem__ b/.emacs.d/snippets/python-mode/__setitem__ new file mode 100644 index 0000000..c7db5b1 --- /dev/null +++ b/.emacs.d/snippets/python-mode/__setitem__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __setitem__ +# key: setit +# group: dunder methods +# -- +def __setitem__(self, ${1:key}, ${2:val}): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/arg b/.emacs.d/snippets/python-mode/arg new file mode 100644 index 0000000..f5145ec --- /dev/null +++ b/.emacs.d/snippets/python-mode/arg @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: arg +# key: arg +# group: argparser +# -- +parser.add_argument('-$1', '--$2', + $0) diff --git a/.emacs.d/snippets/python-mode/classmethod b/.emacs.d/snippets/python-mode/classmethod new file mode 100644 index 0000000..aa78440 --- /dev/null +++ b/.emacs.d/snippets/python-mode/classmethod @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: classmethod +# key: cm +# group: object oriented +# -- +@classmethod +def ${1:meth}(cls, $2): + """ + """ + $3 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/cls b/.emacs.d/snippets/python-mode/cls new file mode 100644 index 0000000..9f8b27c --- /dev/null +++ b/.emacs.d/snippets/python-mode/cls @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: cls +# key: cls +# group: object oriented +# -- +class ${1:class}: + $0 diff --git a/.emacs.d/snippets/python-mode/dec b/.emacs.d/snippets/python-mode/dec new file mode 100644 index 0000000..b22c9e9 --- /dev/null +++ b/.emacs.d/snippets/python-mode/dec @@ -0,0 +1,14 @@ +# -*- mode: snippet -*- +# name: dec +# key: dec +# group : definitions +# -- +def ${1:decorator}(func): + $2 + def _$1(*args, **kwargs): + $3 + ret = func(*args, **kwargs) + $4 + return ret + + return _$1 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/deftest b/.emacs.d/snippets/python-mode/deftest new file mode 100644 index 0000000..394553a --- /dev/null +++ b/.emacs.d/snippets/python-mode/deftest @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: deftest +# key: dt +# group: testing +# -- +def test_${1:long_name}(self): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/doc b/.emacs.d/snippets/python-mode/doc new file mode 100644 index 0000000..2929e78 --- /dev/null +++ b/.emacs.d/snippets/python-mode/doc @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: doc +# key: d +# -- +"""$0 +""" \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/eq b/.emacs.d/snippets/python-mode/eq new file mode 100644 index 0000000..e19c328 --- /dev/null +++ b/.emacs.d/snippets/python-mode/eq @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __eq__ +# key: eq +# group: dunder methods +# -- +def __eq__(self, other): + return self.$1 == other.$1 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/for b/.emacs.d/snippets/python-mode/for new file mode 100644 index 0000000..0033c87 --- /dev/null +++ b/.emacs.d/snippets/python-mode/for @@ -0,0 +1,6 @@ +# name: for ... in ... : ... +# key: for +# group : control structure +# -- +for ${var} in ${collection}: + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/from b/.emacs.d/snippets/python-mode/from new file mode 100644 index 0000000..3a4acfc --- /dev/null +++ b/.emacs.d/snippets/python-mode/from @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: from +# key: from +# group : general +# -- +from ${1:lib} import ${2:funs} \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/function b/.emacs.d/snippets/python-mode/function new file mode 100644 index 0000000..d7e8f12 --- /dev/null +++ b/.emacs.d/snippets/python-mode/function @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: function +# key: f +# group: definitions +# -- +def ${1:fun}(${2:args}): + $0 diff --git a/.emacs.d/snippets/python-mode/function_docstring b/.emacs.d/snippets/python-mode/function_docstring new file mode 100644 index 0000000..1f7f35b --- /dev/null +++ b/.emacs.d/snippets/python-mode/function_docstring @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: function_docstring +# key: fd +# group: definitions +# -- +def ${1:name}($2): + \"\"\"$3 + ${2:$(python-args-to-docstring)} + \"\"\" + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/ife b/.emacs.d/snippets/python-mode/ife new file mode 100644 index 0000000..4b8f613 --- /dev/null +++ b/.emacs.d/snippets/python-mode/ife @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: ife +# key: ife +# group : control structure +# -- +if $1: + $2 +else: + $0 diff --git a/.emacs.d/snippets/python-mode/ifmain b/.emacs.d/snippets/python-mode/ifmain new file mode 100644 index 0000000..9575798 --- /dev/null +++ b/.emacs.d/snippets/python-mode/ifmain @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: ifmain +# key: ifm +# -- +if __name__ == '__main__': + ${1:main()} \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/import b/.emacs.d/snippets/python-mode/import new file mode 100644 index 0000000..f34bc39 --- /dev/null +++ b/.emacs.d/snippets/python-mode/import @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: import +# key: imp +# group : general +# -- +import ${1:lib}${2: as ${3:alias}} +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/init_docstring b/.emacs.d/snippets/python-mode/init_docstring new file mode 100644 index 0000000..51af8db --- /dev/null +++ b/.emacs.d/snippets/python-mode/init_docstring @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: init_docstring +# key: id +# group : definitions +# -- +def __init__(self$1): + \"\"\"$2 + ${1:$(python-args-to-docstring)} + \"\"\" + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/lambda b/.emacs.d/snippets/python-mode/lambda new file mode 100644 index 0000000..08b268b --- /dev/null +++ b/.emacs.d/snippets/python-mode/lambda @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: lambda +# key: lam +# -- +lambda ${1:x}: $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/list b/.emacs.d/snippets/python-mode/list new file mode 100644 index 0000000..63cef24 --- /dev/null +++ b/.emacs.d/snippets/python-mode/list @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: list +# key: li +# group : definitions +# -- +[${1:el} for $1 in ${2:list}] +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/method b/.emacs.d/snippets/python-mode/method new file mode 100644 index 0000000..985ef0c --- /dev/null +++ b/.emacs.d/snippets/python-mode/method @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: method +# key: m +# group: object oriented +# -- +def ${1:method}(self${2:, $3}): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/method_docstring b/.emacs.d/snippets/python-mode/method_docstring new file mode 100644 index 0000000..8f5e78d --- /dev/null +++ b/.emacs.d/snippets/python-mode/method_docstring @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: method_docstring +# key: md +# group: object oriented +# -- +def ${1:name}(self$2): + \"\"\"$3 + ${2:$(python-args-to-docstring)} + \"\"\" + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/not_impl b/.emacs.d/snippets/python-mode/not_impl new file mode 100644 index 0000000..515e353 --- /dev/null +++ b/.emacs.d/snippets/python-mode/not_impl @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: not_impl +# key: not_impl +# -- +raise NotImplementedError \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/parse_args b/.emacs.d/snippets/python-mode/parse_args new file mode 100644 index 0000000..aa61070 --- /dev/null +++ b/.emacs.d/snippets/python-mode/parse_args @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: parse_args +# key: pargs +# group: argparser +# -- +def parse_arguments(): + parser = argparse.ArgumentParser(description='$1') + $0 + return parser.parse_args() \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/parser b/.emacs.d/snippets/python-mode/parser new file mode 100644 index 0000000..29a04ea --- /dev/null +++ b/.emacs.d/snippets/python-mode/parser @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: parser +# key: pars +# group: argparser +# -- +parser = argparse.ArgumentParser(description='$1') +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/print b/.emacs.d/snippets/python-mode/print new file mode 100644 index 0000000..cc1c797 --- /dev/null +++ b/.emacs.d/snippets/python-mode/print @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: print +# key: p +# -- +print($0) \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/reg b/.emacs.d/snippets/python-mode/reg new file mode 100644 index 0000000..c4ebeac --- /dev/null +++ b/.emacs.d/snippets/python-mode/reg @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: reg +# key: reg +# group : general +# -- +${1:regexp} = re.compile(r"${2:expr}") +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/repr b/.emacs.d/snippets/python-mode/repr new file mode 100644 index 0000000..a1f6783 --- /dev/null +++ b/.emacs.d/snippets/python-mode/repr @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __repr__ +# key: repr +# group: dunder methods +# -- +def __repr__(self): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/return b/.emacs.d/snippets/python-mode/return new file mode 100644 index 0000000..641a308 --- /dev/null +++ b/.emacs.d/snippets/python-mode/return @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: return +# key: r +# -- +return $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/script b/.emacs.d/snippets/python-mode/script new file mode 100644 index 0000000..e7f8a42 --- /dev/null +++ b/.emacs.d/snippets/python-mode/script @@ -0,0 +1,13 @@ +# -*- mode: snippet -*- +# name: script +# key: script +# -- +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/.emacs.d/snippets/python-mode/self b/.emacs.d/snippets/python-mode/self new file mode 100644 index 0000000..4461022 --- /dev/null +++ b/.emacs.d/snippets/python-mode/self @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: self +# key: . +# group: object oriented +# -- +self.$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/self_without_dot b/.emacs.d/snippets/python-mode/self_without_dot new file mode 100644 index 0000000..a1a0526 --- /dev/null +++ b/.emacs.d/snippets/python-mode/self_without_dot @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: self_without_dot +# key: s +# group: object oriented +# -- +self \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/selfassign b/.emacs.d/snippets/python-mode/selfassign new file mode 100644 index 0000000..95d7b2b --- /dev/null +++ b/.emacs.d/snippets/python-mode/selfassign @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: selfassign +# key: sn +# group: object oriented +# -- +self.$1 = $1 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/static b/.emacs.d/snippets/python-mode/static new file mode 100644 index 0000000..19c3df9 --- /dev/null +++ b/.emacs.d/snippets/python-mode/static @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: static +# key: sm +# -- +@staticmethod +def ${1:func}($0): diff --git a/.emacs.d/snippets/python-mode/str b/.emacs.d/snippets/python-mode/str new file mode 100644 index 0000000..b0572e3 --- /dev/null +++ b/.emacs.d/snippets/python-mode/str @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __str__ +# key: str +# group: dunder methods +# -- +def __str__(self): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/try b/.emacs.d/snippets/python-mode/try new file mode 100644 index 0000000..8836de6 --- /dev/null +++ b/.emacs.d/snippets/python-mode/try @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: try +# key: try +# -- +try: + $1 +except ${2:Exception}: + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/unicode b/.emacs.d/snippets/python-mode/unicode new file mode 100644 index 0000000..52d6b8d --- /dev/null +++ b/.emacs.d/snippets/python-mode/unicode @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __unicode__ +# key: un +# group: dunder methods +# -- +def __unicode__(self): + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/utf8 b/.emacs.d/snippets/python-mode/utf8 new file mode 100644 index 0000000..2ebd82e --- /dev/null +++ b/.emacs.d/snippets/python-mode/utf8 @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: utf-8 encoding +# key: utf8 +# -- +# -*- coding: utf-8 -*- diff --git a/.emacs.d/snippets/python-mode/while b/.emacs.d/snippets/python-mode/while new file mode 100644 index 0000000..7b3539c --- /dev/null +++ b/.emacs.d/snippets/python-mode/while @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: while +# key: wh +# group: control structure +# -- +while ${1:True}: + $0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/with b/.emacs.d/snippets/python-mode/with new file mode 100644 index 0000000..7fcbd38 --- /dev/null +++ b/.emacs.d/snippets/python-mode/with @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: with +# key: with +# group : control structure +# -- +with ${1:expr}${2: as ${3:alias}}: + $0 \ No newline at end of file -- cgit v1.3