Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sass scss modes update

  • Loading branch information...
commit 5915cf62dd73aba79663a18054e355c4424f05a7 1 parent 529d399
@jpablobr authored
View
5 custom.el
@@ -7,9 +7,10 @@
'(git-baseline-alist (quote (("/home/jpablobr/bin/playr/" . "master"))) t)
'(git-state-modeline-decoration (quote git-state-decoration-colored-letter))
'(git-working-dir-change-behaviour (quote git-refresh-all-saved))
- '(safe-local-variable-values (quote ((backup-inhibited . t) (require-final-newline) (encoding . utf-8))))
+ '(safe-local-variable-values (quote ((TeX-master . "finalreport") (backup-inhibited . t) (require-final-newline) (encoding . utf-8))))
'(send-mail-function (quote sendmail-send-it))
- '(vc-follow-symlinks t))
+ '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)))
+'(vc-follow-symlinks t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
View
7 custom/jp-autocomplete.el
@@ -4,7 +4,8 @@
(require 'auto-complete)
(require 'auto-complete-config)
-(add-to-list 'ac-dictionary-directories (concat misc-dir "/auto-complet/dict"))
+(add-to-list 'ac-dictionary-directories
+ (concat misc-dir "/auto-complet/dict"))
;; (ac-config-default)
(global-auto-complete-mode t)
@@ -30,8 +31,8 @@
;; ac-source-words-in-same-mode-buffers
;; ac-source-rsense-constant
;; ac-source-rsense-method
- ac-source-imenu
- ac-source-words-in-same-mode-buffers
+ ;; ac-source-imenu
+ ;; ac-source-words-in-same-mode-buffers
ac-source-yasnippet
ac-source-filename))
View
9 custom/jp-misc.el
@@ -26,10 +26,10 @@
(transient-mark-mode t)
(recentf-mode t)
(auto-compression-mode t)
-(setq anything-ruby-mthds-object-cmd
- "~/Dropbox/code/ruby/gems/mthdspool/bin/mthdspool -r %s -l %s -o %s -f %s ")
-(setq anything-ruby-inspect-cmd
- "~/Dropbox/code/ruby/gems/mthdspool/bin/mthdspool -d %s -r %s -l %s ")
+;; (setq anything-ruby-mthds-object-cmd
+;; "~/Dropbox/code/ruby/gems/mthdspool/bin/mthdspool -r %s -l %s -o %s -f %s ")
+;; (setq anything-ruby-inspect-cmd
+;; "~/Dropbox/code/ruby/gems/mthdspool/bin/mthdspool -i %s -r %s -l %s -g %s ")
(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq require-final-newline t)
@@ -41,6 +41,7 @@
(setq save-place-file (concat dotfiles-dir "places"))
(setq visible-bell t)
(setq inhibit-startup-message t)
+(customize-variable (quote tab-stop-list))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
View
6 custom/jp-webdev.el
@@ -32,3 +32,9 @@
(dolist (i '("\\.htaccess\\'" "httpd\\.conf\\'" "srm\\.conf\\'"
"access\\.conf\\'" "sites-\\(available\\|enabled\\)/"))
(add-to-list 'auto-mode-alist (cons i 'apache-mode)))
+
+(setq scss-sass-options '("--style" "compressed"))
+(defun jp-scss-mode-hook()
+ (setq cssm-indent-function #'cssm-c-style-indenter)
+ ;; (setq scss-sass-options '("--style" "compressed"))
+ (rainbow-mode t))
View
1  custom/lib/jp-lib-anything.el
@@ -21,7 +21,6 @@
(require 'anything-git-goto)
(require 'anything-etags2)
-
(defun jp-anything-regexp ()
(interactive)
(anything-other-buffer
View
6 custom/lib/jp-lib-hooks.el
@@ -44,6 +44,10 @@
(add-hook 'before-save-hook 'jp-cleanup-buffer)
(local-set-key (kbd "<return>") 'newline-and-indent)))
+(add-hook 'scss-mode-hook
+ '(lambda ()
+ (jp-scss-mode-hook)))
+
(add-hook 'css-mode-hook
'(lambda ()
(setq css-indent-offset 2)
@@ -53,6 +57,8 @@
(add-hook 'markdown-mode-hook
(lambda ()
+ (local-set-key [(meta up)] 'beginning-of-buffer)
+ (local-set-key [(meta down)] 'end-of-buffer)
(font-lock-add-keywords nil jp-show-tabs)
(font-lock-add-keywords
nil '(("\\<\\(FIX\\|TODO\\|FIXME\\|HACK\\|REFACTOR\\):"
View
5 custom/lib/jp-lib-module-loader.el
@@ -27,6 +27,7 @@
(require 'jp-lib-hooks)
(load-file (concat jpablobr-dir "/jp-keyboard.el"))
(require 'jp-keyboard)
+ (jp-load-ruby-frontend)
(jp-shell)
(ibuffer)
(turn-on-xclip)
@@ -131,11 +132,13 @@
(load-file (concat jpablobr-dir "/jp-php.el"))
(require 'jp-php))
-(defun jp-load-haml-scss ()
+(defun jp-load-ruby-frontend ()
(interactive)
(require 'scss-mode)
+ (require 'sass-mode)
(require 'flymake-haml)
(require 'haml-mode)
+ (require 'coffee-mode)
(setq haml-dir (concat vendor-dir "/haml"))
(add-to-list 'load-path haml-dir)
(add-to-list 'auto-mode-alist '("\\.haml?$" . haml-mode))
View
13 custom/lib/jp-lib-ruby.el
@@ -32,10 +32,15 @@
(let ((buffer (shell "*Passenger Server at port 3000*")))
(comint-send-string buffer (concat "passenger start -p 3000 -e development" "\n"))))
+(defun jp-rails-unicorn-server:start ()
+ (interactive)
+ (let ((buffer (shell (concat "*Unicorn Rails Server @ " (jp-home-path) ))))
+ (comint-send-string buffer "unicorn_rails\n")))
+
(defun jp-rails-server:start ()
(interactive)
(let ((buffer (shell (concat "*Rails Server @ " (jp-home-path) "at port 3000*"))))
- (comint-send-string buffer (concat (jp-rails-root) "/script/rails s -p 3000 -e development" "\n"))))
+ (comint-send-string buffer "./script/rails server\n")))
(defun jp-rdebug-rails:start ()
(interactive)
@@ -61,7 +66,7 @@
(interactive)
(let ((buffer (shell (concat "*Rails Console @ " (jp-home-path) "*"))))
(font-lock-mode)
- (comint-send-string buffer "pry -r ./config/environment\n")))
+ (comint-send-string buffer "./script/rails console \n")))
(defun jp-rails-root (&optional dir)
(or dir (setq dir default-directory))
@@ -173,7 +178,7 @@ See the variable `align-rules-list' for more details.")
"end"
"#"
(lambda (&rest args) (ruby-end-of-block))
- ;(lambda (&rest args) (ruby-beginning-of-defun))
+ ;(lambda (&rest args) (ruby-beginning-of-defun))
)
hs-special-modes-alist)))
(hs-minor-mode arg))
@@ -224,7 +229,7 @@ See the variable `align-rules-list' for more details.")
(goto-char (- (point) (+ 1 (length prefix))))
(when (and (looking-at "\\.")
(capital-word-p (word-at-point))
- (el4r-ruby-eval
+ (el4r-ruby-eval
(format "::%s rescue nil" (word-at-point))))
(let* ((cmd "%s.public_methods.map{|i| i.match(/^%s/) ? i.gsub(/^%s/, '') : nil }.compact.sort{|x,y| x.size <=> y.size}")
(cmd (if maxnum (concat cmd (format "[0...%s]" maxnum)) cmd)))
View
3  vendor/anything/anything-config.el
@@ -8161,6 +8161,7 @@ When nil, fallback to `browse-url-browser-function'.")
(defvar anything-c-source-occur
'((name . "Occur")
(init . anything-c-occur-init)
+ (candidate-number-limit . 9999)
(candidates-in-buffer)
(migemo)
(get-line . anything-c-occur-get-line)
@@ -8189,7 +8190,7 @@ Line is parsed for BEG position to END position."
(anything-candidate-buffer anything-current-buffer)
(with-current-buffer anything-current-buffer
(jit-lock-fontify-now))))
- (candidate-number-limit . 9999)
+;; (candidate-number-limit . 9999)
(candidates-in-buffer)
(get-line . anything-c-browse-code-get-line)
(type . line)
View
730 vendor/misc/coffee-mode.el
@@ -0,0 +1,730 @@
+;;; coffee-mode.el --- Major mode to edit CoffeeScript files in Emacs
+
+;; Copyright (C) 2010 Chris Wanstrath
+
+;; Version: 0.4.0
+;; Keywords: CoffeeScript major mode
+;; Author: Chris Wanstrath <chris@ozmm.org>
+;; URL: http://github.com/defunkt/coffee-mode
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; 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; if not, write to the Free Software
+;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary
+
+;; For commentary please see the README.md or
+;; http://github.com/defunkt/coffee-mode#readme
+
+;;; Installation
+
+;; In your shell:
+
+;; $ cd ~/.emacs.d/vendor
+;; $ git clone git://github.com/defunkt/coffee-mode.git
+
+;; In your emacs config:
+
+;; (add-to-list 'load-path "~/.emacs.d/vendor/coffee-mode")
+;; (require 'coffee-mode)
+
+;;; Thanks
+
+;; Major thanks to http://xahlee.org/emacs/elisp_syntax_coloring.html
+;; the instructions.
+
+;; Also thanks to Jason Blevins's markdown-mode.el and Steve Yegge's
+;; js2-mode for guidance.
+
+;; TODO:
+;; - Execute {buffer,region,line} and show output in new buffer
+;; - Make prototype accessor assignments like `String::length: -> 10` pretty.
+;; - mirror-mode - close brackets and parens automatically
+
+;;; Code:
+
+(require 'comint)
+(require 'easymenu)
+(require 'font-lock)
+
+(eval-when-compile
+ (require 'cl))
+
+;;
+;; Customizable Variables
+;;
+
+(defconst coffee-mode-version "0.3.0"
+ "The version of this `coffee-mode'.")
+
+(defgroup coffee nil
+ "A CoffeeScript major mode."
+ :group 'languages)
+
+(defcustom coffee-debug-mode nil
+ "Whether to run in debug mode or not. Logs to `*Messages*'."
+ :type 'boolean
+ :group 'coffee-mode)
+
+(defcustom coffee-js-mode 'js2-mode
+ "The mode to use when viewing compiled JavaScript."
+ :type 'string
+ :group 'coffee)
+
+(defcustom coffee-cleanup-whitespace t
+ "Should we `delete-trailing-whitespace' on save? Probably."
+ :type 'boolean
+ :group 'coffee)
+
+(defcustom coffee-tab-width tab-width
+ "The tab width to use when indenting."
+ :type 'integer
+ :group 'coffee)
+
+(defcustom coffee-command "coffee"
+ "The CoffeeScript command used for evaluating code. Must be in your
+path."
+ :type 'string
+ :group 'coffee)
+
+(defcustom js2coffee-command "js2coffee"
+ "The js2coffee command used for evaluating code. Must be in your
+path."
+ :type 'string
+ :group 'coffee)
+
+
+(defcustom coffee-args-repl '("-i")
+ "The command line arguments to pass to `coffee-command' to start a REPL."
+ :type 'list
+ :group 'coffee)
+
+(defcustom coffee-args-compile '("-c")
+ "The command line arguments to pass to `coffee-command' when compiling a file."
+ :type 'list
+ :group 'coffee)
+
+(defcustom coffee-cygwin-mode t
+ "For Windows systems, add support for Cygwin-style absolute paths."
+ :type 'boolean
+ :group 'coffee)
+
+(defcustom coffee-cygwin-prefix "/cygdrive/C"
+ "The prefix with which to replace the drive-letter for your Windows partition, e.g. 'C:' would be replaced by '/c/cygdrive'."
+ :type 'string
+ :group 'coffee)
+
+(defcustom coffee-compiled-buffer-name "*coffee-compiled*"
+ "The name of the scratch buffer used when compiling CoffeeScript."
+ :type 'string
+ :group 'coffee)
+
+(defcustom coffee-compile-jump-to-error t
+ "Whether to jump to the first error if compilation fails.
+Please note that the coffee compiler doesn't always give a line
+number for the issue and in that case it is not possible to jump
+to the error, of course."
+ :type 'boolean
+ :group 'coffee)
+
+(defcustom coffee-watch-buffer-name "*coffee-watch*"
+ "The name of the scratch buffer used when using the --watch flag with CoffeeScript."
+ :type 'string
+ :group 'coffee)
+
+(defvar coffee-mode-hook nil
+ "A hook for you to run your own code when the mode is loaded.")
+
+(defvar coffee-mode-map (make-keymap)
+ "Keymap for CoffeeScript major mode.")
+
+;;
+;; Compat
+;;
+
+(unless (fboundp 'apply-partially)
+ (defun apply-partially (fun &rest args)
+ "Return a function that is a partial application of FUN to ARGS.
+ARGS is a list of the first N arguments to pass to FUN.
+The result is a new function which does the same as FUN, except that
+the first N arguments are fixed at the values with which this function
+was called."
+ (lexical-let ((fun fun) (args1 args))
+ (lambda (&rest args2) (apply fun (append args1 args2))))))
+
+;;
+;; Macros
+;;
+
+(defmacro setd (var val)
+ "Like setq but optionally logs the variable's value using `coffee-debug'."
+ (if (and (boundp 'coffee-debug-mode) coffee-debug-mode)
+ `(progn
+ (coffee-debug "%s: %s" ',var ,val)
+ (setq ,var ,val))
+ `(setq ,var ,val)))
+
+(defun coffee-debug (string &rest args)
+ "Print a message when in debug mode."
+ (when coffee-debug-mode
+ (apply 'message (append (list string) args))))
+
+(defmacro coffee-line-as-string ()
+ "Returns the current line as a string."
+ `(buffer-substring (point-at-bol) (point-at-eol)))
+
+;;
+;; Commands
+;;
+
+(defun coffee-repl ()
+ "Launch a CoffeeScript REPL using `coffee-command' as an inferior mode."
+ (interactive)
+
+ (unless (comint-check-proc "*CoffeeREPL*")
+ (set-buffer
+ (apply 'make-comint "CoffeeREPL"
+ coffee-command nil coffee-args-repl)))
+
+ (pop-to-buffer "*CoffeeREPL*"))
+
+(defun coffee-compiled-file-name (&optional filename)
+ "Returns the name of the JavaScript file compiled from a CoffeeScript file.
+If FILENAME is omitted, the current buffer's file name is used."
+ (concat (file-name-sans-extension (or filename (buffer-file-name))) ".js"))
+
+(defun coffee-compile-file ()
+ "Compiles and saves the current file to disk. Doesn't open in a buffer.."
+ (interactive)
+ (let ((compiler-output (shell-command-to-string (coffee-command-compile (buffer-file-name)))))
+ (if (string= compiler-output "")
+ (message "Compiled and saved %s" (coffee-compiled-file-name))
+ (let* ((msg (car (split-string compiler-output "[\n\r]+")))
+ (line (and (string-match "on line \\([0-9]+\\)" msg)
+ (string-to-number (match-string 1 msg)))))
+ (message msg)
+ (when (and coffee-compile-jump-to-error line (> line 0))
+ (goto-char (point-min))
+ (forward-line (1- line)))))))
+
+(defun coffee-compile-buffer ()
+ "Compiles the current buffer and displays the JS in another buffer."
+ (interactive)
+ (save-excursion
+ (coffee-compile-region (point-min) (point-max))))
+
+(defun coffee-compile-region (start end)
+ "Compiles a region and displays the JS in another buffer."
+ (interactive "r")
+
+ (let ((buffer (get-buffer coffee-compiled-buffer-name)))
+ (when buffer
+ (kill-buffer buffer)))
+
+ (apply (apply-partially 'call-process-region start end coffee-command nil
+ (get-buffer-create coffee-compiled-buffer-name)
+ nil)
+ (append coffee-args-compile (list "-s" "-p")))
+ (switch-to-buffer (get-buffer coffee-compiled-buffer-name))
+ (funcall coffee-js-mode)
+ (goto-char (point-min)))
+
+(defun coffee-js2coffee-replace-region (start end)
+ "Replace JS to coffee in current buffer."
+ (interactive "r")
+
+ (let ((buffer (get-buffer coffee-compiled-buffer-name)))
+ (when buffer
+ (kill-buffer buffer)))
+
+ (call-process-region start end
+ js2coffee-command nil
+ (current-buffer)
+ )
+ (delete-region start end)
+ )
+
+(defun coffee-show-version ()
+ "Prints the `coffee-mode' version."
+ (interactive)
+ (message (concat "coffee-mode v" coffee-mode-version)))
+
+(defun coffee-open-reference ()
+ "Open browser to CoffeeScript reference."
+ (interactive)
+ (browse-url "http://jashkenas.github.com/coffee-script/"))
+
+(defun coffee-open-node-reference ()
+ "Open browser to node.js documentation."
+ (interactive)
+ (browse-url "http://nodejs.org/docs/"))
+
+(defun coffee-open-github ()
+ "Open browser to `coffee-mode' project on GithHub."
+ (interactive)
+ (browse-url "http://github.com/defunkt/coffee-mode"))
+
+(defun coffee-watch (dir-or-file)
+ "Run `coffee-run-cmd' with the --watch flag enabled for a directory or file"
+ (interactive "fDirectory or File: ")
+ (let ((coffee-compiled-buffer-name coffee-watch-buffer-name)
+ (args (mapconcat 'identity (append coffee-args-compile (list "--watch" (coffee-universal-path dir-or-file))) " ")))
+ (coffee-run-cmd args)))
+
+;;
+;; Menubar
+;;
+
+(easy-menu-define coffee-mode-menu coffee-mode-map
+ "Menu for CoffeeScript mode"
+ '("CoffeeScript"
+ ["Compile File" coffee-compile-file]
+ ["Compile Buffer" coffee-compile-buffer]
+ ["Compile Region" coffee-compile-region]
+ ["REPL" coffee-repl]
+ "---"
+ ["CoffeeScript Reference" coffee-open-reference]
+ ["node.js Reference" coffee-open-node-reference]
+ ["coffee-mode on GitHub" coffee-open-github]
+ ["Version" coffee-show-version]
+ ))
+
+;;
+;; Define Language Syntax
+;;
+
+;; String literals
+(defvar coffee-string-regexp "\"\\([^\\]\\|\\\\.\\)*?\"\\|'\\([^\\]\\|\\\\.\\)*?'")
+
+;; Instance variables (implicit this)
+(defvar coffee-this-regexp "@\\(\\w\\|_\\)*\\|this")
+
+;; Prototype::access
+(defvar coffee-prototype-regexp "\\(\\(\\w\\|\\.\\|_\\| \\|$\\)+?\\)::\\(\\(\\w\\|\\.\\|_\\| \\|$\\)+?\\):")
+
+;; Assignment
+(defvar coffee-assign-regexp "\\(\\(\\w\\|\\.\\|_\\|$\\)+?\s*\\):")
+
+;; Lambda
+(defvar coffee-lambda-regexp "\\((.+)\\)?\\s *\\(->\\|=>\\)")
+
+;; Namespaces
+(defvar coffee-namespace-regexp "\\b\\(class\\s +\\(\\S +\\)\\)\\b")
+
+;; Booleans
+(defvar coffee-boolean-regexp "\\b\\(true\\|false\\|yes\\|no\\|on\\|off\\|null\\|undefined\\)\\b")
+
+;; Regular Expressions
+(defvar coffee-regexp-regexp "\\/\\(\\\\.\\|\\[\\(\\\\.\\|.\\)+?\\]\\|[^/]\\)+?\\/")
+
+;; JavaScript Keywords
+(defvar coffee-js-keywords
+ '("if" "else" "new" "return" "try" "catch"
+ "finally" "throw" "break" "continue" "for" "in" "while"
+ "delete" "instanceof" "typeof" "switch" "super" "extends"
+ "class" "until" "loop"))
+
+;; Reserved keywords either by JS or CS.
+(defvar coffee-js-reserved
+ '("case" "default" "do" "function" "var" "void" "with"
+ "const" "let" "debugger" "enum" "export" "import" "native"
+ "__extends" "__hasProp"))
+
+;; CoffeeScript keywords.
+(defvar coffee-cs-keywords
+ '("then" "unless" "and" "or" "is"
+ "isnt" "not" "of" "by" "where" "when"))
+
+;; Regular expression combining the above three lists.
+(defvar coffee-keywords-regexp (regexp-opt
+ (append
+ coffee-js-reserved
+ coffee-js-keywords
+ coffee-cs-keywords) 'words))
+
+
+;; Create the list for font-lock. Each class of keyword is given a
+;; particular face.
+(defvar coffee-font-lock-keywords
+ ;; *Note*: order below matters. `coffee-keywords-regexp' goes last
+ ;; because otherwise the keyword "state" in the function
+ ;; "state_entry" would be highlighted.
+ `((,coffee-string-regexp . font-lock-string-face)
+ (,coffee-this-regexp . font-lock-variable-name-face)
+ (,coffee-prototype-regexp . font-lock-variable-name-face)
+ (,coffee-assign-regexp . font-lock-type-face)
+ (,coffee-regexp-regexp . font-lock-constant-face)
+ (,coffee-boolean-regexp . font-lock-constant-face)
+ (,coffee-keywords-regexp . font-lock-keyword-face)))
+
+;;
+;; Helper Functions
+;;
+
+(defun coffee-before-save ()
+ "Hook run before file is saved. Deletes whitespace if
+`coffee-cleanup-whitespace' is non-nil."
+ (when coffee-cleanup-whitespace
+ (delete-trailing-whitespace)))
+
+(defun coffee-comment-dwim (arg)
+ "Comment or uncomment current line or region in a smart way.
+For detail, see `comment-dwim'."
+ (interactive "*P")
+ (require 'newcomment)
+ (let ((deactivate-mark nil) (comment-start "#") (comment-end ""))
+ (comment-dwim arg)))
+
+(defun coffee-cygwin-path (expanded-file-name)
+ "Given an expanded file name, derive the absolute Cygwin path based on `coffee-cygwin-prefix'."
+ (replace-regexp-in-string "^[a-zA-Z]:" coffee-cygwin-prefix expanded-file-name t))
+
+(defun coffee-universal-path (file-name)
+ "Handle different paths for different OS configurations for CoffeeScript"
+ (let ((full-file-name (expand-file-name file-name)))
+ (if (and (equal system-type 'windows-nt)
+ coffee-cygwin-mode)
+ (coffee-cygwin-path full-file-name)
+ full-file-name)))
+
+(defun coffee-command-compile (file-name)
+ "The `coffee-command' with args to compile a file."
+ (let ((full-file-name (coffee-universal-path file-name)))
+ (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list full-file-name)) " ")))
+
+(defun coffee-run-cmd (args)
+ "Given an arbitrary set of arguments for the `coffee-command', compile the command and show output in a custom compilation buffer."
+ (interactive "sArguments: ")
+ (let ((compilation-buffer-name-function (lambda (this-mode)
+ (generate-new-buffer-name coffee-compiled-buffer-name))))
+ (compile (concat coffee-command " " args))))
+
+;;
+;; imenu support
+;;
+
+;; This is a pretty naive but workable way of doing it. First we look
+;; for any lines that starting with `coffee-assign-regexp' that include
+;; `coffee-lambda-regexp' then add those tokens to the list.
+;;
+;; Should cover cases like these:
+;;
+;; minus: (x, y) -> x - y
+;; String::length: -> 10
+;; block: ->
+;; print('potion')
+;;
+;; Next we look for any line that starts with `class' or
+;; `coffee-assign-regexp' followed by `{` and drop into a
+;; namespace. This means we search one indentation level deeper for
+;; more assignments and add them to the alist prefixed with the
+;; namespace name.
+;;
+;; Should cover cases like these:
+;;
+;; class Person
+;; print: ->
+;; print 'My name is ' + this.name + '.'
+;;
+;; class Policeman extends Person
+;; constructor: (rank) ->
+;; @rank: rank
+;; print: ->
+;; print 'My name is ' + this.name + " and I'm a " + this.rank + '.'
+;;
+;; TODO:
+;; app = {
+;; window: {width: 200, height: 200}
+;; para: -> 'Welcome.'
+;; button: -> 'OK'
+;; }
+
+(defun coffee-imenu-create-index ()
+ "Create an imenu index of all methods in the buffer."
+ (interactive)
+
+ ;; This function is called within a `save-excursion' so we're safe.
+ (goto-char (point-min))
+
+ (let ((index-alist '()) assign pos indent ns-name ns-indent)
+ ;; Go through every assignment that includes -> or => on the same
+ ;; line or starts with `class'.
+ (while (re-search-forward
+ (concat "^\\(\\s *\\)"
+ "\\("
+ coffee-assign-regexp
+ ".+?"
+ coffee-lambda-regexp
+ "\\|"
+ coffee-namespace-regexp
+ "\\)")
+ (point-max)
+ t)
+
+ (coffee-debug "Match: %s" (match-string 0))
+
+ ;; If this is the start of a new namespace, save the namespace's
+ ;; indentation level and name.
+ (when (match-string 8)
+ ;; Set the name.
+ (setq ns-name (match-string 8))
+
+ ;; If this is a class declaration, add :: to the namespace.
+ (setq ns-name (concat ns-name "::"))
+
+ ;; Save the indentation level.
+ (setq ns-indent (length (match-string 1)))
+
+ ;; Debug
+ (coffee-debug "ns: Found %s with indent %s" ns-name ns-indent))
+
+ ;; If this is an assignment, save the token being
+ ;; assigned. `Please.print:` will be `Please.print`, `block:`
+ ;; will be `block`, etc.
+ (when (setq assign (match-string 3))
+ ;; The position of the match in the buffer.
+ (setq pos (match-beginning 3))
+
+ ;; The indent level of this match
+ (setq indent (length (match-string 1)))
+
+ ;; If we're within the context of a namespace, add that to the
+ ;; front of the assign, e.g.
+ ;; constructor: => Policeman::constructor
+ (when (and ns-name (> indent ns-indent))
+ (setq assign (concat ns-name assign)))
+
+ (coffee-debug "=: Found %s with indent %s" assign indent)
+
+ ;; Clear the namespace if we're no longer indented deeper
+ ;; than it.
+ (when (and ns-name (<= indent ns-indent))
+ (coffee-debug "ns: Clearing %s" ns-name)
+ (setq ns-name nil)
+ (setq ns-indent nil))
+
+ ;; Add this to the alist. Done.
+ (push (cons assign pos) index-alist)))
+
+ ;; Return the alist.
+ index-alist))
+
+;;
+;; Indentation
+;;
+
+;;; The theory is explained in the README.
+
+(defun coffee-indent-line ()
+ "Indent current line as CoffeeScript."
+ (interactive)
+
+ (if (= (point) (point-at-bol))
+ (insert-tab)
+ (save-excursion
+ (let ((prev-indent 0) (cur-indent 0))
+ ;; Figure out the indentation of the previous line
+ (setd prev-indent (coffee-previous-indent))
+
+ ;; Figure out the current line's indentation
+ (setd cur-indent (current-indentation))
+
+ ;; Shift one column to the left
+ (beginning-of-line)
+ (insert-tab)
+
+ (coffee-debug "point: %s" (point))
+ (coffee-debug "point-at-bol: %s" (point-at-bol))
+
+ (when (= (point-at-bol) (point))
+ (forward-char coffee-tab-width))
+
+ (coffee-debug "New indent: %s" (current-indentation))
+
+ ;; We're too far, remove all indentation.
+ (when (> (- (current-indentation) prev-indent) coffee-tab-width)
+ (backward-to-indentation 0)
+ (delete-region (point-at-bol) (point)))))))
+
+(defun coffee-previous-indent ()
+ "Return the indentation level of the previous non-blank line."
+
+ (save-excursion
+ (forward-line -1)
+ (if (bobp)
+ 0
+ (progn
+ (while (and (coffee-line-empty-p) (not (bobp))) (forward-line -1))
+ (current-indentation)))))
+
+(defun coffee-line-empty-p ()
+ "Is this line empty? Returns non-nil if so, nil if not."
+ (or (bobp)
+ (string-match "^\\s *$" (coffee-line-as-string))))
+
+(defun coffee-newline-and-indent ()
+ "Inserts a newline and indents it to the same level as the previous line."
+ (interactive)
+
+ ;; Remember the current line indentation level,
+ ;; insert a newline, and indent the newline to the same
+ ;; level as the previous line.
+ (let ((prev-indent (current-indentation)) (indent-next nil))
+ (delete-horizontal-space t)
+ (newline)
+ (insert-tab (/ prev-indent coffee-tab-width))
+
+ ;; We need to insert an additional tab because the last line was special.
+ (when (coffee-line-wants-indent)
+ (insert-tab)))
+
+ ;; Last line was a comment so this one should probably be,
+ ;; too. Makes it easy to write multi-line comments (like the one I'm
+ ;; writing right now).
+ (when (coffee-previous-line-is-comment)
+ (insert "# ")))
+
+;; Indenters help determine whether the current line should be
+;; indented further based on the content of the previous line. If a
+;; line starts with `class', for instance, you're probably going to
+;; want to indent the next line.
+
+(defvar coffee-indenters-bol '("class" "for" "if" "try")
+ "Keywords or syntax whose presence at the start of a line means the
+next line should probably be indented.")
+
+(defun coffee-indenters-bol-regexp ()
+ "Builds a regexp out of `coffee-indenters-bol' words."
+ (regexp-opt coffee-indenters-bol 'words))
+
+(defvar coffee-indenters-eol '(?> ?{ ?\[)
+ "Single characters at the end of a line that mean the next line
+should probably be indented.")
+
+(defun coffee-line-wants-indent ()
+ "Does the current line want to be indented deeper than the previous
+line? Returns `t' or `nil'. See the README for more details."
+ (interactive)
+
+ (save-excursion
+ (let ((indenter-at-bol) (indenter-at-eol))
+ ;; Go back a line and to the first character.
+ (forward-line -1)
+ (backward-to-indentation 0)
+
+ ;; If the next few characters match one of our magic indenter
+ ;; keywords, we want to indent the line we were on originally.
+ (when (looking-at (coffee-indenters-bol-regexp))
+ (setd indenter-at-bol t))
+
+ ;; If that didn't match, go to the back of the line and check to
+ ;; see if the last character matches one of our indenter
+ ;; characters.
+ (when (not indenter-at-bol)
+ (end-of-line)
+
+ ;; Optimized for speed - checks only the last character.
+ (when (some (lambda (char)
+ (= (char-before) char))
+ coffee-indenters-eol)
+ (setd indenter-at-eol t)))
+
+ ;; If we found an indenter, return `t'.
+ (or indenter-at-bol indenter-at-eol))))
+
+(defun coffee-previous-line-is-comment ()
+ "Returns `t' if the previous line is a CoffeeScript comment."
+ (save-excursion
+ (forward-line -1)
+ (coffee-line-is-comment)))
+
+(defun coffee-line-is-comment ()
+ "Returns `t' if the current line is a CoffeeScript comment."
+ (save-excursion
+ (backward-to-indentation 0)
+ (= (char-after) (string-to-char "#"))))
+
+;;
+;; Define Major Mode
+;;
+
+;;;###autoload
+(define-derived-mode coffee-mode fundamental-mode
+ "Coffee"
+ "Major mode for editing CoffeeScript."
+
+ ;; key bindings
+ (define-key coffee-mode-map (kbd "A-r") 'coffee-compile-buffer)
+ (define-key coffee-mode-map (kbd "A-R") 'coffee-compile-region)
+ (define-key coffee-mode-map (kbd "A-M-r") 'coffee-repl)
+ (define-key coffee-mode-map [remap comment-dwim] 'coffee-comment-dwim)
+ (define-key coffee-mode-map "\C-m" 'coffee-newline-and-indent)
+ (define-key coffee-mode-map "\C-c\C-o\C-s" 'coffee-cos-mode)
+
+ ;; code for syntax highlighting
+ (setq font-lock-defaults '((coffee-font-lock-keywords)))
+
+ ;; perl style comment: "# ..."
+ (modify-syntax-entry ?# "< b" coffee-mode-syntax-table)
+ (modify-syntax-entry ?\n "> b" coffee-mode-syntax-table)
+ (make-local-variable 'comment-start)
+ (setq comment-start "#")
+
+ ;; single quote strings
+ (modify-syntax-entry ?' "\"" coffee-mode-syntax-table)
+
+ ;; indentation
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'coffee-indent-line)
+ (set (make-local-variable 'tab-width) coffee-tab-width)
+
+ ;; imenu
+ (make-local-variable 'imenu-create-index-function)
+ (setq imenu-create-index-function 'coffee-imenu-create-index)
+
+ ;; no tabs
+ (setq indent-tabs-mode nil)
+
+ ;; hooks
+ (set (make-local-variable 'before-save-hook) 'coffee-before-save))
+
+;;
+;; Compile-on-Save minor mode
+;;
+
+(defvar coffee-cos-mode-line " CoS")
+(make-variable-buffer-local 'coffee-cos-mode-line)
+
+(define-minor-mode coffee-cos-mode
+ "Toggle compile-on-save for coffee-mode."
+ :group 'coffee-cos :lighter coffee-cos-mode-line
+ (cond
+ (coffee-cos-mode
+ (add-hook 'after-save-hook 'coffee-compile-file nil t))
+ (t
+ (remove-hook 'after-save-hook 'coffee-compile-file t))))
+
+(provide 'coffee-mode)
+
+;;
+;; On Load
+;;
+
+;; Run coffee-mode for files ending in .coffee.
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
+;;;###autoload
+(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
+;;; coffee-mode.el ends here
View
431 vendor/misc/css-mode.el
@@ -0,0 +1,431 @@
+;;; css-mode.el --- Major mode for editing Cascading Style Sheets
+
+;; Copyright (C) 2005
+;; Karl Landstrom.
+
+;; Author: Karl Landström <kland at comhem dot se>
+;; Maintainer: Karl Landström <kland at comhem dot se>
+;; Version: 1.0
+;; Keywords: languages, hypermedia
+;; 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 2, 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:
+
+;; Installation:
+
+;; Put this file in a folder where Emacs can find it. On GNU/Linux
+;; it's usually /usr/local/share/emacs/site-lisp/ and on Windows it's
+;; something like "C:\Program Files\Emacs<version>\site-lisp". To
+;; make it run slightly faster you can also compile it from Emacs (M-x
+;; `emacs-lisp-byte-compile'). Then add
+;;
+;; (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
+;; (autoload 'css-mode "css-mode" nil t)
+
+;; to your .emacs initialization file (_emacs on Windows).
+
+;;; Code:
+
+;;Other js-mode addition from xemacs js mode for speedbar
+(require 'comint)
+
+(eval-when-compile
+ (require 'regexp-opt)
+ (require 'font-lock)
+ (require 'speedbar)
+ )
+;;finish
+
+;; Speedbar handling
+(if (fboundp 'speedbar-add-supported-extension)
+ (speedbar-add-supported-extension '(".css")))
+
+
+(defcustom css-indent-level 3 "Number of spaces for each indent step.")
+
+
+;; KEYMAP
+
+(defvar css-mode-map nil "Keymap in CSS mode.")
+
+(unless css-mode-map (setq css-mode-map (make-sparse-keymap)))
+
+
+;; SYNTAX TABLE AND PARSING
+
+(defvar css-mode-syntax-table
+ (let ((table (make-syntax-table)))
+ (modify-syntax-entry ?/ ". 14" table)
+ (modify-syntax-entry ?* ". 23" table)
+ (modify-syntax-entry ?- "w" table)
+ table)
+ "Syntax table used in CSS mode.")
+
+
+;; The css-re-search-* functions are copied from my JavaScript mode,
+;; `javascript.el'.
+
+(defun css-re-search-forward-inner (regexp &optional bound count)
+ "Used by `css-re-search-forward'."
+ (let ((parse)
+ (saved-point (point-min)))
+ (while (> count 0)
+ (re-search-forward regexp bound)
+ (setq parse (parse-partial-sexp saved-point (point)))
+ (cond ((nth 3 parse)
+ (re-search-forward
+ (concat "\\([^\\]\\|^\\)" (string (nth 3 parse)))
+ (save-excursion (end-of-line) (point)) t))
+ ((nth 7 parse)
+ (forward-line))
+ ((or (nth 4 parse)
+ (and (eq (char-before) ?\/) (eq (char-after) ?\*)))
+ (re-search-forward "\\*/"))
+ (t
+ (setq count (1- count))))
+ (setq saved-point (point))))
+ (point))
+
+
+(defun css-re-search-forward (regexp &optional bound noerror count)
+ "Invokes `re-search-forward' but treats the buffer as if strings and
+comments have been removed."
+ (let ((saved-point (point))
+ (search-expr
+ (cond ((null count)
+ '(css-re-search-forward-inner regexp bound 1))
+ ((< count 0)
+ '(css-re-search-backward-inner regexp bound (- count)))
+ ((> count 0)
+ '(css-re-search-forward-inner regexp bound count)))))
+ (condition-case err
+ (eval search-expr)
+ (search-failed
+ (goto-char saved-point)
+ (unless noerror
+ (error (error-message-string err)))))))
+
+
+(defun css-re-search-backward-inner (regexp &optional bound count)
+ "Used by `css-re-search-backward'."
+ (let ((parse)
+ (saved-point (point-min)))
+ (while (> count 0)
+ (re-search-backward regexp bound)
+ (setq parse (parse-partial-sexp saved-point (point)))
+ (cond ((nth 3 parse)
+ (re-search-backward
+ (concat "\\([^\\]\\|^\\)" (string (nth 3 parse)))
+ (save-excursion (beginning-of-line) (point)) t))
+ ((nth 7 parse)
+ (goto-char (nth 8 parse)))
+ ((or (nth 4 parse)
+ (and (eq (char-before) ?/) (eq (char-after) ?*)))
+ (re-search-backward "/\\*"))
+ (t
+ (setq count (1- count))))))
+ (point))
+
+
+(defun css-re-search-backward (regexp &optional bound noerror count)
+ "Invokes `re-search-backward' but treats the buffer as if strings
+and comments have been removed."
+ (let ((saved-point (point))
+ (search-expr
+ (cond ((null count)
+ '(css-re-search-backward-inner regexp bound 1))
+ ((< count 0)
+ '(css-re-search-forward-inner regexp bound (- count)))
+ ((> count 0)
+ '(css-re-search-backward-inner regexp bound count)))))
+ (condition-case err
+ (eval search-expr)
+ (search-failed
+ (goto-char saved-point)
+ (unless noerror
+ (error (error-message-string err)))))))
+
+
+;; FONT LOCK
+
+(defconst css-font-lock-keywords-1
+ (list
+
+ ;; selectors
+ (list "^[ \t]*[[:word:].#:]+[ \t]*\\([,{]\\|/\\*\\|$\\)"
+ (list "\\([[:word:].#:]+\\)[ \t]*\\(,\\|{.*\\|/\\*.*?\\*/\\|$\\)"
+ '(progn
+ (backward-char)
+ (if (nth 1 (parse-partial-sexp (point-min) (point)))
+ (end-of-line)
+ (beginning-of-line)))
+ '(end-of-line)
+ '(1 font-lock-function-name-face)))
+
+ ;; properties
+ (list "\\(\\w+\\)[ \t]*:" 1 font-lock-variable-name-face)
+
+ ;; values that need to be quoted
+ (list ":[ \t]*\\(\\w+[ \t]+\\w+\\)" 1 font-lock-warning-face)
+
+ ;; values (unquoted)
+;; (list ":[ \t]*\\(\"\\|\\w"
+;; "\\(.+?\\)\\(,\\|;\\|}\\|$\\)"
+;; '(backward-char)
+;; '(end-of-line)
+;; '(1 font-lock-string-face))
+))
+
+(defconst css-font-lock-keywords-2 css-font-lock-keywords-1)
+(defconst css-font-lock-keywords-3 css-font-lock-keywords-1)
+(defconst css-font-lock-keywords
+ '(css-font-lock-keywords-3 css-font-lock-keywords-1 css-font-lock-keywords-2
+ css-font-lock-keywords-3)
+ "See `font-lock-keywords'.")
+
+
+(defun css-indent-line ()
+ (interactive)
+ (let ((indent
+ (save-excursion
+ (back-to-indentation)
+ (let ((p (parse-partial-sexp (point-min) (point)))
+ (end-brace-p (looking-at "}")))
+ (cond
+ ((or (nth 8 p) (looking-at "/[/*]"))
+ (current-indentation))
+ ((save-excursion
+ (and (skip-chars-backward " \t\n:,")
+ (looking-at "[:,]")))
+ (save-excursion
+ (css-re-search-backward "^[ \t]*\\w")
+ (+ (current-indentation) css-indent-level)))
+ ((nth 1 p)
+ (save-excursion
+ (goto-char (nth 1 p))
+ (+ (current-indentation) (if end-brace-p 0 css-indent-level))))
+ (t
+ 0)))))
+ (offset (- (current-column) (current-indentation))))
+ (indent-line-to indent)
+ (if (> offset 0) (forward-char offset))))
+
+
+(defconst css-imenu-generic-expression
+ '((nil "^[ \t]*\\([[:word:].:#, \t]+\\)\\s-*{" 1))
+ "Regular expression matching any selector. Used by imenu.")
+
+;;;###autoload
+(defun css-mode ()
+ "Major mode for editing CSS source code.
+
+Key bindings:
+
+\\{css-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+
+ (use-local-map css-mode-map)
+ (set-syntax-table css-mode-syntax-table)
+ (set (make-local-variable 'indent-line-function) 'css-indent-line)
+ (set (make-local-variable 'font-lock-defaults) (list css-font-lock-keywords))
+
+ ;; Imenu
+ (setq imenu-case-fold-search nil)
+ (set (make-local-variable 'imenu-generic-expression)
+ css-imenu-generic-expression)
+
+ (when (featurep 'newcomment)
+ (set (make-local-variable 'comment-start) "/*")
+ (set (make-local-variable 'comment-end) "*/")
+ (set (make-local-variable 'comment-start-skip) "/\\*+ *")
+ (set (make-local-variable 'comment-end-skip) " *\\*+/")
+ (require 'advice)
+
+ (defadvice comment-dwim (after inhibit-indent)
+ "Indent new comment lines to column zero and insert only one space
+before a trailing comment."
+ (when (eq major-mode 'css-mode)
+ (let ((prs (parse-partial-sexp
+ (save-excursion (beginning-of-line) (point))
+ (point))))
+ (when (nth 4 prs)
+ (save-excursion
+ (goto-char (nth 8 prs))
+ (when (looking-at "/\\*[ \t]*\\*/")
+ (if (= (current-column) (current-indentation))
+ (indent-line-to 0)
+ (just-one-space))))))))
+
+ (ad-activate 'comment-dwim))
+
+ (setq major-mode 'css-mode)
+ (setq mode-name "CSS")
+ (run-hooks 'css-mode-hook))
+
+;;Other CSS Mode Add ExtraTrying
+
+(defvar css-mode-abbrev-table nil
+ "Abbreviation table used in `css-mode' buffers.")
+(define-abbrev-table 'css-mode-abbrev-table ())
+
+
+(defvar css-at-rule-keywords nil
+ "Keywords for CSS at rules" )
+(if css-at-rule-keywords nil
+ (setq css-at-rule-keywords
+ '("import" "media" "page" "font-face" "charset") ))
+
+(defvar css-at-rule-table nil
+ "Table for CSS at rules" )
+(if css-at-rule-table nil
+ (setq css-at-rule-table (make-vector 5 0))
+ (mapcar (lambda (x) (intern x css-at-rule-table))
+ css-at-rule-keywords ))
+
+(defvar css-element-keywords nil
+ "Common CSS elements" )
+(if css-element-keywords nil
+ (setq css-element-keywords
+ '("a" "address" "b" "blockquote" "body" "br" "cite"
+ "code" "dir" "div" "dd" "dl" "dt" "em" "form" "h1"
+ "h2" "h3" "h4" "h5" "h6" "hr" "i" "img" "kbd" "li"
+ "menu" "ol" "p" "pre" "samp" "span" "strong" "table"
+ "tr" "th" "td" "tt" "ul" "var" )))
+
+(defvar css-element-table nil
+ "Table for CSS elements" )
+(if css-element-table nil
+ (setq css-element-table (make-vector 5 0))
+ (mapcar (lambda (x) (intern x css-element-table))
+ css-element-keywords ))
+
+
+(defvar css-property-keywords nil "CSS properties" )
+(if css-property-keywords nil
+ (setq css-property-keywords
+'("azimuth" "background" "background-attachment" "background-color"
+ "background-image" "background-position" "background-repeat" "border"
+ "border-collapse" "border-color" "border-spacing" "border-style"
+ "border-top" "border-right" "border-bottom" "border-left"
+ "border-top-color" "border-right-color" "border-bottom-color"
+ "border-left-color" "border-top-style" "border-right-style"
+ "border-bottom-style" "border-left-style" "border-top-width"
+ "border-right-width" "border-bottom-width" "border-left-width"
+ "border-width" "bottom" "caption-side" "clear" "clip" "color"
+ "content" "counter-increment" "counter-reset" "cue" "cue-after"
+ "cue-before" "cursor" "direction" "display" "elevation" "empty-cells"
+ "float" "font" "font-family" "font-size" "font-size-adjust"
+ "font-stretch" "font-style" "font-variant" "font-weight" "height"
+ "left" "letter-spacing" "line-height" "list-style" "list-style-image"
+ "list-style-position" "list-style-type" "margin" "margin-top"
+ "margin-right" "margin-bottom" "margin-left" "marker-offset" "marks"
+ "max-height" "max-width" "min-height" "min-width" "orphans" "outline"
+ "outline-color" "outline-style" "outline-width" "overflow" "padding"
+ "padding-top" "padding-right" "padding-bottom" "padding-left" "page"
+ "page-break-after" "page-break-before" "page-break-inside" "pause"
+ "pause-after" "pause-before" "pitch" "pitch-range" "play-during"
+ "position" "quotes" "richness" "right" "size" "speak" "speak-header"
+ "speak-numeral" "speak-punctuation" "speech-rate" "stress"
+ "table-layout" "text-align" "text-decoration" "text-indent"
+ "text-shadow" "text-transform" "top" "unicode-bidi" "vertical-align"
+ "visibility" "voice-family" "volume" "white-space" "widows" "width"
+ "word-spacing" "z-index" )))
+
+(defvar css-property-table nil
+ "Table for CSS properties" )
+(if css-property-table nil
+ (setq css-property-table (make-vector 5 0))
+ (mapcar (lambda (x) (intern x css-property-table))
+ css-property-keywords ))
+
+
+
+(defun css-complete-symbol (&optional table predicate prettify)
+ (let* ((end (point))
+ (beg (save-excursion
+ (skip-syntax-backward "w")
+ (point)))
+ (pattern (buffer-substring beg end))
+ (table (or table obarray))
+ (completion (try-completion pattern table predicate)))
+ (cond ((eq completion t))
+ ((null completion)
+ (message "Can't find completion for \"%s\"" pattern))
+ ((not (string-equal pattern completion))
+ (delete-region beg end)
+ (insert completion))
+ (t
+ (message "Making completion list...")
+ (let ((list (all-completions pattern table predicate)))
+ (if prettify
+ (setq list (funcall prettify list)))
+ (with-output-to-temp-buffer "*Help*"
+ (display-completion-list list)))
+ (message "Making completion list...%s" "done")))))
+
+
+
+(defun css-complete-at-keyword ()
+ "Complete the standard element at point"
+ (interactive)
+ (let ((completion-ignore-case t))
+ (css-complete-symbol css-at-rule-table) ))
+
+(defun css-complete-element ()
+ "Complete the standard element at point"
+ (interactive)
+ (let ((completion-ignore-case t))
+ (css-complete-symbol css-element-table) ))
+
+(defun css-complete-property ()
+ "Complete the standard element at point"
+ (interactive)
+ (let ((completion-ignore-case t))
+ (css-complete-symbol css-property-table) ))
+
+
+(defvar css-mode-map ()
+ "Keymap used in CSS mode.")
+ (setq css-mode-map (make-sparse-keymap))
+ (define-key css-mode-map (read-kbd-macro "C-c C-c") 'css-insert-comment)
+ (define-key css-mode-map (read-kbd-macro "C-c C-u") 'css-insert-url)
+ (define-key css-mode-map "\C-c\C-a" 'css-complete-at-keyword)
+ (define-key css-mode-map "\C-c\C-e" 'css-complete-element)
+; (define-key css-mode-map "\C-c\C-p" 'css-complete-property)
+; (define-key css-mode-map (read-kbd-macro "C-RET") 'css-complete-property)
+ (define-key css-mode-map (read-kbd-macro "M-RET") 'css-complete-property)
+; (define-key css-mode-map (read-kbd-macro "TAB") 'css-complete-property)
+
+
+;)
+
+
+;;; Typing comment and url shortcuts-from old css-mode
+
+
+(define-skeleton css-insert-comment
+ "Inserts a full comment." nil
+ "/* " _ " */")
+
+(define-skeleton css-insert-url
+ "Inserts a URL." nil
+ "url(" _ ")")
+
+
+
+(provide 'css-mode)
+;;; css-mode.el ends here
2  vendor/ruby/anything-ruby-mthds
@@ -1 +1 @@
-Subproject commit 760904c585ef511ad7a9c95f929f061c23d89366
+Subproject commit 0c94093f1636ea48d34940877fea332f5ba32327
View
209 vendor/ruby/sass-mode.el
@@ -0,0 +1,209 @@
+;;; sass-mode.el --- Major mode for editing Sass files
+
+;; Copyright (c) 2007, 2008 Nathan Weizenbaum
+
+;; Author: Nathan Weizenbaum
+;; URL: http://github.com/nex3/haml/tree/master
+;; Version: 3.0.15
+;; Created: 2007-03-15
+;; By: Nathan Weizenbaum
+;; Keywords: markup, language, css
+;; Package-Requires: ((haml-mode "3.0.15"))
+
+;;; Commentary:
+
+;; Because Sass's indentation schema is similar
+;; to that of YAML and Python, many indentation-related
+;; functions are similar to those in yaml-mode and python-mode.
+
+;; To install, save this on your load path and add the following to
+;; your .emacs file:
+;;
+;; (require 'sass-mode)
+
+;; sass-mode requires haml-mode, which can be found at http://github.com/nex3/haml-mode.
+
+;;; Code:
+
+(require 'haml-mode)
+
+;; User definable variables
+
+(defgroup sass nil
+ "Support for the Sass template language."
+ :group 'languages
+ :prefix "sass-")
+
+(defcustom sass-mode-hook nil
+ "Hook run when entering Sass mode."
+ :type 'hook
+ :group 'sass)
+
+(defcustom sass-indent-offset 2
+ "Amount of offset per level of indentation."
+ :type 'integer
+ :group 'sass)
+
+(defvar sass-non-block-openers
+ '("^.*,$" ;; Continued selectors
+ "^ *@\\(extend\\|debug\\|warn\\|include\\|import\\)" ;; Single-line mixins
+ "^ *[$!]" ;; Variables
+ )
+ "A list of regexps that match lines of Sass that couldn't have
+text nested beneath them.")
+
+;; Font lock
+
+(defconst sass-selector-font-lock-keywords
+ '(;; Attribute selectors (e.g. p[foo=bar])
+ ("\\[\\([^]=]+\\)" (1 font-lock-variable-name-face)
+ ("[~|$^*]?=\\([^]=]+\\)" nil nil (1 font-lock-string-face)))
+ ("&" 0 font-lock-constant-face)
+ ("\\.\\w+" 0 font-lock-type-face)
+ ("#\\w+" 0 font-lock-keyword-face)
+ ;; Pseudo-selectors, optionally with arguments (e.g. :first, :nth-child(12))
+ ("\\(::?\\w+\\)" (1 font-lock-function-name-face)
+ ("(\\([^)]+\\))" nil nil (1 font-lock-string-face)))))
+
+(defconst sass-script-font-lock-keywords
+ `(("\"\\([^\"\\\\]\\|\\\\.\\)*\"" 0 font-lock-string-face)
+ ("!\\(\\w\\|_\\)+" 0 font-lock-variable-name-face)
+ ("#[0-9a-fA-F]\\{0,6\\}" 0 font-lock-preprocessor-face)
+ (,(regexp-opt
+ '("true" "false" "black" "silver" "gray" "white" "maroon" "red"
+ "purple" "fuchsia" "green" "lime" "olive" "yellow" "navy"
+ "blue" "teal" "aqua"))
+ 0 font-lock-constant-face)
+ (,(regexp-opt '("and" "or" "not")) 0 font-lock-keyword-face)))
+
+(defconst sass-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?- "w" st)
+ (modify-syntax-entry ?_ "w" st)
+ st))
+
+(defconst sass-script-syntax-table
+ (let ((st (make-syntax-table sass-syntax-table)))
+ (modify-syntax-entry ?- "." st)
+ st))
+
+(defconst sass-font-lock-keywords
+ '((sass-highlight-line 1 nil nil t)))
+
+(defconst sass-line-keywords
+ '(("@\\(\\w+\\)" 0 font-lock-keyword-face sass-highlight-directive)
+ ("/[/*].*" 0 font-lock-comment-face)
+ ("[=+]\\w+" 0 font-lock-function-name-face sass-highlight-script-after-match)
+ ("!\\w+" 0 font-lock-variable-name-face sass-highlight-script-after-match)
+ (":\\w+" 0 font-lock-variable-name-face)
+ ("\\w+\s*:" 0 font-lock-variable-name-face)
+ ("\\(\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match)
+ ("\\(:\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match)
+ (".*" sass-highlight-selector))
+ "A list of full-line Sass syntax to highlight, used by `sass-highlight-line'.
+
+Each item is either of the form (REGEXP SUBEXP FACE), (REGEXP FN),
+or (REGEXP SUBEXP FACE FN). Each REGEXP is run successively on the
+beginning of non-whitespace on the current line until one matches.
+If it has SUBEXP and FACE, then SUBEXP is highlighted using FACE.
+If it has FN, FN is run.")
+
+(defun sass-highlight-line (limit)
+ "Highlight a single line using some Sass single-line syntax.
+This syntax is taken from `sass-line-keywords'.
+LIMIT is the limit of the search."
+ (save-match-data
+ (when (re-search-forward "^ *\\(.+\\)$" limit t)
+ (goto-char (match-beginning 1))
+ (dolist (keyword sass-line-keywords)
+ (destructuring-bind (keyword subexp-or-fn &optional face fn) keyword
+ (when (looking-at keyword)
+ (if (integerp subexp-or-fn)
+ (put-text-property (match-beginning subexp-or-fn)
+ (match-end subexp-or-fn)
+ 'face face)
+ (setq fn subexp-or-fn))
+ (when fn (funcall fn))
+ (end-of-line)
+ (return t)))))))
+
+(defun sass-highlight-selector ()
+ "Highlight a CSS selector starting at `point' and ending at `end-of-line'."
+ (let ((font-lock-keywords sass-selector-font-lock-keywords)
+ font-lock-multiline)
+ (font-lock-fontify-region
+ (point) (progn (end-of-line) (point))))
+ t)
+
+(defun sass-highlight-script (beg end)
+ "Highlight a section of SassScript between BEG and END."
+ (save-match-data
+ (with-syntax-table sass-script-syntax-table
+ (let ((font-lock-keywords sass-script-font-lock-keywords)
+ font-lock-syntax-table
+ font-lock-extend-region-functions)
+ (font-lock-fontify-region beg end)))))
+
+(defun sass-highlight-script-after-match ()
+ "Highlight a section of SassScript after the last match."
+ (end-of-line)
+ (sass-highlight-script (match-end 0) (point)))
+
+(defun sass-highlight-directive ()
+ "Highlight a Sass directive."
+ (goto-char (match-end 0))
+ (block nil
+ (case (intern (match-string 1))
+ (for
+ (unless (looking-at " +!\\w+") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-variable-name-face)
+ (goto-char (match-end 0))
+ (unless (looking-at " +from") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-keyword-face)
+ (goto-char (match-end 0))
+ (when (looking-at " +\\(.+?\\) +\\(to\\|through\\)")
+ (sass-highlight-script (match-beginning 1) (match-end 1))
+ (put-text-property (match-beginning 2) (match-end 2)
+ 'face font-lock-keyword-face))
+ (sass-highlight-script-after-match))
+
+ (else
+ (unless (looking-at " +if") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-keyword-face)
+ (sass-highlight-script-after-match))
+
+ ((if while debug) (sass-highlight-script-after-match)))))
+
+;; Constants
+
+;; Mode setup
+
+;;;###autoload
+(define-derived-mode sass-mode haml-mode "Sass"
+ "Major mode for editing Sass files."
+ (set-syntax-table sass-syntax-table)
+ (setq font-lock-extend-region-functions
+ '(font-lock-extend-region-wholelines font-lock-extend-region-multiline))
+ (set (make-local-variable 'font-lock-multiline) nil)
+ (set (make-local-variable 'comment-start) "/*")
+ (set (make-local-variable 'haml-indent-function) 'sass-indent-p)
+ (set (make-local-variable 'haml-indent-offset) sass-indent-offset)
+ (setq font-lock-defaults '(sass-font-lock-keywords t t)))
+
+;; Indentation
+
+(defun sass-indent-p ()
+ "Return non-nil if the current line can have lines nested beneath it."
+ (loop for opener in sass-non-block-openers
+ if (looking-at opener) return nil
+ finally return t))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
+
+;; Setup/Activation
+(provide 'sass-mode)
+;;; sass-mode.el ends here
View
50 vendor/ruby/scss-mode.el
@@ -1,8 +1,9 @@
;;; scss-mode.el --- Major mode for editing SCSS files
;;
;; Author: Anton Johansson <anton.johansson@gmail.com> - http://antonj.se
-;; URL: http://github.com/blastura/dot-emacs/blob/master/lisp-personal/scss-mode.el
+;; URL: https://github.com/antonj/scss-mode
;; Created: Sep 1 23:11:26 2010
+;; Version: 0.5.0
;; Keywords: scss css mode
;;
;; This program is free software; you can redistribute it and/or
@@ -22,13 +23,14 @@
;; gem install haml
;;
;; Also make sure sass location is in emacs PATH, example:
-;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin/sass") exec-path))
+;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-path))
;; or customize `scss-sass-command' to point to your sass executable.
;;
;;; Code:
(require 'derived)
(require 'compile)
+(require 'flymake)
(defgroup scss nil
"Scss mode"
@@ -46,7 +48,12 @@
:type 'boolean
:group 'scss)
-(defcustom scss-compile-error-regex '("\\(Syntax error:\s*.*\\)\n\s*on line\s*\\([0-9]+\\) of \\([^ ]+\\)$" 3 2 nil nil 1)
+(defcustom scss-sass-options '()
+ "Command line Options for sass executable, for example:
+'(\"--cache-location\" \"'/tmp/.sass-cache'\")"
+ :group 'scss)
+
+(defcustom scss-compile-error-regex '("\\(Syntax error:\s*.*\\)\n\s*on line\s*\\([0-9]+\\) of \\([^, \n]+\\)" 3 2 nil nil 1)
"Regex for finding line number file and error message in
compilation buffers, syntax from
`compilation-error-regexp-alist' (REGEXP FILE LINE COLUMN TYPE
@@ -55,8 +62,7 @@ HYPERLINK HIGHLIGHT)"
(defconst scss-font-lock-keywords
;; Variables
- '(("\$[^\s:;]+" . font-lock-constant-face)
- ("//.*$" . font-lock-comment-face)))
+ '(("$[a-z_-][a-z-_0-9]*" . font-lock-constant-face)))
(defun scss-compile-maybe()
"Runs `scss-compile' on if `scss-compile-at-save' is t"
@@ -64,25 +70,45 @@ HYPERLINK HIGHLIGHT)"
(scss-compile)))
(defun scss-compile()
- "Compiles the current buffer, sass buffername.scss buffername.css"
+ "Compiles the current buffer, sass filename.scss filename.css"
(interactive)
- (compile (concat scss-sass-command " "
- (buffer-name) " "
- (first (split-string (buffer-name) ".scss")) ".css")))
+ (compile (concat scss-sass-command " " (mapconcat 'identity scss-sass-options " ") " "
+ "'" buffer-file-name "' '"
+ (first (split-string buffer-file-name "[.]scss$")) ".css'")))
;;;###autoload
-(define-derived-mode scss-mode css-mode "Scss"
- "Major mode for editing Scss files, http://sass-lang.com/
+(define-derived-mode scss-mode css-mode "SCSS"
+ "Major mode for editing SCSS files, http://sass-lang.com/
Special commands:
\\{scss-mode-map}"
(font-lock-add-keywords nil scss-font-lock-keywords)
+ ;; Add the single-line comment syntax ('//', ends with newline)
+ ;; as comment style 'b' (see "Syntax Flags" in elisp manual)
+ (modify-syntax-entry ?/ ". 124" css-mode-syntax-table)
+ (modify-syntax-entry ?* ". 23b" css-mode-syntax-table)
+ (modify-syntax-entry ?\n ">" css-mode-syntax-table)
(add-to-list 'compilation-error-regexp-alist scss-compile-error-regex)
(add-hook 'after-save-hook 'scss-compile-maybe nil t))
(define-key scss-mode-map "\C-c\C-c" 'scss-compile)
+(defun flymake-scss-init ()
+ "Flymake support for SCSS files"
+ (let* ((temp-file (flymake-init-create-temp-buffer-copy
+ 'flymake-create-temp-inplace))
+ (local-file (file-relative-name
+ temp-file
+ (file-name-directory buffer-file-name))))
+ (list scss-sass-command (append scss-sass-options (list "--scss" "--check" local-file)))))
+
+(push '(".+\\.scss$" flymake-scss-init) flymake-allowed-file-name-masks)
+
+;;;; TODO: Not possible to use multiline regexs flymake? flymake-err-[line]-patterns
+;; '("Syntax error:\s*\\(.*\\)\n\s*on line\s*\\([0-9]+\\) of \\([^ ]+\\)$" 3 2 nil 1)
+(push '("on line \\([0-9]+\\) of \\([^ ]+\\)$" 2 1 nil 2) flymake-err-line-patterns)
+
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
(provide 'scss-mode)
-;;; scss-mode.el ends here
+;;; scss-mode.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.