;;; zencoding-mode.el --- Unfold CSS-selector-like expressions to markup ;; Copyright (C) 2009, Chris Done ;; Version: 0.5.1 ;; Author: Chris Done ;; URL: https://github.com/rooney/zencoding ;; Last-Updated: 2011-12-31 Sat ;; Keywords: convenience ;; 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, 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 GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Commentary: ;; ;; Unfold CSS-selector-like expressions to markup. Intended to be used ;; with sgml-like languages; xml, html, xhtml, xsl, etc. ;; ;; See `zencoding-mode' for more information. ;; ;; Copy zencoding-mode.el to your load-path and add to your .emacs: ;; ;; (require 'zencoding-mode) ;; ;; Example setup: ;; ;; (add-to-list 'load-path "~/Emacs/zencoding/") ;; (require 'zencoding-mode) ;; (add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes ;; (add-hook 'html-mode-hook 'zencoding-mode) ;; (add-hook 'css-mode-hook 'zencoding-mode) ;; ;; Enable the minor mode with M-x zencoding-mode. ;; ;; See ``Test cases'' section for a complete set of expression types. ;; ;; If you are hacking on this project, eval (zencoding-test-cases) to ;; ensure that your changes have not broken anything. Feel free to add ;; new test cases if you add new features. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; History: ;; ;; Modified by Lennart Borgman. ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Code: (defconst zencoding-mode:version "0.5.1") ;; Include the trie data structure for caching ;(require 'zencoding-trie) (require 'cl) (defmacro zencoding-defparameter (symbol &optional initvalue docstring) `(progn (defvar ,symbol nil ,docstring) (setq ,symbol ,initvalue))) (defun zencoding-join-string (lis joiner) (mapconcat 'identity lis joiner)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Generic parsing macros and utilities (defmacro zencoding-aif (test-form then-form &rest else-forms) "Anaphoric if. Temporary variable `it' is the result of test-form." `(let ((it ,test-form)) (if it ,then-form ,@(or else-forms '(it))))) (defmacro zencoding-pif (test-form then-form &rest else-forms) "Parser anaphoric if. Temporary variable `it' is the result of test-form." `(let ((it ,test-form)) (if (not (eq 'error (car it))) ,then-form ,@(or else-forms '(it))))) (defmacro zencoding-parse (regex nums label &rest body) "Parse according to a regex and update the `input' variable." `(zencoding-aif (zencoding-regex ,regex input ',(number-sequence 0 nums)) (let ((input (elt it ,nums))) ,@body) `,`(error ,(concat "expected " ,label)))) (defmacro zencoding-run (parser then-form &rest else-forms) "Run a parser and update the input properly, extract the parsed expression." `(zencoding-pif (,parser input) (let ((input (cdr it)) (expr (car it))) ,then-form) ,@(or else-forms '(it)))) (defmacro zencoding-por (parser1 parser2 then-form &rest else-forms) "OR two parsers. Try one parser, if it fails try the next." `(zencoding-pif (,parser1 input) (let ((input (cdr it)) (expr (car it))) ,then-form) (zencoding-pif (,parser2 input) (let ((input (cdr it)) (expr (car it))) ,then-form) ,@else-forms))) (defun zencoding-regex (regexp string refs) "Return a list of (`ref') matches for a `regex' on a `string' or nil." (if (string-match (concat "^" regexp "\\([^\n]*\\)$") string) (mapcar (lambda (ref) (match-string ref string)) (if (sequencep refs) refs (list refs))) nil)) ;; src/snippets.el ;; This file is generated from conf/snippets.json ;; Don't edit. (zencoding-defparameter zencoding-snippets (let ((tbl (make-hash-table :test 'equal))) (puthash "xml" (let ((tbl (make-hash-table :test 'equal))) (puthash "profile" "xml" tbl) (puthash "extends" "html" tbl) (puthash "filters" "html" tbl) tbl) tbl) (puthash "scss" (let ((tbl (make-hash-table :test 'equal))) (puthash "extends" "css" tbl) tbl) tbl) (puthash "sass" (let ((tbl (make-hash-table :test 'equal))) (puthash "extends" "css" tbl) tbl) tbl) (puthash "less" (let ((tbl (make-hash-table :test 'equal))) (puthash "extends" "css" tbl) tbl) tbl) (puthash "variables" (let ((tbl (make-hash-table :test 'equal))) (puthash "lang" "en" tbl) (puthash "locale" "en-US" tbl) (puthash "charset" "UTF-8" tbl) (puthash "indentation" "\t" tbl) (puthash "newline" "\n" tbl) tbl) tbl) (puthash "stylus" (let ((tbl (make-hash-table :test 'equal))) (puthash "extends" "css" tbl) tbl) tbl) (puthash "html" (let ((tbl (make-hash-table :test 'equal))) (puthash "profile" "html" tbl) (puthash "abbreviations" (let ((tbl (make-hash-table :test 'equal))) (puthash "a:link" "" tbl) (puthash "doc4" "html>(head>meta[http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\"]+title{${1:Document}})" tbl) (puthash "input:datetime-local" "inp[type=datetime-local]" tbl) (puthash "input:reset" "input:button[type=reset]" tbl) (puthash "meta:vp" "" tbl) (puthash "colg" "colgroup" tbl) (puthash "figc" "figcaption" tbl) (puthash "btn:s" "button[type=submit]" tbl) (puthash "btn:r" "button[type=reset]" tbl) (puthash "style" "