Moved 3rd party libs to separate dir and added optional scion haskell support.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/align-with-spaces.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,16 @@
+;; ~/.emacs.d/hoersten-align-with-spaces.el
+;; Luke Hoersten <[email protected]>
+
+(global-set-key (kbd "C-c a") 'align-with-spaces)
+(defun align-with-spaces (beg end pattern)
+ "Align selected using only spaces for whitespace."
+ (interactive "r\nsAlign by: ")
+ (let ((indent-tabs-mode nil))
+ (align-string beg end pattern 1)
+ (align-entire beg end)
+ (untabify beg end)
+ (indent-region beg end)
+ (whitespace-cleanup-region beg end)))
+
+(message "Loading align-with-spaces...done")
+(provide 'align-with-spaces)
--- a/color-theme-twilight.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-;; Twilight Colour Theme for Emacs.
-;;
-;; Defines a colour scheme resembling that of the original TextMate Twilight colour theme.
-;; To use add the following to your .emacs file (requires the color-theme package):
-;;
-;; (require 'color-theme)
-;; (color-theme-initialize)
-;; (load-file "~/.emacs.d/twilight-emacs/color-theme-twilight.el")
-;;
-;; And then (color-theme-twilight) to activate it.
-;;
-;; Several areas still require improvement such as recognition of code that ruby-mode doesn't
-;; yet pick up (eg. parent classes), Rails/Merb keywords, or non Ruby code related areas
-;; (eg. dired, HTML, etc). Please feel free to customize further and send in any improvements,
-;; patches most welcome.
-;;
-;; MIT License Copyright (c) 2008 Marcus Crafter <[email protected]>
-;; Credits due to the excellent TextMate Twilight theme
-;;
-;; Thanks to Travis Jeffery for ido-mode and fixes to the minibuffer-prompt to fit in with the rest of the theme
-;;
-
-(defun color-theme-twilight ()
- "Color theme by Marcus Crafter, based off the TextMate Twilight theme, created 2008-04-18"
- (interactive)
- (color-theme-install
- '(color-theme-twilight
- ((background-color . "#000000")
- (background-mode . dark)
- (border-color . "black")
- (cursor-color . "#A7A7A7")
- (foreground-color . "#F8F8F8")
- (mouse-color . "sienna1"))
- (default ((t (:background "#000000" :foreground "#CACACA"))))
- (blue ((t (:foreground "blue"))))
- (border-glyph ((t (nil))))
- (buffers-tab ((t (:background "#000000" :foreground "#CACACA"))))
- (font-lock-builtin-face ((t (:foreground "#CACACA"))))
- (font-lock-comment-face ((t (:foreground "#5F5A60"))))
- (font-lock-constant-face ((t (:foreground "#CF6A4C"))))
- (font-lock-doc-string-face ((t (:foreground "DarkOrange"))))
- (font-lock-function-name-face ((t (:foreground "#9B703F"))))
- (font-lock-keyword-face ((t (:foreground "#CDA869"))))
- (font-lock-preprocessor-face ((t (:foreground "Aquamarine"))))
- (font-lock-reference-face ((t (:foreground "SlateBlue"))))
-
- (font-lock-regexp-grouping-backslash ((t (:foreground "#E9C062"))))
- (font-lock-regexp-grouping-construct ((t (:foreground "red"))))
-
- (minibuffer-prompt ((t (:foreground "#5F5A60"))))
- (ido-subdir ((t (:foreground "#CF6A4C"))))
- (ido-first-match ((t (:foreground "#8F9D6A"))))
- (ido-only-match ((t (:foreground "#8F9D6A"))))
- (mumamo-background-chunk-submode ((t (:background "#222222"))))
-
- (font-lock-string-face ((t (:foreground "#8F9D6A"))))
- (font-lock-type-face ((t (:foreground "#9B703F"))))
- (font-lock-variable-name-face ((t (:foreground "#7587A6"))))
- (font-lock-warning-face ((t (:background "#EE799F" :foreground "red"))))
- (gui-element ((t (:background "#D4D0C8" :foreground "black"))))
- (region ((t (:background "#27292A"))))
- (mode-line ((t (:background "grey75" :foreground "black"))))
- (highlight ((t (:background "#111111"))))
- (highline-face ((t (:background "SeaGreen"))))
- (left-margin ((t (nil))))
- (text-cursor ((t (:background "yellow" :foreground "black"))))
- (toolbar ((t (nil))))
- (underline ((nil (:underline nil))))
- (zmacs-region ((t (:background "snow" :foreground "blue")))))))
--- a/hoersten-align-with-spaces.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-;; ~/.emacs.d/hoersten-align-with-spaces.el
-;; Luke Hoersten <[email protected]>
-
-(global-set-key (kbd "C-c a") 'align-with-spaces)
-(defun align-with-spaces (beg end pattern)
- "Align selected using only spaces for whitespace."
- (interactive "r\nsAlign by: ")
- (let ((indent-tabs-mode nil))
- (align-string beg end pattern 1)
- (align-entire beg end)
- (untabify beg end)
- (indent-region beg end)
- (whitespace-cleanup-region beg end)))
-
-(message "Loaded Hoersten align-with-spaces function")
-(provide 'hoersten-align-with-spaces)
--- a/hoersten-c-style.el Sun Apr 03 11:26:27 2011 -0500
+++ b/hoersten-c-style.el Sat May 14 14:47:51 2011 -0500
@@ -73,5 +73,5 @@
(add-to-list 'auto-mode-alist '("\\.ipp$" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.inl$" . c++-mode))
-(message "Loaded Hoersten C style")
+(message "Loading Hoersten C style...done")
(provide 'hoersten-c-style)
\ No newline at end of file
--- a/hoersten-pastebin-region.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-;; ~/.emacs.d/hoersten-pastebin-region.el
-;; Luke Hoersten <[email protected]>
-
-;; custom keys
-(global-set-key (kbd "C-c w") 'pastebin-region)
-
-;; Based on http://www.emacswiki.org/cgi-bin/wiki/download/pastebin.el
-(defvar pastebin-type-assoc
- '((emacs-lisp-mode . "common-lisp")
- (c-mode . "c")
- (python-mode . "python")
- (nxml-mode . "xml")
- (c++-mode . "cpp")))
-
-(defun pastebin-region (start end)
- "Send selected text to dpaste pastebin."
- (interactive "r")
- (let*
- ((pastebin-url "http://inf/paste/")
- (url-request-method "POST")
- (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
- (url-request-data
- (format
- "title=%s&content=%s&lexer=%s&author=%s"
- (url-hexify-string (buffer-file-name)) ; title
- (url-hexify-string (buffer-substring-no-properties start end)) ; content
- (url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ; lexer
- (url-hexify-string (user-full-name))))) ; author
- (url-retrieve
- pastebin-url
- (lambda (arg)
- (cond
- ((equal :error (car arg))
- (signal (cdr arg)))
- ((equal :redirect (car arg))
- (let ((redirected (cadr arg)))
- (message redirected)
- (with-temp-buffer
- (insert redirected)
- (clipboard-kill-ring-save (point-min) (point-max))))))))))
-
-(message "Loaded Hoersten pastebin")
-(provide 'hoersten-pastebin-region)
--- a/init.el Sun Apr 03 11:26:27 2011 -0500
+++ b/init.el Sat May 14 14:47:51 2011 -0500
@@ -3,7 +3,8 @@
;;;; General ;;;;
-(add-to-list 'load-path "~/.emacs.d") ; set default emacs load path
+(add-to-list 'load-path "~/.emacs.d") ; set default emacs load path
+(add-to-list 'load-path "~/.emacs.d/thirdparty") ; set default third party path
(setq-default
ediff-split-window-function
@@ -12,14 +13,13 @@
inhibit-splash-screen t ; disable splash screen
truncate-lines t ; truncate, not wrap, lines
indent-tabs-mode nil ; only uses spaces for indentation
- split-width-threshold 181) ; min width to split window horizontially
+ split-width-threshold 181 ; min width to split window horizontially
+ reb-re-syntax 'string) ; use string syntax for regexp builder
(put 'set-goal-column 'disabled nil) ; enable goal column setting
(put 'narrow-to-region 'disabled nil) ; enable hiding
(put 'narrow-to-page 'disabled nil)
-(menu-bar-mode -1) ; remove menu bar
-(display-time-mode t) ; show clock
(column-number-mode t) ; show column numbers
(delete-selection-mode t) ; replace highlighted text
(windmove-default-keybindings) ; move between windows with shift-arrow
@@ -51,8 +51,8 @@
"Get appropriate font based on system and hostname."
(cond
((string-match "darwin" (emacs-version)) "Menlo-12")
- ((string-match "HoldenCaulfield" (system-name)) "monospace-7")
- ((string-match "lhoersten-66113" (system-name)) "monospace-8")
+ ((string-match "HoldenCaulfield" (system-name)) "monospace-6")
+ ((string-match "lhoersten-66113" (system-name)) "monospace-9")
("monospace-10")))
(tool-bar-mode -1) ; remove tool bar
@@ -73,7 +73,7 @@
'eshell-mode-hook
'(lambda ()
(setenv "TERM" "emacs") ; enable colors
- (setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH"))))) ; add cabal binaries
+ (setenv "PATH" (concat "/opt/ghc7/bin:" "~/.cabal/bin:" (getenv "PATH")))))
;;;; Mode-Specific ;;;;
@@ -118,6 +118,19 @@
indent-tabs-mode t)))
;;; haskell-mode
+;; scion
+(if (file-exists-p "~/.cabal/share/scion-0.1.0.10/emacs")
+ (progn
+ (add-to-list 'load-path "~/.cabal/share/scion-0.1.0.10/emacs")
+ (require 'scion)
+ (setq scion-program "~/.cabal/bin/scion-server")
+ (add-hook
+ 'haskell-mode-hook
+ (lambda ()
+ (scion-mode 1)
+ (scion-flycheck-on-save 1)
+ (setq scion-completing-read-function 'ido-completing-read)))))
+
(add-hook
'haskell-mode-hook
(lambda ()
@@ -128,7 +141,7 @@
(setq
haskell-font-lock-symbols 'unicode
haskell-indent-offset 4
- whitespace-line-column 78))
+ whitespace-line-column 120))
t) ; append instead of prepend else haskell-mode overwrites these settings
;;; org-mode
@@ -159,21 +172,21 @@
;;;; Requires ;;;;
-(require 'hoersten-align-with-spaces) ; use only spaces for alignment
-(require 'hoersten-pastebin-region) ; send selected text to pastebin
-(require 'hoersten-c-style) ; load c specific lisp
-(require 'vala-mode) ; vala programming language
-(require 'move-line) ; move line up or down
+(require 'hoersten-c-style) ; load c specific lisp
+(require 'align-with-spaces) ; use only spaces for alignment
+(require 'pastebin-region) ; send selected text to pastebin
+(require 'move-line) ; move line up or down
+(require 'vala-mode) ; vala programming language
;;; pretty-mode - unicode character replacement
(require 'pretty-mode)
(global-pretty-mode t)
;;; yasnippets
-(add-to-list 'load-path "~/.emacs.d/yasnippet")
+(add-to-list 'load-path "~/.emacs.d/thirdparty/yasnippet")
(require 'yasnippet)
(yas/initialize)
-(yas/load-directory "~/.emacs.d/yasnippet/snippets")
+(yas/load-directory "~/.emacs.d/thirdparty/yasnippet/snippets")
(setq-default yas/prompt-functions '(yas/ido-prompt yas/dropdown-prompt)) ; use ido for multiple snippets
;;; zencoding-mode - html
--- a/init_eshell.sh Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-export LOCAL_QUOTES=~/Trade/localQuotes/
--- a/move-line.el Sun Apr 03 11:26:27 2011 -0500
+++ b/move-line.el Sat May 14 14:47:51 2011 -0500
@@ -26,5 +26,5 @@
(global-set-key (kbd "M-p") 'move-line-up)
(global-set-key (kbd "M-n") 'move-line-down)
-(message "Loaded move-line function")
+(message "Loading move-line...done")
(provide 'move-line)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pastebin-region.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,43 @@
+;; ~/.emacs.d/hoersten-pastebin-region.el
+;; Luke Hoersten <[email protected]>
+
+;; custom keys
+(global-set-key (kbd "C-c w") 'pastebin-region)
+
+;; Based on http://www.emacswiki.org/cgi-bin/wiki/download/pastebin.el
+(defvar pastebin-type-assoc
+ '((emacs-lisp-mode . "common-lisp")
+ (c-mode . "c")
+ (python-mode . "python")
+ (nxml-mode . "xml")
+ (c++-mode . "cpp")))
+
+(defun pastebin-region (start end)
+ "Send selected text to dpaste pastebin."
+ (interactive "r")
+ (let*
+ ((pastebin-url "http://inf/paste/")
+ (url-request-method "POST")
+ (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
+ (url-request-data
+ (format
+ "title=%s&content=%s&lexer=%s&author=%s"
+ (url-hexify-string (buffer-file-name)) ; title
+ (url-hexify-string (buffer-substring-no-properties start end)) ; content
+ (url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ; lexer
+ (url-hexify-string (user-full-name))))) ; author
+ (url-retrieve
+ pastebin-url
+ (lambda (arg)
+ (cond
+ ((equal :error (car arg))
+ (signal (cdr arg)))
+ ((equal :redirect (car arg))
+ (let ((redirected (cadr arg)))
+ (message redirected)
+ (with-temp-buffer
+ (insert redirected)
+ (clipboard-kill-ring-save (point-min) (point-max))))))))))
+
+(message "Loading pastebin-region...done")
+(provide 'pastebin-region)
--- a/pretty-mode.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-;;; -*- coding: utf-8 -*-
-;; Minor mode for redisplaying parts of the buffer as pretty symbols
-;; originally modified from Trent Buck's version at http://paste.lisp.org/display/42335,2/raw
-;; Also includes code from `sml-mode'
-;; See also http://www.emacswiki.org/cgi-bin/wiki/PrettyLambda
-;; written by Arthur Danskin <[email protected]>
-;;
-;; to install:
-;; (require 'pretty-mode)
-;; (global-pretty-mode 1)
-;; or
-;; (add-hook 'my-pretty-language-hook 'turn-on-pretty-mode)
-
-
-(require 'cl)
-
-;; modified from `sml-mode'
-(defun pretty-font-lock-compose-symbol (alist)
- "Compose a sequence of ascii chars into a symbol."
- (let* ((start (match-beginning 0))
- (end (match-end 0))
- (syntax (char-syntax (char-after start))))
- (if (or (if (eq syntax ?w)
- (or (eq (char-syntax (char-before start)) ?w)
- (eq (char-syntax (char-after end)) ?w))
- (memq (char-syntax (char-before start)) '(?. ?\\)))
- (memq (get-text-property start 'face)
- '(font-lock-doc-face font-lock-string-face
- font-lock-comment-face)))
- (remove-text-properties start end '(composition))
- (compose-region start end (cdr (assoc (match-string 0) alist)))
- ))
- nil)
-
-(defvar pretty-interaction-mode-alist
- '((inferior-scheme-mode . scheme-mode)
- (lisp-interaction-mode . emacs-lisp-mode)
- (inferior-lisp-mode . lisp-mode)
- (inferior-ess-mode . ess-mode)
- (inf-haskell-mode . haskell-mode)
- (inferior-erlang-mode . erlang-mode)
- (tuareg-interactive-mode . tuareg-mode)
- (inferior-python-mode . python-mode)
- (inferior-octave-mode . octave-mode)
- (inferior-ruby-mode . ruby-mode))
- "Alist mapping from inferior process interaction modes to their
- corresponding script editing modes.")
-
-
-(defun pretty-font-lock-keywords (alist)
- "Return a `font-lock-keywords' style entry for replacing
-regular expressions with symbols. ALIST has the form ((STRING .
-REPLACE-CHAR) ...)."
- (when alist
- `((,(regexp-opt (mapcar 'car alist))
- (0 (pretty-font-lock-compose-symbol
- ',alist))))))
-
-(defun pretty-keywords (&optional mode)
- "Return the font-lock keywords for MODE, or the current mode if
-MODE is nil. Return nil if there are no keywords."
- (let* ((mode (or mode major-mode))
- (kwds (cdr-safe
- (or (assoc mode pretty-patterns)
- (assoc (cdr-safe
- (assoc mode pretty-interaction-mode-alist))
- pretty-patterns)))))
- (pretty-font-lock-keywords kwds)))
-
-(defgroup pretty nil "Minor mode for replacing text with symbols "
- :group 'faces)
-
-(define-minor-mode pretty-mode
- "Toggle Pretty minor mode.
-With arg, turn Pretty minor mode on if arg is positive, off otherwise.
-
-Pretty mode builds on `font-lock-mode'. Instead of highlighting
-keywords, it replaces them with symbols. For example, lambda is
-displayed as λ in lisp modes."
- :group 'pretty
- ; :lighter " λ"
- (if pretty-mode
- (progn
- (font-lock-add-keywords nil (pretty-keywords) t)
- (font-lock-fontify-buffer))
- (font-lock-remove-keywords nil (pretty-keywords))
- (remove-text-properties (point-min) (point-max) '(composition nil))))
-
-(defun turn-on-pretty-if-desired ()
- "Turn on `pretty-mode' if the current major mode supports it."
- (if (pretty-keywords)
- (pretty-mode 1)))
-
-(define-globalized-minor-mode global-pretty-mode
- pretty-mode turn-on-pretty-if-desired
- :init-value t)
-
-(defun turn-off-pretty-mode ()
- (interactive)
- (pretty-mode -1))
-
-
-(defun turn-on-pretty-mode ()
- (interactive)
- (pretty-mode +1))
-
-(defun pretty-compile-patterns (patterns)
- "Set pretty patterns in a convenient way.
-
-PATTERNS should be of the form ((GLYPH (REGEXP MODE ...) ...)
-...). GLYPH should be a character. MODE should be the name of a
-major mode without the \"-mode\". Returns patterns in the form
-expected by `pretty-patterns'"
- (let ((pretty-patterns))
- (loop for (glyph . pairs) in patterns do
- (loop for (regexp . major-modes) in pairs do
- (loop for mode in major-modes do
- (let* ((mode (intern (concat (symbol-name mode)
- "-mode")))
- (assoc-pair (assoc mode pretty-patterns))
-
- (entry (cons regexp glyph)))
- (if assoc-pair
- (push entry (cdr assoc-pair))
- (push (cons mode (list entry))
- pretty-patterns))))))
- pretty-patterns))
-
-;;; (setq-default pretty-patterns pretty-patterns-default)
-(defconst pretty-patterns-default
- (let* ((lispy '(scheme emacs-lisp lisp))
- (mley '(tuareg haskell sml erlang))
- (c-like '(c c++ perl sh python java ess ruby))
- (all (append lispy mley c-like (list 'octave))))
- (pretty-compile-patterns
- `(
- (?≠ ("!=" ,@c-like scheme octave)
- ("<>" tuareg octave)
- ("~=" octave)
- ("/=" haskell)
- ("=/=" erlang))
- (?≤ ("<=" ,@all))
- (?≤ ("=<" erlang))
- (?λ ("fun" erlang))
- (?≥ (">=" ,@all))
- (?← ("<-" ,@mley ess)
- ("!" erlang))
- (?→ ("->" ,@mley ess c c++ perl))
- (?↑ ("\\^" tuareg))
- (?⇒ ("=>" sml perl ruby))
- (?≡ ("==" ,@c-like erlang haskell))
- (?∀ ("BOOST_FOREACH" c++))
- (?∷ ("::" ,@all))
- (?√ ("sqrt" ,@all))
- (?∑ ("sum" python))
-
- (?α ("alpha" ,@all))
- (?Α ("Alpha" ,@all))
-
- (?β ("beta" ,@all))
- (?Β ("Beta" ,@all))
-
- (?γ ("gamma" ,@all))
- (?Γ ("Gamma" ,@all))
-
- (?δ ("delta" ,@all))
- (?Δ ("Delta" ,@all))
-
- (?ε ("epsilon" ,@all))
- (?Ε ("epsilon" ,@all))
-
- (?ζ ("zeta" ,@all))
- (?Ζ ("Zeta" ,@all))
-
- (?η ("eta" ,@all))
- (?Η ("Eta" ,@all))
-
- (?θ ("theta" ,@all))
- (?Θ ("Theta" ,@all))
-
- (?ι ("iota" ,@all))
- (?Ι ("Iota" ,@all))
-
- (?κ ("kappa" ,@all))
- (?K ("Kappa" ,@all))
-
- (?λ ("lambda" ,@all))
- (?Λ ("Lambda" ,@all))
-
- (?μ ("mu" ,@all))
- (?Μ ("Mu" ,@all))
-
- (?ν ("nu" ,@all))
- (?Ν ("Nu" ,@all))
-
- (?ν ("vega" ,@all))
- (?ν ("Vega" ,@all))
-
- (?ξ ("xi" ,@all))
- (?Ξ ("Xi" ,@all))
-
- (?ο ("omicron" ,@all))
- (?Ο ("Omicron" ,@all))
-
- (?π ("pi" ,@all))
- (?Π ("pi" ,@all))
-
- (?ρ ("rho" ,@all))
- (?Ρ ("Rho" ,@all))
-
- (?σ ("sigma" ,@all))
- (?Σ ("Sigma" ,@all))
-
- (?τ ("tau" ,@all))
- (?Τ ("Tau" ,@all))
-
- (?υ ("upsilon" ,@all))
- (?Y ("Upsilon" ,@all))
-
- (?φ ("phi" ,@all))
- (?Φ ("Phi" ,@all))
-
- (?χ ("chi" ,@all))
- (?Χ ("Chi" ,@all))
-
- (?ψ ("psi" ,@all))
- (?Ψ ("Psi" ,@all))
-
- (?ω ("omega" ,@all))
- (?Ω ("Omega" ,@all))
-
- (?² ("**2" python tuareg octave))
- (?³ ("**3" python tuareg octave))
- (?ⁿ ("**n" python tuareg octave))
- (?ₐ ("[a]" ,@c-like))
- (?ₓ ("[x]" ,@c-like))
- (?₀ ("[0]" ,@c-like)
- ("/0" erlang))
- (?₁ ("[1]" ,@c-like)
- ("/1" erlang))
- (?₂ ("[2]" ,@c-like)
- ("/2" erlang))
- (?₃ ("[3]" ,@c-like)
- ("/3" erlang))
- (?₄ ("[4]" ,@c-like)
- ("/4" erlang))
- (?₅ ("[5]" ,@c-like)
- ("/5" erlang))
- (?₆ ("[6]" ,@c-like)
- ("/6" erlang))
- (?₇ ("[7]" ,@c-like)
- ("/7" erlang))
- (?₈ ("[8]" ,@c-like)
- ("/8" erlang))
- (?₉ ("[9]" ,@c-like)
- ("/9" erlang))
- (?∧ ("\\<And\\>" emacs-lisp lisp python)
- ("\\<andalso\\>" sml erlang)
- ("&&" c c++ perl haskell))
- (?∨ ("\\<or\\>" emacs-lisp lisp)
- ("\\<orelse\\>" sml erlang)
- ("||" c c++ perl haskell erlang))
- (?¬ ("!" c c++))
- )))
- "default value for `pretty-patterns'")
-
-;; TODO fix type
-(defcustom pretty-patterns pretty-patterns-default
- "*List of pretty patterns.
-
-Should be a list of the form ((MODE ((REGEXP . GLYPH) ...)) ...)"
- :group 'pretty
- :type '(alist :key-type variable :value-type (alist :key-type (string) :value-type (character))))
-
-
-(defun pretty-add-keywords (mode keywords)
- "Add pretty character KEYWORDS to MODE
-
-MODE should be a symbol, the major mode command name, such as
-`c-mode' or nil. If nil, pretty keywords are added to the current
-buffer. KEYWORDS should be a list where each element has the
-form (REGEXP . CHAR). REGEXP will be replaced with CHAR in the
-relevant buffer(s)."
- (font-lock-add-keywords
- mode (mapcar (lambda (kw) `((,(car kw)
- (0 (prog1 nil
- (compose-region (match-beginning 0)
- (match-end 0)
- ,(cdr kw)))))))
- keywords)))
-
-(defun pretty-regexp (regexp glyph)
- "Replace REGEXP with GLYPH in buffer."
- (interactive "MRegexp to replace:
-MCharacter to replace with: ")
- (pretty-add-keywords nil `((,regexp . ,(string-to-char glyph))))
- (font-lock-fontify-buffer))
-
-
-
-
-(provide 'pretty-mode)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/thirdparty/color-theme-twilight.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,69 @@
+;; Twilight Colour Theme for Emacs.
+;;
+;; Defines a colour scheme resembling that of the original TextMate Twilight colour theme.
+;; To use add the following to your .emacs file (requires the color-theme package):
+;;
+;; (require 'color-theme)
+;; (color-theme-initialize)
+;; (load-file "~/.emacs.d/twilight-emacs/color-theme-twilight.el")
+;;
+;; And then (color-theme-twilight) to activate it.
+;;
+;; Several areas still require improvement such as recognition of code that ruby-mode doesn't
+;; yet pick up (eg. parent classes), Rails/Merb keywords, or non Ruby code related areas
+;; (eg. dired, HTML, etc). Please feel free to customize further and send in any improvements,
+;; patches most welcome.
+;;
+;; MIT License Copyright (c) 2008 Marcus Crafter <[email protected]>
+;; Credits due to the excellent TextMate Twilight theme
+;;
+;; Thanks to Travis Jeffery for ido-mode and fixes to the minibuffer-prompt to fit in with the rest of the theme
+;;
+
+(defun color-theme-twilight ()
+ "Color theme by Marcus Crafter, based off the TextMate Twilight theme, created 2008-04-18"
+ (interactive)
+ (color-theme-install
+ '(color-theme-twilight
+ ((background-color . "#000000")
+ (background-mode . dark)
+ (border-color . "black")
+ (cursor-color . "#A7A7A7")
+ (foreground-color . "#F8F8F8")
+ (mouse-color . "sienna1"))
+ (default ((t (:background "#000000" :foreground "#CACACA"))))
+ (blue ((t (:foreground "blue"))))
+ (border-glyph ((t (nil))))
+ (buffers-tab ((t (:background "#000000" :foreground "#CACACA"))))
+ (font-lock-builtin-face ((t (:foreground "#CACACA"))))
+ (font-lock-comment-face ((t (:foreground "#5F5A60"))))
+ (font-lock-constant-face ((t (:foreground "#CF6A4C"))))
+ (font-lock-doc-string-face ((t (:foreground "DarkOrange"))))
+ (font-lock-function-name-face ((t (:foreground "#9B703F"))))
+ (font-lock-keyword-face ((t (:foreground "#CDA869"))))
+ (font-lock-preprocessor-face ((t (:foreground "Aquamarine"))))
+ (font-lock-reference-face ((t (:foreground "SlateBlue"))))
+
+ (font-lock-regexp-grouping-backslash ((t (:foreground "#E9C062"))))
+ (font-lock-regexp-grouping-construct ((t (:foreground "red"))))
+
+ (minibuffer-prompt ((t (:foreground "#5F5A60"))))
+ (ido-subdir ((t (:foreground "#CF6A4C"))))
+ (ido-first-match ((t (:foreground "#8F9D6A"))))
+ (ido-only-match ((t (:foreground "#8F9D6A"))))
+ (mumamo-background-chunk-submode ((t (:background "#222222"))))
+
+ (font-lock-string-face ((t (:foreground "#8F9D6A"))))
+ (font-lock-type-face ((t (:foreground "#9B703F"))))
+ (font-lock-variable-name-face ((t (:foreground "#7587A6"))))
+ (font-lock-warning-face ((t (:background "#EE799F" :foreground "red"))))
+ (gui-element ((t (:background "#D4D0C8" :foreground "black"))))
+ (region ((t (:background "#27292A"))))
+ (mode-line ((t (:background "grey75" :foreground "black"))))
+ (highlight ((t (:background "#111111"))))
+ (highline-face ((t (:background "SeaGreen"))))
+ (left-margin ((t (nil))))
+ (text-cursor ((t (:background "yellow" :foreground "black"))))
+ (toolbar ((t (nil))))
+ (underline ((nil (:underline nil))))
+ (zmacs-region ((t (:background "snow" :foreground "blue")))))))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/thirdparty/pretty-mode.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,302 @@
+;;; -*- coding: utf-8 -*-
+;; Minor mode for redisplaying parts of the buffer as pretty symbols
+;; originally modified from Trent Buck's version at http://paste.lisp.org/display/42335,2/raw
+;; Also includes code from `sml-mode'
+;; See also http://www.emacswiki.org/cgi-bin/wiki/PrettyLambda
+;; written by Arthur Danskin <[email protected]>
+;;
+;; to install:
+;; (require 'pretty-mode)
+;; (global-pretty-mode 1)
+;; or
+;; (add-hook 'my-pretty-language-hook 'turn-on-pretty-mode)
+
+
+(require 'cl)
+
+;; modified from `sml-mode'
+(defun pretty-font-lock-compose-symbol (alist)
+ "Compose a sequence of ascii chars into a symbol."
+ (let* ((start (match-beginning 0))
+ (end (match-end 0))
+ (syntax (char-syntax (char-after start))))
+ (if (or (if (eq syntax ?w)
+ (or (eq (char-syntax (char-before start)) ?w)
+ (eq (char-syntax (char-after end)) ?w))
+ (memq (char-syntax (char-before start)) '(?. ?\\)))
+ (memq (get-text-property start 'face)
+ '(font-lock-doc-face font-lock-string-face
+ font-lock-comment-face)))
+ (remove-text-properties start end '(composition))
+ (compose-region start end (cdr (assoc (match-string 0) alist)))
+ ))
+ nil)
+
+(defvar pretty-interaction-mode-alist
+ '((inferior-scheme-mode . scheme-mode)
+ (lisp-interaction-mode . emacs-lisp-mode)
+ (inferior-lisp-mode . lisp-mode)
+ (inferior-ess-mode . ess-mode)
+ (inf-haskell-mode . haskell-mode)
+ (inferior-erlang-mode . erlang-mode)
+ (tuareg-interactive-mode . tuareg-mode)
+ (inferior-python-mode . python-mode)
+ (inferior-octave-mode . octave-mode)
+ (inferior-ruby-mode . ruby-mode))
+ "Alist mapping from inferior process interaction modes to their
+ corresponding script editing modes.")
+
+
+(defun pretty-font-lock-keywords (alist)
+ "Return a `font-lock-keywords' style entry for replacing
+regular expressions with symbols. ALIST has the form ((STRING .
+REPLACE-CHAR) ...)."
+ (when alist
+ `((,(regexp-opt (mapcar 'car alist))
+ (0 (pretty-font-lock-compose-symbol
+ ',alist))))))
+
+(defun pretty-keywords (&optional mode)
+ "Return the font-lock keywords for MODE, or the current mode if
+MODE is nil. Return nil if there are no keywords."
+ (let* ((mode (or mode major-mode))
+ (kwds (cdr-safe
+ (or (assoc mode pretty-patterns)
+ (assoc (cdr-safe
+ (assoc mode pretty-interaction-mode-alist))
+ pretty-patterns)))))
+ (pretty-font-lock-keywords kwds)))
+
+(defgroup pretty nil "Minor mode for replacing text with symbols "
+ :group 'faces)
+
+(define-minor-mode pretty-mode
+ "Toggle Pretty minor mode.
+With arg, turn Pretty minor mode on if arg is positive, off otherwise.
+
+Pretty mode builds on `font-lock-mode'. Instead of highlighting
+keywords, it replaces them with symbols. For example, lambda is
+displayed as λ in lisp modes."
+ :group 'pretty
+ ; :lighter " λ"
+ (if pretty-mode
+ (progn
+ (font-lock-add-keywords nil (pretty-keywords) t)
+ (font-lock-fontify-buffer))
+ (font-lock-remove-keywords nil (pretty-keywords))
+ (remove-text-properties (point-min) (point-max) '(composition nil))))
+
+(defun turn-on-pretty-if-desired ()
+ "Turn on `pretty-mode' if the current major mode supports it."
+ (if (pretty-keywords)
+ (pretty-mode 1)))
+
+(define-globalized-minor-mode global-pretty-mode
+ pretty-mode turn-on-pretty-if-desired
+ :init-value t)
+
+(defun turn-off-pretty-mode ()
+ (interactive)
+ (pretty-mode -1))
+
+
+(defun turn-on-pretty-mode ()
+ (interactive)
+ (pretty-mode +1))
+
+(defun pretty-compile-patterns (patterns)
+ "Set pretty patterns in a convenient way.
+
+PATTERNS should be of the form ((GLYPH (REGEXP MODE ...) ...)
+...). GLYPH should be a character. MODE should be the name of a
+major mode without the \"-mode\". Returns patterns in the form
+expected by `pretty-patterns'"
+ (let ((pretty-patterns))
+ (loop for (glyph . pairs) in patterns do
+ (loop for (regexp . major-modes) in pairs do
+ (loop for mode in major-modes do
+ (let* ((mode (intern (concat (symbol-name mode)
+ "-mode")))
+ (assoc-pair (assoc mode pretty-patterns))
+
+ (entry (cons regexp glyph)))
+ (if assoc-pair
+ (push entry (cdr assoc-pair))
+ (push (cons mode (list entry))
+ pretty-patterns))))))
+ pretty-patterns))
+
+;;; (setq-default pretty-patterns pretty-patterns-default)
+(defconst pretty-patterns-default
+ (let* ((lispy '(scheme emacs-lisp lisp))
+ (mley '(tuareg haskell sml erlang))
+ (c-like '(c c++ perl sh python java ess ruby))
+ (all (append lispy mley c-like (list 'octave))))
+ (pretty-compile-patterns
+ `(
+ (?≠ ("!=" ,@c-like scheme octave)
+ ("<>" tuareg octave)
+ ("~=" octave)
+ ("/=" haskell)
+ ("=/=" erlang))
+ (?≤ ("<=" ,@all))
+ (?≤ ("=<" erlang))
+ (?λ ("fun" erlang))
+ (?≥ (">=" ,@all))
+ (?← ("<-" ,@mley ess)
+ ("!" erlang))
+ (?→ ("->" ,@mley ess c c++ perl))
+ (?↑ ("\\^" tuareg))
+ (?⇒ ("=>" sml perl ruby))
+ (?≡ ("==" ,@c-like erlang haskell))
+ (?∀ ("BOOST_FOREACH" c++))
+ (?∷ ("::" ,@all))
+ (?√ ("sqrt" ,@all))
+ (?∑ ("sum" python))
+
+ (?α ("alpha" ,@all))
+ (?Α ("Alpha" ,@all))
+
+ (?β ("beta" ,@all))
+ (?Β ("Beta" ,@all))
+
+ (?γ ("gamma" ,@all))
+ (?Γ ("Gamma" ,@all))
+
+ (?δ ("delta" ,@all))
+ (?Δ ("Delta" ,@all))
+
+ (?ε ("epsilon" ,@all))
+ (?Ε ("epsilon" ,@all))
+
+ (?ζ ("zeta" ,@all))
+ (?Ζ ("Zeta" ,@all))
+
+ (?η ("eta" ,@all))
+ (?Η ("Eta" ,@all))
+
+ (?θ ("theta" ,@all))
+ (?Θ ("Theta" ,@all))
+
+ (?ι ("iota" ,@all))
+ (?Ι ("Iota" ,@all))
+
+ (?κ ("kappa" ,@all))
+ (?K ("Kappa" ,@all))
+
+ (?λ ("lambda" ,@all))
+ (?Λ ("Lambda" ,@all))
+
+ (?μ ("mu" ,@all))
+ (?Μ ("Mu" ,@all))
+
+ (?ν ("nu" ,@all))
+ (?Ν ("Nu" ,@all))
+
+ (?ν ("vega" ,@all))
+ (?ν ("Vega" ,@all))
+
+ (?ξ ("xi" ,@all))
+ (?Ξ ("Xi" ,@all))
+
+ (?ο ("omicron" ,@all))
+ (?Ο ("Omicron" ,@all))
+
+ (?π ("pi" ,@all))
+ (?Π ("pi" ,@all))
+
+ (?ρ ("rho" ,@all))
+ (?Ρ ("Rho" ,@all))
+
+ (?σ ("sigma" ,@all))
+ (?Σ ("Sigma" ,@all))
+
+ (?τ ("tau" ,@all))
+ (?Τ ("Tau" ,@all))
+
+ (?υ ("upsilon" ,@all))
+ (?Y ("Upsilon" ,@all))
+
+ (?φ ("phi" ,@all))
+ (?Φ ("Phi" ,@all))
+
+ (?χ ("chi" ,@all))
+ (?Χ ("Chi" ,@all))
+
+ (?ψ ("psi" ,@all))
+ (?Ψ ("Psi" ,@all))
+
+ (?ω ("omega" ,@all))
+ (?Ω ("Omega" ,@all))
+
+ (?² ("**2" python tuareg octave))
+ (?³ ("**3" python tuareg octave))
+ (?ⁿ ("**n" python tuareg octave))
+ (?ₐ ("[a]" ,@c-like))
+ (?ₓ ("[x]" ,@c-like))
+ (?₀ ("[0]" ,@c-like)
+ ("/0" erlang))
+ (?₁ ("[1]" ,@c-like)
+ ("/1" erlang))
+ (?₂ ("[2]" ,@c-like)
+ ("/2" erlang))
+ (?₃ ("[3]" ,@c-like)
+ ("/3" erlang))
+ (?₄ ("[4]" ,@c-like)
+ ("/4" erlang))
+ (?₅ ("[5]" ,@c-like)
+ ("/5" erlang))
+ (?₆ ("[6]" ,@c-like)
+ ("/6" erlang))
+ (?₇ ("[7]" ,@c-like)
+ ("/7" erlang))
+ (?₈ ("[8]" ,@c-like)
+ ("/8" erlang))
+ (?₉ ("[9]" ,@c-like)
+ ("/9" erlang))
+ (?∧ ("\\<And\\>" emacs-lisp lisp python)
+ ("\\<andalso\\>" sml erlang)
+ ("&&" c c++ perl haskell))
+ (?∨ ("\\<or\\>" emacs-lisp lisp)
+ ("\\<orelse\\>" sml erlang)
+ ("||" c c++ perl haskell erlang))
+ (?¬ ("!" c c++))
+ )))
+ "default value for `pretty-patterns'")
+
+;; TODO fix type
+(defcustom pretty-patterns pretty-patterns-default
+ "*List of pretty patterns.
+
+Should be a list of the form ((MODE ((REGEXP . GLYPH) ...)) ...)"
+ :group 'pretty
+ :type '(alist :key-type variable :value-type (alist :key-type (string) :value-type (character))))
+
+
+(defun pretty-add-keywords (mode keywords)
+ "Add pretty character KEYWORDS to MODE
+
+MODE should be a symbol, the major mode command name, such as
+`c-mode' or nil. If nil, pretty keywords are added to the current
+buffer. KEYWORDS should be a list where each element has the
+form (REGEXP . CHAR). REGEXP will be replaced with CHAR in the
+relevant buffer(s)."
+ (font-lock-add-keywords
+ mode (mapcar (lambda (kw) `((,(car kw)
+ (0 (prog1 nil
+ (compose-region (match-beginning 0)
+ (match-end 0)
+ ,(cdr kw)))))))
+ keywords)))
+
+(defun pretty-regexp (regexp glyph)
+ "Replace REGEXP with GLYPH in buffer."
+ (interactive "MRegexp to replace:
+MCharacter to replace with: ")
+ (pretty-add-keywords nil `((,regexp . ,(string-to-char glyph))))
+ (font-lock-fontify-buffer))
+
+
+
+
+(provide 'pretty-mode)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/thirdparty/vala-mode.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,395 @@
+;;; vala-mode.el --- Vala mode derived mode
+
+;; Author: 2005 Dylan R. E. Moonfire
+;; 2008 Étienne BERSAC
+;; Maintainer: Étienne BERSAC <[email protected]>
+;; Created: 2008 May the 4th
+;; Modified: May 2008
+;; Version: 0.1
+;; Keywords: vala languages oop
+
+;; 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 of the License, or
+;; (at your option) any later version.
+;;
+;; 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 this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; See http://live.gnome.org/Vala for details about Vala language.
+;;
+;; This is a separate mode to implement the Vala constructs and
+;; font-locking. It is mostly the csharp-mode from
+;; http://mfgames.com/linux/csharp-mode with vala specific keywords
+;; and filename suffixes.
+;;
+;; Note: The interface used in this file requires CC Mode 5.30 or
+;; later.
+
+;;; .emacs (don't put in (require 'vala-mode))
+;; (autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
+;; (setq auto-mode-alist
+;; (append '(("\\.vala$" . vala-mode)) auto-mode-alist))
+
+;;; Versions:
+;;
+;; 0.1 : Initial version based on csharp-mode
+;;
+
+;; This is a copy of the function in cc-mode which is used to handle
+;; the eval-when-compile which is needed during other times.
+(defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
+ ;; See cc-langs.el, a direct copy.
+ (unless (listp (car-safe ops))
+ (setq ops (list ops)))
+ (cond ((eq opgroup-filter t)
+ (setq opgroup-filter (lambda (opgroup) t)))
+ ((not (functionp opgroup-filter))
+ (setq opgroup-filter `(lambda (opgroup)
+ (memq opgroup ',opgroup-filter)))))
+ (cond ((eq op-filter t)
+ (setq op-filter (lambda (op) t)))
+ ((stringp op-filter)
+ (setq op-filter `(lambda (op)
+ (string-match ,op-filter op)))))
+ (unless xlate
+ (setq xlate 'identity))
+ (c-with-syntax-table (c-lang-const c-mode-syntax-table)
+ (delete-duplicates
+ (mapcan (lambda (opgroup)
+ (when (if (symbolp (car opgroup))
+ (when (funcall opgroup-filter (car opgroup))
+ (setq opgroup (cdr opgroup))
+ t)
+ t)
+ (mapcan (lambda (op)
+ (when (funcall op-filter op)
+ (let ((res (funcall xlate op)))
+ (if (listp res) res (list res)))))
+ opgroup)))
+ ops)
+ :test 'equal)))
+
+;; This inserts the bulk of the code.
+(require 'cc-mode)
+
+;; These are only required at compile time to get the sources for the
+;; language constants. (The cc-fonts require and the font-lock
+;; related constants could additionally be put inside an
+;; (eval-after-load "font-lock" ...) but then some trickery is
+;; necessary to get them compiled.)
+(eval-when-compile
+ (let ((load-path
+ (if (and (boundp 'byte-compile-dest-file)
+ (stringp byte-compile-dest-file))
+ (cons (file-name-directory byte-compile-dest-file) load-path)
+ load-path)))
+ (load "cc-mode" nil t)
+ (load "cc-fonts" nil t)
+ (load "cc-langs" nil t)))
+
+(eval-and-compile
+ ;; Make our mode known to the language constant system. Use Java
+ ;; mode as the fallback for the constants we don't change here.
+ ;; This needs to be done also at compile time since the language
+ ;; constants are evaluated then.
+ (c-add-language 'vala-mode 'java-mode))
+
+;; Java uses a series of regexes to change the font-lock for class
+;; references. The problem comes in because Java uses Pascal (leading
+;; space in names, SomeClass) for class and package names, but
+;; Camel-casing (initial lowercase, upper case in words,
+;; i.e. someVariable) for variables.
+;;(error (byte-compile-dest-file))
+;;(error (c-get-current-file))
+(c-lang-defconst c-opt-after-id-concat-key
+ vala (if (c-lang-const c-opt-identifier-concat-key)
+ (c-lang-const c-symbol-start)))
+
+(c-lang-defconst c-basic-matchers-before
+ vala `(
+;;;; Font-lock the attributes by searching for the
+;;;; appropriate regex and marking it as TODO.
+ ;;,`(,(concat "\\(" vala-attribute-regex "\\)")
+ ;; 0 font-lock-function-name-face)
+
+ ;; Put a warning face on the opener of unclosed strings that
+ ;; can't span lines. Later font
+ ;; lock packages have a `font-lock-syntactic-face-function' for
+ ;; this, but it doesn't give the control we want since any
+ ;; fontification done inside the function will be
+ ;; unconditionally overridden.
+ ,(c-make-font-lock-search-function
+ ;; Match a char before the string starter to make
+ ;; `c-skip-comments-and-strings' work correctly.
+ (concat ".\\(" c-string-limit-regexp "\\)")
+ '((c-font-lock-invalid-string)))
+
+ ;; Fontify keyword constants.
+ ,@(when (c-lang-const c-constant-kwds)
+ (let ((re (c-make-keywords-re nil
+ (c-lang-const c-constant-kwds))))
+ `((eval . (list ,(concat "\\<\\(" re "\\)\\>")
+ 1 c-constant-face-name)))))
+
+ ;; Fontify all keywords except the primitive types.
+ ,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
+ 1 font-lock-keyword-face)
+
+ ;; Fontify leading identifiers in fully
+ ;; qualified names like "Foo.Bar".
+ ,@(when (c-lang-const c-opt-identifier-concat-key)
+ `((,(byte-compile
+ `(lambda (limit)
+ (while (re-search-forward
+ ,(concat "\\(\\<" ; 1
+ "\\(" (c-lang-const c-symbol-key)
+ "\\)" ; 2
+ "[ \t\n\r\f\v]*"
+ (c-lang-const
+ c-opt-identifier-concat-key)
+ "[ \t\n\r\f\v]*"
+ "\\)"
+ "\\("
+ (c-lang-const
+ c-opt-after-id-concat-key)
+ "\\)")
+ limit t)
+ (unless (progn
+ (goto-char (match-beginning 0))
+ (c-skip-comments-and-strings limit))
+ (or (get-text-property (match-beginning 2) 'face)
+ (c-put-font-lock-face (match-beginning 2)
+ (match-end 2)
+ c-reference-face-name))
+ (goto-char (match-end 1)))))))))
+ ))
+
+;; Vala does not allow a leading qualifier operator. It also doesn't
+;; allow the ".*" construct of Java. So, we redo this regex without
+;; the "\\|\\*" regex.
+(c-lang-defconst c-identifier-key
+ vala (concat "\\(" (c-lang-const c-symbol-key) "\\)" ; 1
+ (concat "\\("
+ "[ \t\n\r\f\v]*"
+ (c-lang-const c-opt-identifier-concat-key)
+ "[ \t\n\r\f\v]*"
+ (concat "\\("
+ "\\(" (c-lang-const c-symbol-key) "\\)"
+ "\\)")
+ "\\)*")))
+
+;; Vala has a few rules that are slightly different than Java for
+;; operators. This also removed the Java's "super" and replaces it
+;; with the Vala's "base".
+(c-lang-defconst c-operators
+ vala `((prefix "base")))
+
+;; Vala directives ?
+;; (c-lang-defconst c-opt-cpp-prefix
+;; csharp "^\\s *#.*")
+
+
+;; Vala uses the following assignment operators
+(c-lang-defconst c-assignment-operators
+ vala '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<="
+ "&=" "^=" "|=" "++" "--"))
+
+;; This defines the primative types for Vala
+(c-lang-defconst c-primitive-type-kwds
+ vala '("void" "char" "int" "float" "double" "string"))
+
+;; The keywords that define that the following is a type, such as a
+;; class definition.
+(c-lang-defconst c-type-prefix-kwds
+ vala '("class" "interface" "struct" "enum" "signal"))
+
+;; Type modifier keywords. They appear anywhere in types, but modifiy
+;; instead create one.
+(c-lang-defconst c-type-modifier-kwds
+ vala '("const"))
+
+;; Structures that are similiar to classes.
+(c-lang-defconst c-class-decl-kwds
+ vala '("class" "interface"))
+
+;; The various modifiers used for class and method descriptions.
+(c-lang-defconst c-modifier-kwds
+ vala '("public" "partial" "private" "const" "abstract"
+ "protected" "ref" "in" "out" "static" "virtual"
+ "override" "params" "internal" "weak" "owned"
+ "unowned"))
+
+;; We don't use the protection level stuff because it breaks the
+;; method indenting. Not sure why, though.
+(c-lang-defconst c-protection-kwds
+ vala nil)
+
+;; Define the keywords that can have something following after them.
+(c-lang-defconst c-type-list-kwds
+ vala '("struct" "class" "interface" "is" "as"
+ "delegate" "event" "set" "get" "add" "remove"
+ "callback" "signal" "var" "default"))
+
+;; This allows the classes after the : in the class declartion to be
+;; fontified.
+(c-lang-defconst c-typeless-decl-kwds
+ vala '(":"))
+
+;; Sets up the enum to handle the list properly
+(c-lang-defconst c-brace-list-decl-kwds
+ vala '("enum" "errordomain"))
+
+;; We need to remove Java's package keyword
+(c-lang-defconst c-ref-list-kwds
+ vala '("using" "namespace" "construct"))
+
+;; Follow-on blocks that don't require a brace
+(c-lang-defconst c-block-stmt-2-kwds
+ vala '("for" "if" "switch" "while" "catch" "foreach" "lock"))
+
+;; Statements that break out of braces
+(c-lang-defconst c-simple-stmt-kwds
+ vala '("return" "continue" "break" "throw"))
+
+;; Statements that allow a label
+;; TODO?
+(c-lang-defconst c-before-label-kwds
+ vala nil)
+
+;; Constant keywords
+(c-lang-defconst c-constant-kwds
+ vala '("true" "false" "null"))
+
+;; Keywords that start "primary expressions."
+(c-lang-defconst c-primary-expr-kwds
+ vala '("this" "base"))
+
+;; We need to treat namespace as an outer block to class indenting
+;; works properly.
+(c-lang-defconst c-other-block-decl-kwds
+ vala '("namespace"))
+
+;; We need to include the "in" for the foreach
+(c-lang-defconst c-other-kwds
+ vala '("in" "sizeof" "typeof"))
+
+(require 'cc-awk)
+
+(c-lang-defconst c-at-vsemi-p-fn
+ vala 'c-awk-at-vsemi-p)
+
+
+(defcustom vala-font-lock-extra-types nil
+ "*List of extra types (aside from the type keywords) to recognize in Vala mode.
+Each list item should be a regexp matching a single identifier.")
+
+(defconst vala-font-lock-keywords-1 (c-lang-const c-matchers-1 vala)
+ "Minimal highlighting for Vala mode.")
+
+(defconst vala-font-lock-keywords-2 (c-lang-const c-matchers-2 vala)
+ "Fast normal highlighting for Vala mode.")
+
+(defconst vala-font-lock-keywords-3 (c-lang-const c-matchers-3 vala)
+ "Accurate normal highlighting for Vala mode.")
+
+(defvar vala-font-lock-keywords vala-font-lock-keywords-3
+ "Default expressions to highlight in Vala mode.")
+
+(defvar vala-mode-syntax-table
+ nil
+ "Syntax table used in vala-mode buffers.")
+(or vala-mode-syntax-table
+ (setq vala-mode-syntax-table
+ (funcall (c-lang-const c-make-mode-syntax-table vala))))
+
+(defvar vala-mode-abbrev-table nil
+ "Abbreviation table used in vala-mode buffers.")
+(c-define-abbrev-table 'vala-mode-abbrev-table
+ ;; Keywords that if they occur first on a line
+ ;; might alter the syntactic context, and which
+ ;; therefore should trig reindentation when
+ ;; they are completed.
+ '(("else" "else" c-electric-continued-statement 0)
+ ("while" "while" c-electric-continued-statement 0)
+ ("catch" "catch" c-electric-continued-statement 0)
+ ("finally" "finally" c-electric-continued-statement 0)))
+
+(defvar vala-mode-map (let ((map (c-make-inherited-keymap)))
+ ;; Add bindings which are only useful for Vala
+ map)
+ "Keymap used in vala-mode buffers.")
+
+;;(easy-menu-define vala-menu vala-mode-map "Vala Mode Commands"
+;; ;; Can use `vala' as the language for `c-mode-menu'
+;; ;; since its definition covers any language. In
+;; ;; this case the language is used to adapt to the
+;; ;; nonexistence of a cpp pass and thus removing some
+;; ;; irrelevant menu alternatives.
+;; (cons "Vala" (c-lang-const c-mode-menu vala)))
+
+;;; Autoload mode trigger
+(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
+(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
+
+;; Custom variables
+(defcustom vala-mode-hook nil
+ "*Hook called by `vala-mode'."
+ :type 'hook
+ :group 'c)
+
+;;; The entry point into the mode
+;;;###autoload
+(defun vala-mode ()
+ "Major mode for editing Vala code.
+This is a simple example of a separate mode derived from CC Mode
+to support a language with syntax similar to
+C#/C/C++/ObjC/Java/IDL/Pike.
+
+The hook `c-mode-common-hook' is run with no args at mode
+initialization, then `vala-mode-hook'.
+
+Key bindings:
+\\{vala-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (c-initialize-cc-mode t)
+ (set-syntax-table vala-mode-syntax-table)
+ (setq major-mode 'vala-mode
+ mode-name "Vala"
+ local-abbrev-table vala-mode-abbrev-table
+ abbrev-mode t)
+ (use-local-map c-mode-map)
+ ;; `c-init-language-vars' is a macro that is expanded at compile
+ ;; time to a large `setq' with all the language variables and their
+ ;; customized values for our language.
+ (c-init-language-vars vala-mode)
+ ;; `c-common-init' initializes most of the components of a CC Mode
+ ;; buffer, including setup of the mode menu, font-lock, etc.
+ ;; There's also a lower level routine `c-basic-common-init' that
+ ;; only makes the necessary initialization to get the syntactic
+ ;; analysis and similar things working.
+ (c-common-init 'vala-mode)
+ ;;(easy-menu-add vala-menu)
+ (c-set-style "linux")
+ (setq indent-tabs-mode t)
+ (setq c-basic-offset 4)
+ (setq tab-width 4)
+ (c-toggle-auto-newline -1)
+ (c-toggle-hungry-state -1)
+ (run-hooks 'c-mode-common-hook)
+ (run-hooks 'vala-mode-hook)
+ (c-update-modeline))
+
+(provide 'vala-mode)
+
+;;; vala-mode.el ends here
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/thirdparty/zencoding-mode.el Sat May 14 14:47:51 2011 -0500
@@ -0,0 +1,798 @@
+;;; zencoding-mode.el --- Unfold CSS-selector-like expressions to markup
+;;
+;; Copyright (C) 2009, Chris Done
+;;
+;; Author: Chris Done <[email protected]>
+(defconst zencoding-mode:version "0.5")
+;; Last-Updated: 2009-11-20 Fri
+;; 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
+;;
+;; 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:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 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))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Zen coding parsers
+
+(defun zencoding-expr (input)
+ "Parse a zen coding expression. This pretty much defines precedence."
+ (zencoding-run zencoding-siblings
+ it
+ (zencoding-run zencoding-parent-child
+ it
+ (zencoding-run zencoding-multiplier
+ it
+ (zencoding-run zencoding-pexpr
+ it
+ (zencoding-run zencoding-tag
+ it
+ '(error "no match, expecting ( or a-zA-Z0-9")))))))
+
+(defun zencoding-multiplier (input)
+ (zencoding-por zencoding-pexpr zencoding-tag
+ (let ((multiplier expr))
+ (zencoding-parse "\\*\\([0-9]+\\)" 2 "*n where n is a number"
+ (let ((multiplicand (read (elt it 1))))
+ `((list ,(make-list multiplicand multiplier)) . ,input))))
+ '(error "expected *n multiplier")))
+
+(defun zencoding-tag (input)
+ "Parse a tag."
+ (zencoding-run zencoding-tagname
+ (let ((result it)
+ (tagname (cdr expr)))
+ (zencoding-pif (zencoding-run zencoding-identifier
+ (zencoding-tag-classes
+ `(tag ,tagname ((id ,(cddr expr)))) input)
+ (zencoding-tag-classes `(tag ,tagname ()) input))
+ (let ((expr-and-input it) (expr (car it)) (input (cdr it)))
+ (zencoding-pif (zencoding-tag-props expr input)
+ it
+ expr-and-input))))
+ '(error "expected tagname")))
+
+(defun zencoding-tag-props (tag input)
+ (zencoding-run zencoding-props
+ (let ((tagname (cadr tag))
+ (existing-props (caddr tag))
+ (props (cdr expr)))
+ `((tag ,tagname
+ ,(append existing-props props))
+ . ,input))))
+
+(defun zencoding-props (input)
+ "Parse many props."
+ (zencoding-run zencoding-prop
+ (zencoding-pif (zencoding-props input)
+ `((props . ,(cons expr (cdar it))) . ,(cdr it))
+ `((props . ,(list expr)) . ,input))))
+
+(defun zencoding-prop (input)
+ (zencoding-parse
+ " " 1 "space"
+ (zencoding-run
+ zencoding-name
+ (let ((name (cdr expr)))
+ (zencoding-parse "=\\([^\\,\\+\\>\\ )]*\\)" 2
+ "=property value"
+ (let ((value (elt it 1))
+ (input (elt it 2)))
+ `((,(read name) ,value) . ,input)))))))
+
+(defun zencoding-tag-classes (tag input)
+ (zencoding-run zencoding-classes
+ (let ((tagname (cadr tag))
+ (props (caddr tag))
+ (classes `(class ,(mapconcat
+ (lambda (prop)
+ (cdadr prop))
+ (cdr expr)
+ " "))))
+ `((tag ,tagname ,(append props (list classes))) . ,input))
+ `(,tag . ,input)))
+
+(defun zencoding-tagname (input)
+ "Parse a tagname a-zA-Z0-9 tagname (e.g. html/head/xsl:if/br)."
+ (zencoding-parse "\\([a-zA-Z][a-zA-Z0-9:-]*\\)" 2 "tagname, a-zA-Z0-9"
+ `((tagname . ,(elt it 1)) . ,input)))
+
+(defun zencoding-pexpr (input)
+ "A zen coding expression with parentheses around it."
+ (zencoding-parse "(" 1 "("
+ (zencoding-run zencoding-expr
+ (zencoding-aif (zencoding-regex ")" input '(0 1))
+ `(,expr . ,(elt it 1))
+ '(error "expecting `)'")))))
+
+(defun zencoding-parent-child (input)
+ "Parse an tag>e expression, where `n' is an tag and `e' is any
+ expression."
+ (zencoding-run zencoding-multiplier
+ (let* ((items (cadr expr))
+ (rest (zencoding-child-sans expr input)))
+ (if (not (eq (car rest) 'error))
+ (let ((child (car rest))
+ (input (cdr rest)))
+ (cons (cons 'list
+ (cons (mapcar (lambda (parent)
+ `(parent-child ,parent ,child))
+ items)
+ nil))
+ input))
+ '(error "expected child")))
+ (zencoding-run zencoding-tag
+ (zencoding-child expr input)
+ '(error "expected parent"))))
+
+(defun zencoding-child-sans (parent input)
+ (zencoding-parse ">" 1 ">"
+ (zencoding-run zencoding-expr
+ it
+ '(error "expected child"))))
+
+(defun zencoding-child (parent input)
+ (zencoding-parse ">" 1 ">"
+ (zencoding-run zencoding-expr
+ (let ((child expr))
+ `((parent-child ,parent ,child) . ,input))
+ '(error "expected child"))))
+
+(defun zencoding-sibling (input)
+ (zencoding-por zencoding-pexpr zencoding-multiplier
+ it
+ (zencoding-run zencoding-tag
+ it
+ '(error "expected sibling"))))
+
+(defun zencoding-siblings (input)
+ "Parse an e+e expression, where e is an tag or a pexpr."
+ (zencoding-run zencoding-sibling
+ (let ((parent expr))
+ (zencoding-parse "\\+" 1 "+"
+ (zencoding-run zencoding-expr
+ (let ((child expr))
+ `((zencoding-siblings ,parent ,child) . ,input))
+ '(error "expected second sibling"))))
+ '(error "expected first sibling")))
+
+(defun zencoding-name (input)
+ "Parse a class or identifier name, e.g. news, footer, mainimage"
+ (zencoding-parse "\\([a-zA-Z][a-zA-Z0-9-_]*\\)" 2 "class or identifer name"
+ `((name . ,(elt it 1)) . ,input)))
+
+(defun zencoding-class (input)
+ "Parse a classname expression, e.g. .foo"
+ (zencoding-parse "\\." 1 "."
+ (zencoding-run zencoding-name
+ `((class ,expr) . ,input)
+ '(error "expected class name"))))
+
+(defun zencoding-identifier (input)
+ "Parse an identifier expression, e.g. #foo"
+ (zencoding-parse "#" 1 "#"
+ (zencoding-run zencoding-name
+ `((identifier . ,expr) . ,input))))
+
+(defun zencoding-classes (input)
+ "Parse many classes."
+ (zencoding-run zencoding-class
+ (zencoding-pif (zencoding-classes input)
+ `((classes . ,(cons expr (cdar it))) . ,(cdr it))
+ `((classes . ,(list expr)) . ,input))
+ '(error "expected class")))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Zen coding transformer from AST to HTML
+
+;; Fix-me: make mode specific
+(defvar zencoding-single-tags
+ '("br"
+ "img"))
+
+(defvar zencoding-inline-tags
+ '("a"
+ "abbr"
+ "acronym"
+ "cite"
+ "code"
+ "dfn"
+ "em"
+ "h1" "h2" "h3" "h4" "h5" "h6"
+ "kbd"
+ "q"
+ "span"
+ "strong"
+ "var"))
+
+(defvar zencoding-block-tags
+ '("p"))
+
+;; li
+;; a
+;; em
+;; p
+
+(defvar zencoding-leaf-function nil
+ "Function to execute when expanding a leaf node in the
+ Zencoding AST.")
+
+(defun zencoding-make-tag (tag &optional content)
+ (let* ((name (car tag))
+ (lf (if
+ (or
+ (member name zencoding-block-tags)
+ (and
+ (> (length name) 1)
+ (not (member name zencoding-inline-tags))
+ ))
+ "\n" ""))
+ (single (member name zencoding-single-tags))
+ (props (apply 'concat (mapcar
+ (lambda (prop)
+ (concat " " (symbol-name (car prop))
+ "=\"" (cadr prop) "\""))
+ (cadr tag)))))
+ (concat lf "<" name props ">" lf
+ (if single
+ ""
+ (concat
+ (if content content
+ (if zencoding-leaf-function
+ (funcall zencoding-leaf-function)
+ ""))
+ lf "</" name ">")))))
+
+(defun zencoding-transform (ast)
+ (let ((type (car ast)))
+ (cond
+ ((eq type 'list)
+ (mapconcat 'zencoding-transform (cadr ast) ""))
+ ((eq type 'tag)
+ (zencoding-make-tag (cdr ast)))
+ ((eq type 'parent-child)
+ (let ((parent (cdadr ast))
+ (children (zencoding-transform (caddr ast))))
+ (zencoding-make-tag parent children)))
+ ((eq type 'zencoding-siblings)
+ (let ((sib1 (zencoding-transform (cadr ast)))
+ (sib2 (zencoding-transform (caddr ast))))
+ (concat sib1 sib2))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Test-cases
+
+(defun zencoding-test-cases ()
+ (let ((tests '(;; Tags
+ ("a" "<a></a>")
+ ("a.x" "<a class=\"x\"></a>")
+ ("a#q.x" "<a id=\"q\" class=\"x\"></a>")
+ ("a#q.x.y.z" "<a id=\"q\" class=\"x y z\"></a>")
+ ;; Siblings
+ ("a+b" "<a></a><b></b>")
+ ("a+b+c" "<a></a><b></b><c></c>")
+ ("a.x+b" "<a class=\"x\"></a><b></b>")
+ ("a#q.x+b" "<a id=\"q\" class=\"x\"></a><b></b>")
+ ("a#q.x.y.z+b" "<a id=\"q\" class=\"x y z\"></a><b></b>")
+ ("a#q.x.y.z+b#p.l.m.n" "<a id=\"q\" class=\"x y z\"></a><b id=\"p\" class=\"l m n\"></b>")
+ ;; Parent > child
+ ("a>b" "<a><b></b></a>")
+ ("a>b>c" "<a><b><c></c></b></a>")
+ ("a.x>b" "<a class=\"x\"><b></b></a>")
+ ("a#q.x>b" "<a id=\"q\" class=\"x\"><b></b></a>")
+ ("a#q.x.y.z>b" "<a id=\"q\" class=\"x y z\"><b></b></a>")
+ ("a#q.x.y.z>b#p.l.m.n" "<a id=\"q\" class=\"x y z\"><b id=\"p\" class=\"l m n\"></b></a>")
+ ("a>b+c" "<a><b></b><c></c></a>")
+ ("a>b+c>d" "<a><b></b><c><d></d></c></a>")
+ ;; Multiplication
+ ("a*1" "<a></a>")
+ ("a*2" "<a></a><a></a>")
+ ("a*2+b*2" "<a></a><a></a><b></b><b></b>")
+ ("a*2>b*2" "<a><b></b><b></b></a><a><b></b><b></b></a>")
+ ("a>b*2" "<a><b></b><b></b></a>")
+ ("a#q.x>b#q.x*2" "<a id=\"q\" class=\"x\"><b id=\"q\" class=\"x\"></b><b id=\"q\" class=\"x\"></b></a>")
+ ;; Properties
+ ("a x=y" "<a x=\"y\"></a>")
+ ("a x=y m=l" "<a x=\"y\" m=\"l\"></a>")
+ ("a#foo x=y m=l" "<a id=\"foo\" x=\"y\" m=\"l\"></a>")
+ ("a.foo x=y m=l" "<a class=\"foo\" x=\"y\" m=\"l\"></a>")
+ ("a#foo.bar.mu x=y m=l" "<a id=\"foo\" class=\"bar mu\" x=\"y\" m=\"l\"></a>")
+ ("a x=y+b" "<a x=\"y\"></a><b></b>")
+ ("a x=y+b x=y" "<a x=\"y\"></a><b x=\"y\"></b>")
+ ("a x=y>b" "<a x=\"y\"><b></b></a>")
+ ("a x=y>b x=y" "<a x=\"y\"><b x=\"y\"></b></a>")
+ ("a x=y>b x=y+c x=y" "<a x=\"y\"><b x=\"y\"></b><c x=\"y\"></c></a>")
+ ;; Parentheses
+ ("(a)" "<a></a>")
+ ("(a)+(b)" "<a></a><b></b>")
+ ("a>(b)" "<a><b></b></a>")
+ ("(a>b)>c" "<a><b></b></a>")
+ ("(a>b)+c" "<a><b></b></a><c></c>")
+ ("z+(a>b)+c+k" "<z></z><a><b></b></a><c></c><k></k>")
+ ("(a)*2" "<a></a><a></a>")
+ ("((a)*2)" "<a></a><a></a>")
+ ("((a)*2)" "<a></a><a></a>")
+ ("(a>b)*2" "<a><b></b></a><a><b></b></a>")
+ ("(a+b)*2" "<a></a><b></b><a></a><b></b>")
+ )))
+ (mapc (lambda (input)
+ (let ((expected (cadr input))
+ (actual (zencoding-transform (car (zencoding-expr (car input))))))
+ (if (not (equal expected actual))
+ (error (concat "Assertion " (car input) " failed:"
+ expected
+ " == "
+ actual)))))
+ tests)
+ (concat (number-to-string (length tests)) " tests performed. All OK.")))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Zencoding minor mode
+
+(defgroup zencoding nil
+ "Customization group for zencoding-mode."
+ :group 'convenience)
+
+(defun zencoding-expr-on-line ()
+ "Extract a zencoding expression and the corresponding bounds
+ for the current line."
+ (let* ((start (line-beginning-position))
+ (end (line-end-position))
+ (line (buffer-substring-no-properties start end))
+ (expr (zencoding-regex "\\([ \t]*\\)\\([^\n]+\\)" line 2)))
+ (if (first expr)
+ (list (first expr) start end))))
+
+(defun zencoding-prettify (markup indent)
+ (save-match-data
+ ;;(setq markup (replace-regexp-in-string "><" ">\n<" markup))
+ (setq markup (replace-regexp-in-string "\n\n" "\n" markup))
+ (setq markup (replace-regexp-in-string "^\n" "" markup)))
+ (with-temp-buffer
+ (indent-to indent)
+ (insert "<i></i>")
+ (insert "\n")
+ (let ((here (point)))
+ (insert markup)
+ (sgml-mode)
+ (indent-region here (point-max))
+ (buffer-substring-no-properties here (point-max)))))
+
+;;;###autoload
+(defun zencoding-expand-line (arg)
+ "Replace the current line's zencode expression with the corresponding expansion.
+If prefix ARG is given or region is visible call `zencoding-preview' to start an
+interactive preview.
+
+Otherwise expand line directly.
+
+For more information see `zencoding-mode'."
+ (interactive "P")
+ (let* ((here (point))
+ (preview (if zencoding-preview-default (not arg) arg))
+ (beg (if preview
+ (progn
+ (beginning-of-line)
+ (skip-chars-forward " \t")
+ (point))
+ (when mark-active (region-beginning))))
+ (end (if preview
+ (progn
+ (end-of-line)
+ (skip-chars-backward " \t")
+ (point))
+ (when mark-active (region-end)))))
+ (if beg
+ (progn
+ (goto-char here)
+ (zencoding-preview beg end))
+ (let ((expr (zencoding-expr-on-line)))
+ (if expr
+ (let* ((markup (zencoding-transform (car (zencoding-expr (first expr)))))
+ (pretty (zencoding-prettify markup (current-indentation))))
+ (save-excursion
+ (delete-region (second expr) (third expr))
+ (zencoding-insert-and-flash pretty))))))))
+
+(defvar zencoding-mode-keymap nil
+ "Keymap for zencode minor mode.")
+
+(if zencoding-mode-keymap
+ nil
+ (progn
+ (setq zencoding-mode-keymap (make-sparse-keymap))
+ (define-key zencoding-mode-keymap (kbd "<C-return>") 'zencoding-expand-line)))
+
+;;;###autoload
+(define-minor-mode zencoding-mode
+ "Minor mode for writing HTML and CSS markup.
+With zen coding for HTML and CSS you can write a line like
+
+ ul#name>li.item*2
+
+and have it expanded to
+
+ <ul id=\"name\">
+ <li class=\"item\"></li>
+ <li class=\"item\"></li>
+ </ul>
+
+This minor mode defines keys for quick access:
+
+\\{zencoding-mode-keymap}
+
+Home page URL `http://www.emacswiki.org/emacs/ZenCoding'.
+
+See also `zencoding-expand-line'."
+ :lighter " Zen"
+ :keymap zencoding-mode-keymap)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Zencoding yasnippet integration
+
+(defun zencoding-transform-yas (ast)
+ (let* ((leaf-count 0)
+ (zencoding-leaf-function
+ (lambda ()
+ (format "$%d" (incf leaf-count)))))
+ (zencoding-transform ast)))
+
+;;;###autoload
+(defun zencoding-expand-yas ()
+ (interactive)
+ (let ((expr (zencoding-expr-on-line)))
+ (if expr
+ (let* ((markup (zencoding-transform-yas (car (zencoding-expr (first expr)))))
+ (filled (replace-regexp-in-string "><" ">\n<" markup)))
+ (delete-region (second expr) (third expr))
+ (insert filled)
+ (indent-region (second expr) (point))
+ (yas/expand-snippet
+ (buffer-substring (second expr) (point))
+ (second expr) (point))))))
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Real-time preview
+;;
+
+;;;;;;;;;;
+;; Lennart's version
+
+(defvar zencoding-preview-input nil)
+(make-local-variable 'zencoding-preview-input)
+(defvar zencoding-preview-output nil)
+(make-local-variable 'zencoding-preview-output)
+(defvar zencoding-old-show-paren nil)
+(make-local-variable 'zencoding-old-show-paren)
+
+(defface zencoding-preview-input
+ '((default :box t :inherit secondary-selection))
+ "Face for preview input field."
+ :group 'zencoding)
+
+(defface zencoding-preview-output
+ '((default :inherit highlight))
+ "Face for preview output field."
+ :group 'zencoding)
+
+(defvar zencoding-preview-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "<return>") 'zencoding-preview-accept)
+ (define-key map [(control ?g)] 'zencoding-preview-abort)
+ map))
+
+(defun zencoding-preview-accept ()
+ (interactive)
+ (let ((ovli zencoding-preview-input))
+ (if (not (and (overlayp ovli)
+ (bufferp (overlay-buffer ovli))))
+ (message "Preview is not active")
+ (let* ((indent (current-indentation))
+ (markup (zencoding-preview-transformed indent)))
+ (when markup
+ (delete-region (line-beginning-position) (overlay-end ovli))
+ (zencoding-insert-and-flash markup)))))
+ (zencoding-preview-abort))
+
+(defvar zencoding-flash-ovl nil)
+(make-variable-buffer-local 'zencoding-flash-ovl)
+
+(defun zencoding-remove-flash-ovl (buf)
+ (with-current-buffer buf
+ (when (overlayp zencoding-flash-ovl)
+ (delete-overlay zencoding-flash-ovl))
+ (setq zencoding-flash-ovl nil)))
+
+(defcustom zencoding-preview-default t
+ "If non-nil then preview is the default action.
+This determines how `zencoding-expand-line' works by default."
+ :type 'boolean
+ :group 'zencoding)
+
+(defcustom zencoding-insert-flash-time 0.5
+ "Time to flash insertion.
+Set this to a negative number if you do not want flashing the
+expansion after insertion."
+ :type '(number :tag "Seconds")
+ :group 'zencoding)
+
+(defun zencoding-insert-and-flash (markup)
+ (zencoding-remove-flash-ovl (current-buffer))
+ (let ((here (point)))
+ (insert markup)
+ (setq zencoding-flash-ovl (make-overlay here (point)))
+ (overlay-put zencoding-flash-ovl 'face 'zencoding-preview-output)
+ (when (< 0 zencoding-insert-flash-time)
+ (run-with-idle-timer zencoding-insert-flash-time
+ nil 'zencoding-remove-flash-ovl (current-buffer)))))
+
+;;;###autoload
+(defun zencoding-preview (beg end)
+ "Expand zencode between BEG and END interactively.
+This will show a preview of the expanded zen code and you can
+accept it or skip it."
+ (interactive (if mark-active
+ (list (region-beginning) (region-end))
+ (list nil nil)))
+ (zencoding-preview-abort)
+ (if (not beg)
+ (message "Region not active")
+ (setq zencoding-old-show-paren show-paren-mode)
+ (show-paren-mode -1)
+ (let ((here (point)))
+ (goto-char beg)
+ (forward-line 1)
+ (unless (= 0 (current-column))
+ (insert "\n"))
+ (let* ((opos (point))
+ (ovli (make-overlay beg end nil nil t))
+ (ovlo (make-overlay opos opos))
+ (info (propertize " Zen preview. Choose with RET. Cancel by stepping out. \n"
+ 'face 'tooltip)))
+ (overlay-put ovli 'face 'zencoding-preview-input)
+ (overlay-put ovli 'keymap zencoding-preview-keymap)
+ (overlay-put ovlo 'face 'zencoding-preview-output)
+ (overlay-put ovlo 'before-string info)
+ (setq zencoding-preview-input ovli)
+ (setq zencoding-preview-output ovlo)
+ (add-hook 'before-change-functions 'zencoding-preview-before-change t t)
+ (goto-char here)
+ (add-hook 'post-command-hook 'zencoding-preview-post-command t t)))))
+
+(defvar zencoding-preview-pending-abort nil)
+(make-variable-buffer-local 'zencoding-preview-pending-abort)
+
+(defun zencoding-preview-before-change (beg end)
+ (when
+ (or (> beg (overlay-end zencoding-preview-input))
+ (< beg (overlay-start zencoding-preview-input))
+ (> end (overlay-end zencoding-preview-input))
+ (< end (overlay-start zencoding-preview-input)))
+ (setq zencoding-preview-pending-abort t)))
+
+(defun zencoding-preview-abort ()
+ "Abort zen code preview."
+ (interactive)
+ (setq zencoding-preview-pending-abort nil)
+ (remove-hook 'before-change-functions 'zencoding-preview-before-change t)
+ (when (overlayp zencoding-preview-input)
+ (delete-overlay zencoding-preview-input))
+ (setq zencoding-preview-input nil)
+ (when (overlayp zencoding-preview-output)
+ (delete-overlay zencoding-preview-output))
+ (setq zencoding-preview-output nil)
+ (remove-hook 'post-command-hook 'zencoding-preview-post-command t)
+ (when zencoding-old-show-paren (show-paren-mode 1)))
+
+(defun zencoding-preview-post-command ()
+ (condition-case err
+ (zencoding-preview-post-command-1)
+ (error (message "zencoding-preview-post: %s" err))))
+
+(defun zencoding-preview-post-command-1 ()
+ (if (and (not zencoding-preview-pending-abort)
+ (<= (point) (overlay-end zencoding-preview-input))
+ (>= (point) (overlay-start zencoding-preview-input)))
+ (zencoding-update-preview (current-indentation))
+ (zencoding-preview-abort)))
+
+(defun zencoding-preview-transformed (indent)
+ (let* ((string (buffer-substring-no-properties
+ (overlay-start zencoding-preview-input)
+ (overlay-end zencoding-preview-input)))
+ (ast (car (zencoding-expr string))))
+ (when (not (eq ast 'error))
+ (zencoding-prettify (zencoding-transform ast)
+ indent))))
+
+(defun zencoding-update-preview (indent)
+ (let* ((pretty (zencoding-preview-transformed indent))
+ (show (when pretty
+ (propertize pretty 'face 'highlight))))
+ (when show
+ (overlay-put zencoding-preview-output 'after-string
+ (concat show "\n")))))
+;; a+bc
+
+;;;;;;;;;;
+;; Chris's version
+
+;; (defvar zencoding-realtime-preview-keymap
+;; (let ((map (make-sparse-keymap)))
+;; (define-key map "\C-c\C-c" 'zencoding-delete-overlay-pair)
+
+;; map)
+;; "Keymap used in zencoding realtime preview overlays.")
+
+;; ;;;###autoload
+;; (defun zencoding-realtime-preview-of-region (beg end)
+;; "Construct a real-time preview for the region BEG to END."
+;; (interactive "r")
+;; (let ((beg2)
+;; (end2))
+;; (save-excursion
+;; (goto-char beg)
+;; (forward-line)
+;; (setq beg2 (point)
+;; end2 (point))
+;; (insert "\n"))
+;; (let ((input-and-output (zencoding-make-overlay-pair beg end beg2 end2)))
+;; (zencoding-handle-overlay-change (car input-and-output) nil nil nil)))
+;; )
+
+;; (defun zencoding-make-overlay-pair (beg1 end1 beg2 end2)
+;; "Construct an input and an output overlay for BEG1 END1 and BEG2 END2"
+;; (let ((input (make-overlay beg1 end1 nil t t))
+;; (output (make-overlay beg2 end2)))
+;; ;; Setup input overlay
+;; (overlay-put input 'face '(:underline t))
+;; (overlay-put input 'modification-hooks
+;; (list #'zencoding-handle-overlay-change))
+;; (overlay-put input 'output output)
+;; (overlay-put input 'keymap zencoding-realtime-preview-keymap)
+;; ;; Setup output overlay
+;; (overlay-put output 'face '(:overline t))
+;; (overlay-put output 'intangible t)
+;; (overlay-put output 'input input)
+;; ;; Return the overlays.
+;; (list input output))
+;; )
+
+;; (defun zencoding-delete-overlay-pair (&optional one)
+;; "Delete a pair of input and output overlays based on ONE."
+;; (interactive) ;; Since called from keymap
+;; (unless one
+;; (let ((overlays (overlays-at (point))))
+;; (while (and overlays
+;; (not (or (overlay-get (car overlays) 'input)
+;; (overlay-get (car overlays) 'output))))
+;; (setq overlays (cdr overlays)))
+;; (setq one (car overlays))))
+;; (when one
+;; (let ((other (or (overlay-get one 'input)
+;; (overlay-get one 'output))))
+;; (delete-overlay one)
+;; (delete-overlay other)))
+;; )
+
+;; (defun zencoding-handle-overlay-change (input del beg end &optional old)
+;; "Update preview after overlay change."
+;; (let* ((output (overlay-get input 'output))
+;; (start (overlay-start output))
+;; (string (buffer-substring-no-properties
+;; (overlay-start input)
+;; (overlay-end input)))
+;; (ast (car (zencoding-expr string)))
+;; (markup (when (not (eq ast 'error))
+;; (zencoding-transform ast))))
+;; (save-excursion
+;; (delete-region start (overlay-end output))
+;; (goto-char start)
+;; (if markup
+;; (insert markup)
+;; (insert (propertize "error" 'face 'font-lock-error-face)))
+;; (move-overlay output start (point))))
+;; )
+
+(provide 'zencoding-mode)
+
+;;; zencoding-mode.el ends here
--- a/vala-mode.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-;;; vala-mode.el --- Vala mode derived mode
-
-;; Author: 2005 Dylan R. E. Moonfire
-;; 2008 Étienne BERSAC
-;; Maintainer: Étienne BERSAC <[email protected]>
-;; Created: 2008 May the 4th
-;; Modified: May 2008
-;; Version: 0.1
-;; Keywords: vala languages oop
-
-;; 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 of the License, or
-;; (at your option) any later version.
-;;
-;; 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 this program; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;; See http://live.gnome.org/Vala for details about Vala language.
-;;
-;; This is a separate mode to implement the Vala constructs and
-;; font-locking. It is mostly the csharp-mode from
-;; http://mfgames.com/linux/csharp-mode with vala specific keywords
-;; and filename suffixes.
-;;
-;; Note: The interface used in this file requires CC Mode 5.30 or
-;; later.
-
-;;; .emacs (don't put in (require 'vala-mode))
-;; (autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
-;; (setq auto-mode-alist
-;; (append '(("\\.vala$" . vala-mode)) auto-mode-alist))
-
-;;; Versions:
-;;
-;; 0.1 : Initial version based on csharp-mode
-;;
-
-;; This is a copy of the function in cc-mode which is used to handle
-;; the eval-when-compile which is needed during other times.
-(defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
- ;; See cc-langs.el, a direct copy.
- (unless (listp (car-safe ops))
- (setq ops (list ops)))
- (cond ((eq opgroup-filter t)
- (setq opgroup-filter (lambda (opgroup) t)))
- ((not (functionp opgroup-filter))
- (setq opgroup-filter `(lambda (opgroup)
- (memq opgroup ',opgroup-filter)))))
- (cond ((eq op-filter t)
- (setq op-filter (lambda (op) t)))
- ((stringp op-filter)
- (setq op-filter `(lambda (op)
- (string-match ,op-filter op)))))
- (unless xlate
- (setq xlate 'identity))
- (c-with-syntax-table (c-lang-const c-mode-syntax-table)
- (delete-duplicates
- (mapcan (lambda (opgroup)
- (when (if (symbolp (car opgroup))
- (when (funcall opgroup-filter (car opgroup))
- (setq opgroup (cdr opgroup))
- t)
- t)
- (mapcan (lambda (op)
- (when (funcall op-filter op)
- (let ((res (funcall xlate op)))
- (if (listp res) res (list res)))))
- opgroup)))
- ops)
- :test 'equal)))
-
-;; This inserts the bulk of the code.
-(require 'cc-mode)
-
-;; These are only required at compile time to get the sources for the
-;; language constants. (The cc-fonts require and the font-lock
-;; related constants could additionally be put inside an
-;; (eval-after-load "font-lock" ...) but then some trickery is
-;; necessary to get them compiled.)
-(eval-when-compile
- (let ((load-path
- (if (and (boundp 'byte-compile-dest-file)
- (stringp byte-compile-dest-file))
- (cons (file-name-directory byte-compile-dest-file) load-path)
- load-path)))
- (load "cc-mode" nil t)
- (load "cc-fonts" nil t)
- (load "cc-langs" nil t)))
-
-(eval-and-compile
- ;; Make our mode known to the language constant system. Use Java
- ;; mode as the fallback for the constants we don't change here.
- ;; This needs to be done also at compile time since the language
- ;; constants are evaluated then.
- (c-add-language 'vala-mode 'java-mode))
-
-;; Java uses a series of regexes to change the font-lock for class
-;; references. The problem comes in because Java uses Pascal (leading
-;; space in names, SomeClass) for class and package names, but
-;; Camel-casing (initial lowercase, upper case in words,
-;; i.e. someVariable) for variables.
-;;(error (byte-compile-dest-file))
-;;(error (c-get-current-file))
-(c-lang-defconst c-opt-after-id-concat-key
- vala (if (c-lang-const c-opt-identifier-concat-key)
- (c-lang-const c-symbol-start)))
-
-(c-lang-defconst c-basic-matchers-before
- vala `(
-;;;; Font-lock the attributes by searching for the
-;;;; appropriate regex and marking it as TODO.
- ;;,`(,(concat "\\(" vala-attribute-regex "\\)")
- ;; 0 font-lock-function-name-face)
-
- ;; Put a warning face on the opener of unclosed strings that
- ;; can't span lines. Later font
- ;; lock packages have a `font-lock-syntactic-face-function' for
- ;; this, but it doesn't give the control we want since any
- ;; fontification done inside the function will be
- ;; unconditionally overridden.
- ,(c-make-font-lock-search-function
- ;; Match a char before the string starter to make
- ;; `c-skip-comments-and-strings' work correctly.
- (concat ".\\(" c-string-limit-regexp "\\)")
- '((c-font-lock-invalid-string)))
-
- ;; Fontify keyword constants.
- ,@(when (c-lang-const c-constant-kwds)
- (let ((re (c-make-keywords-re nil
- (c-lang-const c-constant-kwds))))
- `((eval . (list ,(concat "\\<\\(" re "\\)\\>")
- 1 c-constant-face-name)))))
-
- ;; Fontify all keywords except the primitive types.
- ,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
- 1 font-lock-keyword-face)
-
- ;; Fontify leading identifiers in fully
- ;; qualified names like "Foo.Bar".
- ,@(when (c-lang-const c-opt-identifier-concat-key)
- `((,(byte-compile
- `(lambda (limit)
- (while (re-search-forward
- ,(concat "\\(\\<" ; 1
- "\\(" (c-lang-const c-symbol-key)
- "\\)" ; 2
- "[ \t\n\r\f\v]*"
- (c-lang-const
- c-opt-identifier-concat-key)
- "[ \t\n\r\f\v]*"
- "\\)"
- "\\("
- (c-lang-const
- c-opt-after-id-concat-key)
- "\\)")
- limit t)
- (unless (progn
- (goto-char (match-beginning 0))
- (c-skip-comments-and-strings limit))
- (or (get-text-property (match-beginning 2) 'face)
- (c-put-font-lock-face (match-beginning 2)
- (match-end 2)
- c-reference-face-name))
- (goto-char (match-end 1)))))))))
- ))
-
-;; Vala does not allow a leading qualifier operator. It also doesn't
-;; allow the ".*" construct of Java. So, we redo this regex without
-;; the "\\|\\*" regex.
-(c-lang-defconst c-identifier-key
- vala (concat "\\(" (c-lang-const c-symbol-key) "\\)" ; 1
- (concat "\\("
- "[ \t\n\r\f\v]*"
- (c-lang-const c-opt-identifier-concat-key)
- "[ \t\n\r\f\v]*"
- (concat "\\("
- "\\(" (c-lang-const c-symbol-key) "\\)"
- "\\)")
- "\\)*")))
-
-;; Vala has a few rules that are slightly different than Java for
-;; operators. This also removed the Java's "super" and replaces it
-;; with the Vala's "base".
-(c-lang-defconst c-operators
- vala `((prefix "base")))
-
-;; Vala directives ?
-;; (c-lang-defconst c-opt-cpp-prefix
-;; csharp "^\\s *#.*")
-
-
-;; Vala uses the following assignment operators
-(c-lang-defconst c-assignment-operators
- vala '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<="
- "&=" "^=" "|=" "++" "--"))
-
-;; This defines the primative types for Vala
-(c-lang-defconst c-primitive-type-kwds
- vala '("void" "char" "int" "float" "double" "string"))
-
-;; The keywords that define that the following is a type, such as a
-;; class definition.
-(c-lang-defconst c-type-prefix-kwds
- vala '("class" "interface" "struct" "enum" "signal"))
-
-;; Type modifier keywords. They appear anywhere in types, but modifiy
-;; instead create one.
-(c-lang-defconst c-type-modifier-kwds
- vala '("const"))
-
-;; Structures that are similiar to classes.
-(c-lang-defconst c-class-decl-kwds
- vala '("class" "interface"))
-
-;; The various modifiers used for class and method descriptions.
-(c-lang-defconst c-modifier-kwds
- vala '("public" "partial" "private" "const" "abstract"
- "protected" "ref" "in" "out" "static" "virtual"
- "override" "params" "internal" "weak" "owned"
- "unowned"))
-
-;; We don't use the protection level stuff because it breaks the
-;; method indenting. Not sure why, though.
-(c-lang-defconst c-protection-kwds
- vala nil)
-
-;; Define the keywords that can have something following after them.
-(c-lang-defconst c-type-list-kwds
- vala '("struct" "class" "interface" "is" "as"
- "delegate" "event" "set" "get" "add" "remove"
- "callback" "signal" "var" "default"))
-
-;; This allows the classes after the : in the class declartion to be
-;; fontified.
-(c-lang-defconst c-typeless-decl-kwds
- vala '(":"))
-
-;; Sets up the enum to handle the list properly
-(c-lang-defconst c-brace-list-decl-kwds
- vala '("enum" "errordomain"))
-
-;; We need to remove Java's package keyword
-(c-lang-defconst c-ref-list-kwds
- vala '("using" "namespace" "construct"))
-
-;; Follow-on blocks that don't require a brace
-(c-lang-defconst c-block-stmt-2-kwds
- vala '("for" "if" "switch" "while" "catch" "foreach" "lock"))
-
-;; Statements that break out of braces
-(c-lang-defconst c-simple-stmt-kwds
- vala '("return" "continue" "break" "throw"))
-
-;; Statements that allow a label
-;; TODO?
-(c-lang-defconst c-before-label-kwds
- vala nil)
-
-;; Constant keywords
-(c-lang-defconst c-constant-kwds
- vala '("true" "false" "null"))
-
-;; Keywords that start "primary expressions."
-(c-lang-defconst c-primary-expr-kwds
- vala '("this" "base"))
-
-;; We need to treat namespace as an outer block to class indenting
-;; works properly.
-(c-lang-defconst c-other-block-decl-kwds
- vala '("namespace"))
-
-;; We need to include the "in" for the foreach
-(c-lang-defconst c-other-kwds
- vala '("in" "sizeof" "typeof"))
-
-(require 'cc-awk)
-
-(c-lang-defconst c-at-vsemi-p-fn
- vala 'c-awk-at-vsemi-p)
-
-
-(defcustom vala-font-lock-extra-types nil
- "*List of extra types (aside from the type keywords) to recognize in Vala mode.
-Each list item should be a regexp matching a single identifier.")
-
-(defconst vala-font-lock-keywords-1 (c-lang-const c-matchers-1 vala)
- "Minimal highlighting for Vala mode.")
-
-(defconst vala-font-lock-keywords-2 (c-lang-const c-matchers-2 vala)
- "Fast normal highlighting for Vala mode.")
-
-(defconst vala-font-lock-keywords-3 (c-lang-const c-matchers-3 vala)
- "Accurate normal highlighting for Vala mode.")
-
-(defvar vala-font-lock-keywords vala-font-lock-keywords-3
- "Default expressions to highlight in Vala mode.")
-
-(defvar vala-mode-syntax-table
- nil
- "Syntax table used in vala-mode buffers.")
-(or vala-mode-syntax-table
- (setq vala-mode-syntax-table
- (funcall (c-lang-const c-make-mode-syntax-table vala))))
-
-(defvar vala-mode-abbrev-table nil
- "Abbreviation table used in vala-mode buffers.")
-(c-define-abbrev-table 'vala-mode-abbrev-table
- ;; Keywords that if they occur first on a line
- ;; might alter the syntactic context, and which
- ;; therefore should trig reindentation when
- ;; they are completed.
- '(("else" "else" c-electric-continued-statement 0)
- ("while" "while" c-electric-continued-statement 0)
- ("catch" "catch" c-electric-continued-statement 0)
- ("finally" "finally" c-electric-continued-statement 0)))
-
-(defvar vala-mode-map (let ((map (c-make-inherited-keymap)))
- ;; Add bindings which are only useful for Vala
- map)
- "Keymap used in vala-mode buffers.")
-
-;;(easy-menu-define vala-menu vala-mode-map "Vala Mode Commands"
-;; ;; Can use `vala' as the language for `c-mode-menu'
-;; ;; since its definition covers any language. In
-;; ;; this case the language is used to adapt to the
-;; ;; nonexistence of a cpp pass and thus removing some
-;; ;; irrelevant menu alternatives.
-;; (cons "Vala" (c-lang-const c-mode-menu vala)))
-
-;;; Autoload mode trigger
-(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
-(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
-
-;; Custom variables
-(defcustom vala-mode-hook nil
- "*Hook called by `vala-mode'."
- :type 'hook
- :group 'c)
-
-;;; The entry point into the mode
-;;;###autoload
-(defun vala-mode ()
- "Major mode for editing Vala code.
-This is a simple example of a separate mode derived from CC Mode
-to support a language with syntax similar to
-C#/C/C++/ObjC/Java/IDL/Pike.
-
-The hook `c-mode-common-hook' is run with no args at mode
-initialization, then `vala-mode-hook'.
-
-Key bindings:
-\\{vala-mode-map}"
- (interactive)
- (kill-all-local-variables)
- (c-initialize-cc-mode t)
- (set-syntax-table vala-mode-syntax-table)
- (setq major-mode 'vala-mode
- mode-name "Vala"
- local-abbrev-table vala-mode-abbrev-table
- abbrev-mode t)
- (use-local-map c-mode-map)
- ;; `c-init-language-vars' is a macro that is expanded at compile
- ;; time to a large `setq' with all the language variables and their
- ;; customized values for our language.
- (c-init-language-vars vala-mode)
- ;; `c-common-init' initializes most of the components of a CC Mode
- ;; buffer, including setup of the mode menu, font-lock, etc.
- ;; There's also a lower level routine `c-basic-common-init' that
- ;; only makes the necessary initialization to get the syntactic
- ;; analysis and similar things working.
- (c-common-init 'vala-mode)
- ;;(easy-menu-add vala-menu)
- (c-set-style "linux")
- (setq indent-tabs-mode t)
- (setq c-basic-offset 4)
- (setq tab-width 4)
- (c-toggle-auto-newline -1)
- (c-toggle-hungry-state -1)
- (run-hooks 'c-mode-common-hook)
- (run-hooks 'vala-mode-hook)
- (c-update-modeline))
-
-(provide 'vala-mode)
-
-;;; vala-mode.el ends here
--- a/zencoding-mode.el Sun Apr 03 11:26:27 2011 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,798 +0,0 @@
-;;; zencoding-mode.el --- Unfold CSS-selector-like expressions to markup
-;;
-;; Copyright (C) 2009, Chris Done
-;;
-;; Author: Chris Done <[email protected]>
-(defconst zencoding-mode:version "0.5")
-;; Last-Updated: 2009-11-20 Fri
-;; 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
-;;
-;; 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:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 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))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Zen coding parsers
-
-(defun zencoding-expr (input)
- "Parse a zen coding expression. This pretty much defines precedence."
- (zencoding-run zencoding-siblings
- it
- (zencoding-run zencoding-parent-child
- it
- (zencoding-run zencoding-multiplier
- it
- (zencoding-run zencoding-pexpr
- it
- (zencoding-run zencoding-tag
- it
- '(error "no match, expecting ( or a-zA-Z0-9")))))))
-
-(defun zencoding-multiplier (input)
- (zencoding-por zencoding-pexpr zencoding-tag
- (let ((multiplier expr))
- (zencoding-parse "\\*\\([0-9]+\\)" 2 "*n where n is a number"
- (let ((multiplicand (read (elt it 1))))
- `((list ,(make-list multiplicand multiplier)) . ,input))))
- '(error "expected *n multiplier")))
-
-(defun zencoding-tag (input)
- "Parse a tag."
- (zencoding-run zencoding-tagname
- (let ((result it)
- (tagname (cdr expr)))
- (zencoding-pif (zencoding-run zencoding-identifier
- (zencoding-tag-classes
- `(tag ,tagname ((id ,(cddr expr)))) input)
- (zencoding-tag-classes `(tag ,tagname ()) input))
- (let ((expr-and-input it) (expr (car it)) (input (cdr it)))
- (zencoding-pif (zencoding-tag-props expr input)
- it
- expr-and-input))))
- '(error "expected tagname")))
-
-(defun zencoding-tag-props (tag input)
- (zencoding-run zencoding-props
- (let ((tagname (cadr tag))
- (existing-props (caddr tag))
- (props (cdr expr)))
- `((tag ,tagname
- ,(append existing-props props))
- . ,input))))
-
-(defun zencoding-props (input)
- "Parse many props."
- (zencoding-run zencoding-prop
- (zencoding-pif (zencoding-props input)
- `((props . ,(cons expr (cdar it))) . ,(cdr it))
- `((props . ,(list expr)) . ,input))))
-
-(defun zencoding-prop (input)
- (zencoding-parse
- " " 1 "space"
- (zencoding-run
- zencoding-name
- (let ((name (cdr expr)))
- (zencoding-parse "=\\([^\\,\\+\\>\\ )]*\\)" 2
- "=property value"
- (let ((value (elt it 1))
- (input (elt it 2)))
- `((,(read name) ,value) . ,input)))))))
-
-(defun zencoding-tag-classes (tag input)
- (zencoding-run zencoding-classes
- (let ((tagname (cadr tag))
- (props (caddr tag))
- (classes `(class ,(mapconcat
- (lambda (prop)
- (cdadr prop))
- (cdr expr)
- " "))))
- `((tag ,tagname ,(append props (list classes))) . ,input))
- `(,tag . ,input)))
-
-(defun zencoding-tagname (input)
- "Parse a tagname a-zA-Z0-9 tagname (e.g. html/head/xsl:if/br)."
- (zencoding-parse "\\([a-zA-Z][a-zA-Z0-9:-]*\\)" 2 "tagname, a-zA-Z0-9"
- `((tagname . ,(elt it 1)) . ,input)))
-
-(defun zencoding-pexpr (input)
- "A zen coding expression with parentheses around it."
- (zencoding-parse "(" 1 "("
- (zencoding-run zencoding-expr
- (zencoding-aif (zencoding-regex ")" input '(0 1))
- `(,expr . ,(elt it 1))
- '(error "expecting `)'")))))
-
-(defun zencoding-parent-child (input)
- "Parse an tag>e expression, where `n' is an tag and `e' is any
- expression."
- (zencoding-run zencoding-multiplier
- (let* ((items (cadr expr))
- (rest (zencoding-child-sans expr input)))
- (if (not (eq (car rest) 'error))
- (let ((child (car rest))
- (input (cdr rest)))
- (cons (cons 'list
- (cons (mapcar (lambda (parent)
- `(parent-child ,parent ,child))
- items)
- nil))
- input))
- '(error "expected child")))
- (zencoding-run zencoding-tag
- (zencoding-child expr input)
- '(error "expected parent"))))
-
-(defun zencoding-child-sans (parent input)
- (zencoding-parse ">" 1 ">"
- (zencoding-run zencoding-expr
- it
- '(error "expected child"))))
-
-(defun zencoding-child (parent input)
- (zencoding-parse ">" 1 ">"
- (zencoding-run zencoding-expr
- (let ((child expr))
- `((parent-child ,parent ,child) . ,input))
- '(error "expected child"))))
-
-(defun zencoding-sibling (input)
- (zencoding-por zencoding-pexpr zencoding-multiplier
- it
- (zencoding-run zencoding-tag
- it
- '(error "expected sibling"))))
-
-(defun zencoding-siblings (input)
- "Parse an e+e expression, where e is an tag or a pexpr."
- (zencoding-run zencoding-sibling
- (let ((parent expr))
- (zencoding-parse "\\+" 1 "+"
- (zencoding-run zencoding-expr
- (let ((child expr))
- `((zencoding-siblings ,parent ,child) . ,input))
- '(error "expected second sibling"))))
- '(error "expected first sibling")))
-
-(defun zencoding-name (input)
- "Parse a class or identifier name, e.g. news, footer, mainimage"
- (zencoding-parse "\\([a-zA-Z][a-zA-Z0-9-_]*\\)" 2 "class or identifer name"
- `((name . ,(elt it 1)) . ,input)))
-
-(defun zencoding-class (input)
- "Parse a classname expression, e.g. .foo"
- (zencoding-parse "\\." 1 "."
- (zencoding-run zencoding-name
- `((class ,expr) . ,input)
- '(error "expected class name"))))
-
-(defun zencoding-identifier (input)
- "Parse an identifier expression, e.g. #foo"
- (zencoding-parse "#" 1 "#"
- (zencoding-run zencoding-name
- `((identifier . ,expr) . ,input))))
-
-(defun zencoding-classes (input)
- "Parse many classes."
- (zencoding-run zencoding-class
- (zencoding-pif (zencoding-classes input)
- `((classes . ,(cons expr (cdar it))) . ,(cdr it))
- `((classes . ,(list expr)) . ,input))
- '(error "expected class")))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Zen coding transformer from AST to HTML
-
-;; Fix-me: make mode specific
-(defvar zencoding-single-tags
- '("br"
- "img"))
-
-(defvar zencoding-inline-tags
- '("a"
- "abbr"
- "acronym"
- "cite"
- "code"
- "dfn"
- "em"
- "h1" "h2" "h3" "h4" "h5" "h6"
- "kbd"
- "q"
- "span"
- "strong"
- "var"))
-
-(defvar zencoding-block-tags
- '("p"))
-
-;; li
-;; a
-;; em
-;; p
-
-(defvar zencoding-leaf-function nil
- "Function to execute when expanding a leaf node in the
- Zencoding AST.")
-
-(defun zencoding-make-tag (tag &optional content)
- (let* ((name (car tag))
- (lf (if
- (or
- (member name zencoding-block-tags)
- (and
- (> (length name) 1)
- (not (member name zencoding-inline-tags))
- ))
- "\n" ""))
- (single (member name zencoding-single-tags))
- (props (apply 'concat (mapcar
- (lambda (prop)
- (concat " " (symbol-name (car prop))
- "=\"" (cadr prop) "\""))
- (cadr tag)))))
- (concat lf "<" name props ">" lf
- (if single
- ""
- (concat
- (if content content
- (if zencoding-leaf-function
- (funcall zencoding-leaf-function)
- ""))
- lf "</" name ">")))))
-
-(defun zencoding-transform (ast)
- (let ((type (car ast)))
- (cond
- ((eq type 'list)
- (mapconcat 'zencoding-transform (cadr ast) ""))
- ((eq type 'tag)
- (zencoding-make-tag (cdr ast)))
- ((eq type 'parent-child)
- (let ((parent (cdadr ast))
- (children (zencoding-transform (caddr ast))))
- (zencoding-make-tag parent children)))
- ((eq type 'zencoding-siblings)
- (let ((sib1 (zencoding-transform (cadr ast)))
- (sib2 (zencoding-transform (caddr ast))))
- (concat sib1 sib2))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Test-cases
-
-(defun zencoding-test-cases ()
- (let ((tests '(;; Tags
- ("a" "<a></a>")
- ("a.x" "<a class=\"x\"></a>")
- ("a#q.x" "<a id=\"q\" class=\"x\"></a>")
- ("a#q.x.y.z" "<a id=\"q\" class=\"x y z\"></a>")
- ;; Siblings
- ("a+b" "<a></a><b></b>")
- ("a+b+c" "<a></a><b></b><c></c>")
- ("a.x+b" "<a class=\"x\"></a><b></b>")
- ("a#q.x+b" "<a id=\"q\" class=\"x\"></a><b></b>")
- ("a#q.x.y.z+b" "<a id=\"q\" class=\"x y z\"></a><b></b>")
- ("a#q.x.y.z+b#p.l.m.n" "<a id=\"q\" class=\"x y z\"></a><b id=\"p\" class=\"l m n\"></b>")
- ;; Parent > child
- ("a>b" "<a><b></b></a>")
- ("a>b>c" "<a><b><c></c></b></a>")
- ("a.x>b" "<a class=\"x\"><b></b></a>")
- ("a#q.x>b" "<a id=\"q\" class=\"x\"><b></b></a>")
- ("a#q.x.y.z>b" "<a id=\"q\" class=\"x y z\"><b></b></a>")
- ("a#q.x.y.z>b#p.l.m.n" "<a id=\"q\" class=\"x y z\"><b id=\"p\" class=\"l m n\"></b></a>")
- ("a>b+c" "<a><b></b><c></c></a>")
- ("a>b+c>d" "<a><b></b><c><d></d></c></a>")
- ;; Multiplication
- ("a*1" "<a></a>")
- ("a*2" "<a></a><a></a>")
- ("a*2+b*2" "<a></a><a></a><b></b><b></b>")
- ("a*2>b*2" "<a><b></b><b></b></a><a><b></b><b></b></a>")
- ("a>b*2" "<a><b></b><b></b></a>")
- ("a#q.x>b#q.x*2" "<a id=\"q\" class=\"x\"><b id=\"q\" class=\"x\"></b><b id=\"q\" class=\"x\"></b></a>")
- ;; Properties
- ("a x=y" "<a x=\"y\"></a>")
- ("a x=y m=l" "<a x=\"y\" m=\"l\"></a>")
- ("a#foo x=y m=l" "<a id=\"foo\" x=\"y\" m=\"l\"></a>")
- ("a.foo x=y m=l" "<a class=\"foo\" x=\"y\" m=\"l\"></a>")
- ("a#foo.bar.mu x=y m=l" "<a id=\"foo\" class=\"bar mu\" x=\"y\" m=\"l\"></a>")
- ("a x=y+b" "<a x=\"y\"></a><b></b>")
- ("a x=y+b x=y" "<a x=\"y\"></a><b x=\"y\"></b>")
- ("a x=y>b" "<a x=\"y\"><b></b></a>")
- ("a x=y>b x=y" "<a x=\"y\"><b x=\"y\"></b></a>")
- ("a x=y>b x=y+c x=y" "<a x=\"y\"><b x=\"y\"></b><c x=\"y\"></c></a>")
- ;; Parentheses
- ("(a)" "<a></a>")
- ("(a)+(b)" "<a></a><b></b>")
- ("a>(b)" "<a><b></b></a>")
- ("(a>b)>c" "<a><b></b></a>")
- ("(a>b)+c" "<a><b></b></a><c></c>")
- ("z+(a>b)+c+k" "<z></z><a><b></b></a><c></c><k></k>")
- ("(a)*2" "<a></a><a></a>")
- ("((a)*2)" "<a></a><a></a>")
- ("((a)*2)" "<a></a><a></a>")
- ("(a>b)*2" "<a><b></b></a><a><b></b></a>")
- ("(a+b)*2" "<a></a><b></b><a></a><b></b>")
- )))
- (mapc (lambda (input)
- (let ((expected (cadr input))
- (actual (zencoding-transform (car (zencoding-expr (car input))))))
- (if (not (equal expected actual))
- (error (concat "Assertion " (car input) " failed:"
- expected
- " == "
- actual)))))
- tests)
- (concat (number-to-string (length tests)) " tests performed. All OK.")))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Zencoding minor mode
-
-(defgroup zencoding nil
- "Customization group for zencoding-mode."
- :group 'convenience)
-
-(defun zencoding-expr-on-line ()
- "Extract a zencoding expression and the corresponding bounds
- for the current line."
- (let* ((start (line-beginning-position))
- (end (line-end-position))
- (line (buffer-substring-no-properties start end))
- (expr (zencoding-regex "\\([ \t]*\\)\\([^\n]+\\)" line 2)))
- (if (first expr)
- (list (first expr) start end))))
-
-(defun zencoding-prettify (markup indent)
- (save-match-data
- ;;(setq markup (replace-regexp-in-string "><" ">\n<" markup))
- (setq markup (replace-regexp-in-string "\n\n" "\n" markup))
- (setq markup (replace-regexp-in-string "^\n" "" markup)))
- (with-temp-buffer
- (indent-to indent)
- (insert "<i></i>")
- (insert "\n")
- (let ((here (point)))
- (insert markup)
- (sgml-mode)
- (indent-region here (point-max))
- (buffer-substring-no-properties here (point-max)))))
-
-;;;###autoload
-(defun zencoding-expand-line (arg)
- "Replace the current line's zencode expression with the corresponding expansion.
-If prefix ARG is given or region is visible call `zencoding-preview' to start an
-interactive preview.
-
-Otherwise expand line directly.
-
-For more information see `zencoding-mode'."
- (interactive "P")
- (let* ((here (point))
- (preview (if zencoding-preview-default (not arg) arg))
- (beg (if preview
- (progn
- (beginning-of-line)
- (skip-chars-forward " \t")
- (point))
- (when mark-active (region-beginning))))
- (end (if preview
- (progn
- (end-of-line)
- (skip-chars-backward " \t")
- (point))
- (when mark-active (region-end)))))
- (if beg
- (progn
- (goto-char here)
- (zencoding-preview beg end))
- (let ((expr (zencoding-expr-on-line)))
- (if expr
- (let* ((markup (zencoding-transform (car (zencoding-expr (first expr)))))
- (pretty (zencoding-prettify markup (current-indentation))))
- (save-excursion
- (delete-region (second expr) (third expr))
- (zencoding-insert-and-flash pretty))))))))
-
-(defvar zencoding-mode-keymap nil
- "Keymap for zencode minor mode.")
-
-(if zencoding-mode-keymap
- nil
- (progn
- (setq zencoding-mode-keymap (make-sparse-keymap))
- (define-key zencoding-mode-keymap (kbd "<C-return>") 'zencoding-expand-line)))
-
-;;;###autoload
-(define-minor-mode zencoding-mode
- "Minor mode for writing HTML and CSS markup.
-With zen coding for HTML and CSS you can write a line like
-
- ul#name>li.item*2
-
-and have it expanded to
-
- <ul id=\"name\">
- <li class=\"item\"></li>
- <li class=\"item\"></li>
- </ul>
-
-This minor mode defines keys for quick access:
-
-\\{zencoding-mode-keymap}
-
-Home page URL `http://www.emacswiki.org/emacs/ZenCoding'.
-
-See also `zencoding-expand-line'."
- :lighter " Zen"
- :keymap zencoding-mode-keymap)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Zencoding yasnippet integration
-
-(defun zencoding-transform-yas (ast)
- (let* ((leaf-count 0)
- (zencoding-leaf-function
- (lambda ()
- (format "$%d" (incf leaf-count)))))
- (zencoding-transform ast)))
-
-;;;###autoload
-(defun zencoding-expand-yas ()
- (interactive)
- (let ((expr (zencoding-expr-on-line)))
- (if expr
- (let* ((markup (zencoding-transform-yas (car (zencoding-expr (first expr)))))
- (filled (replace-regexp-in-string "><" ">\n<" markup)))
- (delete-region (second expr) (third expr))
- (insert filled)
- (indent-region (second expr) (point))
- (yas/expand-snippet
- (buffer-substring (second expr) (point))
- (second expr) (point))))))
-
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Real-time preview
-;;
-
-;;;;;;;;;;
-;; Lennart's version
-
-(defvar zencoding-preview-input nil)
-(make-local-variable 'zencoding-preview-input)
-(defvar zencoding-preview-output nil)
-(make-local-variable 'zencoding-preview-output)
-(defvar zencoding-old-show-paren nil)
-(make-local-variable 'zencoding-old-show-paren)
-
-(defface zencoding-preview-input
- '((default :box t :inherit secondary-selection))
- "Face for preview input field."
- :group 'zencoding)
-
-(defface zencoding-preview-output
- '((default :inherit highlight))
- "Face for preview output field."
- :group 'zencoding)
-
-(defvar zencoding-preview-keymap
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "<return>") 'zencoding-preview-accept)
- (define-key map [(control ?g)] 'zencoding-preview-abort)
- map))
-
-(defun zencoding-preview-accept ()
- (interactive)
- (let ((ovli zencoding-preview-input))
- (if (not (and (overlayp ovli)
- (bufferp (overlay-buffer ovli))))
- (message "Preview is not active")
- (let* ((indent (current-indentation))
- (markup (zencoding-preview-transformed indent)))
- (when markup
- (delete-region (line-beginning-position) (overlay-end ovli))
- (zencoding-insert-and-flash markup)))))
- (zencoding-preview-abort))
-
-(defvar zencoding-flash-ovl nil)
-(make-variable-buffer-local 'zencoding-flash-ovl)
-
-(defun zencoding-remove-flash-ovl (buf)
- (with-current-buffer buf
- (when (overlayp zencoding-flash-ovl)
- (delete-overlay zencoding-flash-ovl))
- (setq zencoding-flash-ovl nil)))
-
-(defcustom zencoding-preview-default t
- "If non-nil then preview is the default action.
-This determines how `zencoding-expand-line' works by default."
- :type 'boolean
- :group 'zencoding)
-
-(defcustom zencoding-insert-flash-time 0.5
- "Time to flash insertion.
-Set this to a negative number if you do not want flashing the
-expansion after insertion."
- :type '(number :tag "Seconds")
- :group 'zencoding)
-
-(defun zencoding-insert-and-flash (markup)
- (zencoding-remove-flash-ovl (current-buffer))
- (let ((here (point)))
- (insert markup)
- (setq zencoding-flash-ovl (make-overlay here (point)))
- (overlay-put zencoding-flash-ovl 'face 'zencoding-preview-output)
- (when (< 0 zencoding-insert-flash-time)
- (run-with-idle-timer zencoding-insert-flash-time
- nil 'zencoding-remove-flash-ovl (current-buffer)))))
-
-;;;###autoload
-(defun zencoding-preview (beg end)
- "Expand zencode between BEG and END interactively.
-This will show a preview of the expanded zen code and you can
-accept it or skip it."
- (interactive (if mark-active
- (list (region-beginning) (region-end))
- (list nil nil)))
- (zencoding-preview-abort)
- (if (not beg)
- (message "Region not active")
- (setq zencoding-old-show-paren show-paren-mode)
- (show-paren-mode -1)
- (let ((here (point)))
- (goto-char beg)
- (forward-line 1)
- (unless (= 0 (current-column))
- (insert "\n"))
- (let* ((opos (point))
- (ovli (make-overlay beg end nil nil t))
- (ovlo (make-overlay opos opos))
- (info (propertize " Zen preview. Choose with RET. Cancel by stepping out. \n"
- 'face 'tooltip)))
- (overlay-put ovli 'face 'zencoding-preview-input)
- (overlay-put ovli 'keymap zencoding-preview-keymap)
- (overlay-put ovlo 'face 'zencoding-preview-output)
- (overlay-put ovlo 'before-string info)
- (setq zencoding-preview-input ovli)
- (setq zencoding-preview-output ovlo)
- (add-hook 'before-change-functions 'zencoding-preview-before-change t t)
- (goto-char here)
- (add-hook 'post-command-hook 'zencoding-preview-post-command t t)))))
-
-(defvar zencoding-preview-pending-abort nil)
-(make-variable-buffer-local 'zencoding-preview-pending-abort)
-
-(defun zencoding-preview-before-change (beg end)
- (when
- (or (> beg (overlay-end zencoding-preview-input))
- (< beg (overlay-start zencoding-preview-input))
- (> end (overlay-end zencoding-preview-input))
- (< end (overlay-start zencoding-preview-input)))
- (setq zencoding-preview-pending-abort t)))
-
-(defun zencoding-preview-abort ()
- "Abort zen code preview."
- (interactive)
- (setq zencoding-preview-pending-abort nil)
- (remove-hook 'before-change-functions 'zencoding-preview-before-change t)
- (when (overlayp zencoding-preview-input)
- (delete-overlay zencoding-preview-input))
- (setq zencoding-preview-input nil)
- (when (overlayp zencoding-preview-output)
- (delete-overlay zencoding-preview-output))
- (setq zencoding-preview-output nil)
- (remove-hook 'post-command-hook 'zencoding-preview-post-command t)
- (when zencoding-old-show-paren (show-paren-mode 1)))
-
-(defun zencoding-preview-post-command ()
- (condition-case err
- (zencoding-preview-post-command-1)
- (error (message "zencoding-preview-post: %s" err))))
-
-(defun zencoding-preview-post-command-1 ()
- (if (and (not zencoding-preview-pending-abort)
- (<= (point) (overlay-end zencoding-preview-input))
- (>= (point) (overlay-start zencoding-preview-input)))
- (zencoding-update-preview (current-indentation))
- (zencoding-preview-abort)))
-
-(defun zencoding-preview-transformed (indent)
- (let* ((string (buffer-substring-no-properties
- (overlay-start zencoding-preview-input)
- (overlay-end zencoding-preview-input)))
- (ast (car (zencoding-expr string))))
- (when (not (eq ast 'error))
- (zencoding-prettify (zencoding-transform ast)
- indent))))
-
-(defun zencoding-update-preview (indent)
- (let* ((pretty (zencoding-preview-transformed indent))
- (show (when pretty
- (propertize pretty 'face 'highlight))))
- (when show
- (overlay-put zencoding-preview-output 'after-string
- (concat show "\n")))))
-;; a+bc
-
-;;;;;;;;;;
-;; Chris's version
-
-;; (defvar zencoding-realtime-preview-keymap
-;; (let ((map (make-sparse-keymap)))
-;; (define-key map "\C-c\C-c" 'zencoding-delete-overlay-pair)
-
-;; map)
-;; "Keymap used in zencoding realtime preview overlays.")
-
-;; ;;;###autoload
-;; (defun zencoding-realtime-preview-of-region (beg end)
-;; "Construct a real-time preview for the region BEG to END."
-;; (interactive "r")
-;; (let ((beg2)
-;; (end2))
-;; (save-excursion
-;; (goto-char beg)
-;; (forward-line)
-;; (setq beg2 (point)
-;; end2 (point))
-;; (insert "\n"))
-;; (let ((input-and-output (zencoding-make-overlay-pair beg end beg2 end2)))
-;; (zencoding-handle-overlay-change (car input-and-output) nil nil nil)))
-;; )
-
-;; (defun zencoding-make-overlay-pair (beg1 end1 beg2 end2)
-;; "Construct an input and an output overlay for BEG1 END1 and BEG2 END2"
-;; (let ((input (make-overlay beg1 end1 nil t t))
-;; (output (make-overlay beg2 end2)))
-;; ;; Setup input overlay
-;; (overlay-put input 'face '(:underline t))
-;; (overlay-put input 'modification-hooks
-;; (list #'zencoding-handle-overlay-change))
-;; (overlay-put input 'output output)
-;; (overlay-put input 'keymap zencoding-realtime-preview-keymap)
-;; ;; Setup output overlay
-;; (overlay-put output 'face '(:overline t))
-;; (overlay-put output 'intangible t)
-;; (overlay-put output 'input input)
-;; ;; Return the overlays.
-;; (list input output))
-;; )
-
-;; (defun zencoding-delete-overlay-pair (&optional one)
-;; "Delete a pair of input and output overlays based on ONE."
-;; (interactive) ;; Since called from keymap
-;; (unless one
-;; (let ((overlays (overlays-at (point))))
-;; (while (and overlays
-;; (not (or (overlay-get (car overlays) 'input)
-;; (overlay-get (car overlays) 'output))))
-;; (setq overlays (cdr overlays)))
-;; (setq one (car overlays))))
-;; (when one
-;; (let ((other (or (overlay-get one 'input)
-;; (overlay-get one 'output))))
-;; (delete-overlay one)
-;; (delete-overlay other)))
-;; )
-
-;; (defun zencoding-handle-overlay-change (input del beg end &optional old)
-;; "Update preview after overlay change."
-;; (let* ((output (overlay-get input 'output))
-;; (start (overlay-start output))
-;; (string (buffer-substring-no-properties
-;; (overlay-start input)
-;; (overlay-end input)))
-;; (ast (car (zencoding-expr string)))
-;; (markup (when (not (eq ast 'error))
-;; (zencoding-transform ast))))
-;; (save-excursion
-;; (delete-region start (overlay-end output))
-;; (goto-char start)
-;; (if markup
-;; (insert markup)
-;; (insert (propertize "error" 'face 'font-lock-error-face)))
-;; (move-overlay output start (point))))
-;; )
-
-(provide 'zencoding-mode)
-
-;;; zencoding-mode.el ends here