Replacing config with cask including dependencies

This commit is contained in:
Kienan Stewart 2016-11-11 17:10:03 -05:00
parent eb28d848d3
commit 79d9dce3e1
9 changed files with 14 additions and 9259 deletions

7
Cask
View File

@ -5,22 +5,29 @@
(depends-on "cask")
(depends-on "dash")
(depends-on "drag-stuff")
(depends-on "drupal-mode")
(depends-on "exec-path-from-shell")
(depends-on "expand-region")
(depends-on "f")
(depends-on "flycheck")
(depends-on "flycheck-cask")
(depends-on "flycheck-pyflakes")
(depends-on "htmlize")
(depends-on "idle-highlight-mode")
(depends-on "js2-mode")
(depends-on "kivy-mode")
(depends-on "magit")
(depends-on "markdown-mode")
(depends-on "multiple-cursors")
(depends-on "nyan-mode")
(depends-on "pallet")
(depends-on "php-mode")
(depends-on "popwin")
(depends-on "prodigy")
(depends-on "projectile")
(depends-on "puppet-mode")
(depends-on "s")
(depends-on "scss-mode")
(depends-on "smartparens")
(depends-on "smex")
(depends-on "use-package")

100
init.el
View File

@ -1,12 +1,15 @@
;; Load cask info
(require 'cask "~/local/share/cask/cask.el")
(cask-initialize)
;; Enable flycheck
(add-hook 'after-init-hook #'global-flycheck-mode)
;; Generic Emacs stuff
(add-to-list 'load-path "~/.emacs.d/modes/")
(add-to-list 'load-path "~/.emacs.d/misc/")
(show-paren-mode 1)
;; multi-term
;;(require 'multi-term)
;;(setq multi-term-program "/bin/bash")
;; CSS Mode needs to be applied to scss files.
(add-to-list 'auto-mode-alist '("\\.scss" . css-mode))
(setq-default css-indent-offset 2)
@ -24,97 +27,8 @@
(setq-default whitespace-line-column 80)
(global-whitespace-mode 1)
;; Markdown http://jblevins.org/projects/markdown-mode/markdown-mode.el
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdwn\\'" . markdown-mode))
;; C, use k&r style by default (naev)
(setq-default c-default-style "k&r"
c-basic-offset 3)
;; Kivy (ref:https://github.com/kivy/kivy/blob/master/kivy/tools/highlight/kivy-mode.el)
(require 'kivy-mode)
(add-to-list 'auto-mode-alist '("\\.kv$" . kivy-mode))
;; Python!
;; Prevent ropemacs from overriding emacs shortcuts
;;(setq ropemacs-enable-shortcuts nil)
;;(setq ropemacs-local-prefix "C-c C-p")
;; Load of a bunch of stuff for pymacs : http://pymacs.progiciels-bpi.ca/pymacs.html#installation
;;(autoload 'pymacs-apply "pymacs")
;;(autoload 'pymacs-call "pymacs")
;;(autoload 'pymacs-eval "pymacs" nil t)
;;(autoload 'pymacs-exec "pymacs" nil t)
;;(autoload 'pymacs-load "pymacs" nil t)
;;(autoload 'pymacs-autoload "pymacs")
;;(eval-after-load "pymacs"
;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY"))
;;(require 'pymacs)
;; Load ropemacs
;;(pymacs-load "ropemacs" "rope-")
;; SCSS
;;(autoload 'scss-mode "scss-mode")
;;(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
;;(setq-default scss-compile-at-save nil)
;; PHP and Drupal-Modes
;; http://stackoverflow.com/questions/898063/making-php-mode-and-other-cc-mode-derived-modes-compatible-with-emacs-23
;; Use autoload for php-mode and drupal-mode to avoid occasionaly errors on some
;; systems when loading from init. See the above question on stack overflow
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(autoload 'drupal-mode "drupal-mode" "Major mode for editing drupal php files." t)
;(require 'php-mode)
;(require 'drupal-mode)
(add-to-list 'auto-mode-alist '("\\.\\(module\\|test\\|install\\|theme\\)$" . drupal-mode))
(add-to-list 'auto-mode-alist '("\\.\\(php\\|inc\\)$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.info" . conf-windows-mode))
(defun my-php-hook-function ()
(set (make-local-variable 'compile-command) (format "phpcs --report=emacs --standard=PEAR %s" (buffer-file-name))))
(add-hook 'php-mode-hook 'my-php-hook-function)
(defun my-drupal-hook-function ()
(set (make-local-variable 'compile-command) (format "phpcs --report=emacs --extensions=php,module,inc,install,test,profile,theme --standard=Drupal %s" (buffer-file-name))))
(add-hook 'drupal-mode-hook 'my-drupal-hook-function)
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;; Synax checking for PHP with flymake
;; http://sachachua.com/blog/2008/07/emacs-and-php-on-the-fly-syntax-checking-with-flymake/
;; https://github.com/illusori/emacs-flymake
;; http://www.emacswiki.org/emacs/FlyMake
(require 'flymake)
(defun flymake-php-init ()
"Use php to check the syntax of the current file."
(let* ((temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
(local (file-relative-name temp (file-name-directory buffer-file-name))))
(list "php" (list "-f" local "-l"))))
(add-to-list 'flymake-err-line-patterns
'("\\(Parse\\|Fatal\\) error: +\\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)$" 3 4 nil 2))
(add-to-list 'flymake-allowed-file-name-masks '("\\.php$" flymake-php-init))
;; Drupal-type extensions
(add-to-list 'flymake-allowed-file-name-masks
'("\\.\\(inc\\|module\\|test\\|install\\|theme\\)$"
flymake-php-init))
(add-hook 'php-mode-hook (lambda () (flymake-mode 1)))
(add-hook 'php-mode-hook (lambda ()
(define-key php-mode-map '[M-S-up]
'flymake-goto-prev-error)))
(add-hook 'php-mode-hook (lambda ()
(define-key php-mode-map '[M-S-down]
'flymake-goto-next-error)))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(flymake-errline ((((class color) (background light)) (:background "magenta" :foreground "red")))))

File diff suppressed because it is too large Load Diff

View File

@ -1,794 +0,0 @@
;;; multi-term.el --- Managing multiple terminal buffers in Emacs.
;; Author: Andy Stewart <lazycat.manatee@gmail.com>
;; Maintainer: ahei <ahei0802@gmail.com>
;; Copyright (C) 2008, 2009, Andy Stewart, all rights reserved.
;; Copyright (C) 2010, ahei, all rights reserved.
;; Created: <2008-09-19 23:02:42>
;; Version: 0.8.9
;; Last-Updated: <2013-01-08 10:11:43 Tuesday by jpkotta>
;; URL: http://www.emacswiki.org/emacs/download/multi-term.el
;; Keywords: term, terminal, multiple buffer
;; Compatibility: GNU Emacs 23.2.1
;; 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 3, 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., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;; Features that might be required by this library:
;;
;; `term' `cl' `advice'
;;
;;; Commentary:
;;
;; This package is for creating and managing multiple terminal buffers in Emacs.
;;
;; By default, term.el provides a great terminal emulator in Emacs.
;; But I have some troubles with term-mode:
;;
;; 1. term.el just provides commands `term' or `ansi-term'
;; for creating a terminal buffer.
;; And there is no special command to create or switch
;; between multiple terminal buffers quickly.
;;
;; 2. By default, the keystrokes of term.el conflict with global-mode keystrokes,
;; which makes it difficult for the user to integrate term.el with Emacs.
;;
;; 3. By default, executing *NIX command “exit” from term-mode,
;; it will leave an unused buffer.
;;
;; 4. term.el wont quit running sub-process when you kill terminal buffer forcibly.
;;
;; 5. Havent a dedicated window for debug program.
;;
;; And multi-term.el is enhanced with those features.
;;
;;; Installation:
;;
;; Copy multi-term.el to your load-path and add to your ~/.emacs
;;
;; (require 'multi-term)
;;
;; And setup program that `multi-term' will need:
;;
;; (setq multi-term-program "/bin/bash")
;;
;; or setup like me "/bin/zsh" ;)
;;
;; Below are the commands you can use:
;;
;; `multi-term' Create a new term buffer.
;; `multi-term-next' Switch to next term buffer.
;; `multi-term-prev' Switch to previous term buffer.
;; `multi-term-dedicated-open' Open dedicated term window.
;; `multi-term-dedicated-close' Close dedicated term window.
;; `multi-term-dedicated-toggle' Toggle dedicated term window.
;; `multi-term-dedicated-select' Select dedicated term window.
;;
;; Tips:
;;
;; You can type `C-u' before command `multi-term' or `multi-term-dedicated-open'
;; then will prompt you shell name for creating terminal buffer.
;;
;;; Customize:
;;
;; `multi-term-program' default is nil, so when creating new term buffer,
;; send environment variable of `SHELL' (`ESHELL', `/bin/sh') to `make-term'.
;;
;; And you can set it to your liking, like me: ;-)
;;
;; (setq multi-term-program "/bin/zsh")
;;
;; `multi-term-default-dir' default is `~/', only use when current buffer
;; is not in a real directory.
;;
;; `multi-term-buffer-name' is the name of term buffer.
;;
;; `multi-term-scroll-show-maximum-output' controls how interpreter
;; output causes window to scroll.
;;
;; `multi-term-scroll-to-bottom-on-output' controls whether interpreter
;; output causes window to scroll.
;;
;; `multi-term-switch-after-close' try to switch other `multi-term' buffer
;; after close current one.
;; If you don't like this feature just set it with nil.
;;
;; `term-unbind-key-list' is a key list to unbind some keystroke.
;;
;; `term-bind-key-alist' is a key alist that binds some keystroke.
;; If you don't like default, modify it.
;;
;; `multi-term-dedicated-window-height' the height of a dedicated term window.
;;
;; `multi-term-dedicated-max-window-height' the max height limit that dedicated
;; window is allowed.
;;
;; `multi-term-dedicated-skip-other-window-p' whether skip dedicated term
;; window when use command `other-window' to cycle windows order.
;;
;; All of the above can be customize by:
;; M-x customize-group RET multi-term RET
;;
;;; Change log:
;; 2013/01/08
;; * Fix customize group of `multi-term-try-create'.
;; * Add autoloads.
;; * Add new commands `term-send-quote' and `term-send-M-x'.
;;
;; 2009/07/04
;; * Add new option `multi-term-dedicated-select-after-open-p'.
;;
;; 2009/06/29
;; * Fix regexp bug.
;;
;; 2009/04/21
;; * Fix a bug that bring at `2009/03/28':
;; It will kill sub-process in other multi-term buffer
;; when we kill current multi-term buffer.
;;
;; 2009/03/29
;; * Add new command `term-send-reverse-search-history'.
;;
;; 2009/03/28
;; * Add new option `multi-term-switch-after-close'.
;;
;; 2009/02/18
;; * Fix bug between ECB and `multi-term-dedicated-close'.
;;
;; 2009/02/05
;; * Prompt user shell name when type `C-u' before command
;; `multi-term' or `multi-term-dedicated-open'.
;; * Fix doc.
;;
;; 2009/01/29
;; * Use `term-quit-subjob' instead `term-interrupt-subjob'.
;; * Fix doc.
;;
;; 2009/01/13
;; * Rewrite advice for `pop-to-buffer' to avoid `pop-to-buffer' not effect
;; when have many dedicated window in current frame.
;; * Rewrite advice for `delete-other-windows' to avoid use common variable
;; `delete-protected-window-list' and use `window-dedicated-p' instead.
;; Remove variable `delete-protected-window-list' and function
;; `multi-term-dedicated-match-protected-window-p'.
;;
;; 2009/01/06
;; * Improve document.
;;
;; 2008/12/29
;; * Remove option `multi-term-current-window-height' and
;; function `multi-term-current-directory'.
;; * Add some functions to make get dedicated term buffer,
;; those functions is beginning with `multi-term-dedicated-'.
;; * Modified advice `delete-window', make command `delete-window'
;; and delete dedicated window, but will remember window height
;; before deleted.
;; * Don't remember dedicated window height if larger than max value.
;; * Fix some bug with `delete-other-windows' and window configuration.
;; And this bug exists with another extension `sr-speedbar'.
;; * Add new variable `delete-protected-window-list' for protected
;; special window that won't be deleted.
;; This variable is common for any extension that use dedicated
;; window.
;; * Fix doc.
;;
;; 2008/12/21
;; * Default bind `C-m' with `term-send-input'.
;;
;; 2008/12/10
;; * Improve customize interface.
;; * Setup customize automatically, don't need to user setup it up.
;; * Add option `multi-term-try-create'.
;; * Make function `multi-term-switch' accept offset argument.
;; * Fix doc.
;;
;; 2008/10/22
;; * Add variable `multi-term-current-window-height'.
;; * Add variable `multi-term-buffer-name'.
;; * Add variable `term-unbind-key-list'.
;; * Add variable `term-rebind-key-alist'.
;; * Move key setup and some extension from `term-extension.el'.
;; * Create new function `multi-term-keystroke-setup'.
;; * Fix doc.
;;
;; 2008/09/19
;; * First released.
;;
;;; Acknowledgments:
;;
;; Mark Triggs <mst@dishevelled.net>
;; For create multi-shell.el
;; Aaron S. Hawley <aaron.s.hawley@gmail.com>
;; For improve document.
;;
;;; Bug
;;
;;
;;; TODO
;;
;;
;;
;;; Require:
(require 'term)
(require 'cl)
(require 'advice)
;;; Code:
;;; Customize
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Customize ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup multi-term nil
"Multi term manager."
:group 'term)
(defcustom multi-term-program nil
"The program of term.
If this is nil, setup to environment variable of `SHELL'."
:type 'string
:group 'multi-term)
(defcustom multi-term-program-switches nil
"The command-line switches to pass to the term program."
:type 'string
:group 'multi-term)
(defcustom multi-term-try-create t
"Try to create a new term buffer when switch.
When use `multi-term-next' or `multi-term-prev', switch term buffer,
and try to create a new term buffer if no term buffers exist."
:type 'boolean
:group 'multi-term)
(defcustom multi-term-default-dir "~/"
"The default directory for terms if current directory doesn't exist."
:type 'string
:group 'multi-term)
(defcustom multi-term-buffer-name "terminal"
"The buffer name of term buffer."
:type 'string
:group 'multi-term)
(defcustom multi-term-scroll-show-maximum-output nil
"*Controls how interpreter output causes window to scroll.
If non-nil, then show the maximum output when the window is scrolled.
See variable `multi-term-scroll-to-bottom-on-output'."
:type 'boolean
:group 'multi-term)
(defcustom multi-term-scroll-to-bottom-on-output nil
"*Controls whether interpreter output causes window to scroll.
If nil, then do not scroll. If t or `all', scroll all windows showing buffer.
If `this', scroll only the selected window.
If `others', scroll only those that are not the selected window.
The default is nil.
See variable `multi-term-scroll-show-maximum-output'."
:type 'boolean
:group 'multi-term)
(defcustom multi-term-switch-after-close 'NEXT
"Try to switch other `multi-term' buffer after close current one.
If this option is 'NEXT, switch to next `multi-term' buffer;
If this option is 'PREVIOUS, switch to previous `multi-term' buffer.
If this option is nil, don't switch other `multi-term' buffer."
:type 'symbol
:group 'multi-term)
(defcustom term-unbind-key-list
'("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>")
"The key list that will need to be unbind."
:type 'list
:group 'multi-term)
(defcustom term-bind-key-alist
'(
("C-c C-c" . term-interrupt-subjob)
("C-p" . previous-line)
("C-n" . next-line)
("C-s" . isearch-forward)
("C-r" . isearch-backward)
("C-m" . term-send-raw)
("M-f" . term-send-forward-word)
("M-b" . term-send-backward-word)
("M-o" . term-send-backspace)
("M-p" . term-send-up)
("M-n" . term-send-down)
("M-M" . term-send-forward-kill-word)
("M-N" . term-send-backward-kill-word)
("M-r" . term-send-reverse-search-history)
("M-," . term-send-input)
("M-." . comint-dynamic-complete))
"The key alist that will need to be bind.
If you do not like default setup, modify it, with (KEY . COMMAND) format."
:type 'alist
:group 'multi-term)
(defcustom multi-term-dedicated-window-height 14
"The height of `multi-term' dedicated window."
:type 'integer
:group 'multi-term)
(defcustom multi-term-dedicated-max-window-height 30
"The max height limit of `multi-term' dedicated window.
Default, when hide `multi-term' dedicated window, will remember
window height before hide, except height is larger than this.`"
:type 'integer
:group 'multi-term)
(defcustom multi-term-dedicated-skip-other-window-p nil
"Default, can have `other-window' select window in cyclic ordering of windows.
In cases you don't want to select `multi-term' dedicated window, use `other-window'
and make `multi-term' dedicated window as a viewable sidebar.
So please turn on this option if you want to skip `multi-term' dedicated window with `other-window'.
Default is nil."
:type 'boolean
:set (lambda (symbol value)
(set symbol value)
(when (ad-advised-definition-p 'other-window)
(multi-term-dedicated-handle-other-window-advice value)))
:group 'multi-term)
(defcustom multi-term-dedicated-select-after-open-p nil
"Default, multi-term won't focus terminal window after you open dedicated window.
Please make this option with t if you want focus terminal window.
Default is nil."
:type 'boolean
:group 'multi-term)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Constant ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst multi-term-dedicated-buffer-name "MULTI-TERM-DEDICATED"
"The buffer name of dedicated `multi-term'.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar multi-term-dedicated-window nil
"The dedicated `multi-term' window.")
(defvar multi-term-dedicated-buffer nil
"The dedicated `multi-term' buffer.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun multi-term ()
"Create new term buffer.
Will prompt you shell name when you type `C-u' before this command."
(interactive)
(let (term-buffer)
;; Set buffer.
(setq term-buffer (multi-term-get-buffer current-prefix-arg))
(set-buffer term-buffer)
;; Internal handle for `multi-term' buffer.
(multi-term-internal)
;; Switch buffer
(switch-to-buffer term-buffer)))
;;;###autoload
(defun multi-term-next (&optional offset)
"Go to the next term buffer.
If OFFSET is `non-nil', will goto next term buffer with OFFSET."
(interactive "P")
(multi-term-switch 'NEXT (or offset 1)))
;;;###autoload
(defun multi-term-prev (&optional offset)
"Go to the previous term buffer.
If OFFSET is `non-nil', will goto previous term buffer with OFFSET."
(interactive "P")
(multi-term-switch 'PREVIOUS (or offset 1)))
;;;###autoload
(defun multi-term-dedicated-open ()
"Open dedicated `multi-term' window.
Will prompt you shell name when you type `C-u' before this command."
(interactive)
(if (not (multi-term-dedicated-exist-p))
(let ((current-window (selected-window)))
(if (multi-term-buffer-exist-p multi-term-dedicated-buffer)
(unless (multi-term-window-exist-p multi-term-dedicated-window)
(multi-term-dedicated-get-window))
;; Set buffer.
(setq multi-term-dedicated-buffer (multi-term-get-buffer current-prefix-arg t))
(set-buffer (multi-term-dedicated-get-buffer-name))
;; Get dedicate window.
(multi-term-dedicated-get-window)
;; Whether skip `other-window'.
(multi-term-dedicated-handle-other-window-advice multi-term-dedicated-skip-other-window-p)
;; Internal handle for `multi-term' buffer.
(multi-term-internal))
(set-window-buffer multi-term-dedicated-window (get-buffer (multi-term-dedicated-get-buffer-name)))
(set-window-dedicated-p multi-term-dedicated-window t)
;; Select window.
(select-window
(if multi-term-dedicated-select-after-open-p
;; Focus dedicated terminal window if option `multi-term-dedicated-select-after-open-p' is enable.
multi-term-dedicated-window
;; Otherwise focus current window.
current-window)))
(message "`multi-term' dedicated window has exist.")))
(defun multi-term-dedicated-close ()
"Close dedicated `multi-term' window."
(interactive)
(if (multi-term-dedicated-exist-p)
(let ((current-window (selected-window)))
;; Remember height.
(multi-term-dedicated-select)
(multi-term-dedicated-remember-window-height)
;; Close window.
(if (and (require 'ecb nil t)
ecb-activated-window-configuration)
;; Toggle ECB window when ECB window activated.
(progn
(ecb-deactivate)
(ecb-activate))
;; Otherwise delete dedicated window.
(delete-window multi-term-dedicated-window)
(if (multi-term-window-exist-p current-window)
(select-window current-window))))
(message "`multi-term' window is not exist.")))
(defun multi-term-dedicated-remember-window-height ()
"Remember window height."
(let ((win-height (multi-term-current-window-take-height)))
(if (and (multi-term-dedicated-window-p) ;in `multi-term' window
(> win-height 1)
(<= win-height multi-term-dedicated-max-window-height))
(setq multi-term-dedicated-window-height win-height))))
;;;###autoload
(defun multi-term-dedicated-toggle ()
"Toggle dedicated `multi-term' window."
(interactive)
(if (multi-term-dedicated-exist-p)
(multi-term-dedicated-close)
(multi-term-dedicated-open)))
;;;###autoload
(defun multi-term-dedicated-select ()
"Select the `multi-term' dedicated window."
(interactive)
(if (multi-term-dedicated-exist-p)
(select-window multi-term-dedicated-window)
(message "`multi-term' window is not exist.")))
(defun term-send-backward-kill-word ()
"Backward kill word in term mode."
(interactive)
(term-send-raw-string "\C-w"))
(defun term-send-forward-kill-word ()
"Kill word in term mode."
(interactive)
(term-send-raw-string "\ed"))
(defun term-send-backward-word ()
"Move backward word in term mode."
(interactive)
(term-send-raw-string "\eb"))
(defun term-send-forward-word ()
"Move forward word in term mode."
(interactive)
(term-send-raw-string "\ef"))
(defun term-send-reverse-search-history ()
"Search history reverse."
(interactive)
(term-send-raw-string "\C-r"))
(defun term-send-quote ()
"Quote the next character in term-mode.
Similar to how `quoted-insert' works in a regular buffer."
(interactive)
(term-send-raw-string "\C-v"))
(defun term-send-M-x ()
"Type M-x in term-mode."
(interactive)
(term-send-raw-string "\ex"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utilise Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun multi-term-internal ()
"Internal handle for `multi-term' buffer."
;; Add customize keystroke with `term-mode-hook'
(remove-hook 'term-mode-hook 'multi-term-keystroke-setup)
(add-hook 'term-mode-hook 'multi-term-keystroke-setup)
;; Load term mode
(term-mode)
(term-char-mode)
;; Handle term buffer close
(multi-term-handle-close)
;; Handle `output' variable.
(setq term-scroll-show-maximum-output multi-term-scroll-show-maximum-output
term-scroll-to-bottom-on-output multi-term-scroll-to-bottom-on-output)
;; Add hook to be sure `term' quit subjob before buffer killed.
(add-hook 'kill-buffer-hook 'multi-term-kill-buffer-hook))
(defun multi-term-get-buffer (&optional special-shell dedicated-window)
"Get term buffer.
If option SPECIAL-SHELL is `non-nil', will use shell from user input.
If option DEDICATED-WINDOW is `non-nil' will create dedicated `multi-term' window ."
(with-temp-buffer
(let ((shell-name (or multi-term-program ;shell name
(getenv "SHELL")
(getenv "ESHELL")
"/bin/sh"))
term-list-length ;get length of term list
index ;setup new term index
term-name) ;term name
(if dedicated-window
(setq term-name multi-term-dedicated-buffer-name)
;; Compute index.
(setq term-list-length (length (multi-term-list)))
(setq index (if term-list-length (1+ term-list-length) 1))
;; switch to current local directory,
;; if in-existence, switch to `multi-term-default-dir'.
(cd (or default-directory (expand-file-name multi-term-default-dir)))
;; adjust value N when max index of term buffer is less than length of term list
(while (buffer-live-p (get-buffer (format "*%s<%s>*" multi-term-buffer-name index)))
(setq index (1+ index)))
(setq term-name (format "%s<%s>" multi-term-buffer-name index)))
;; Try get other shell name if `special-shell' is non-nil.
(if special-shell
(setq shell-name (read-from-minibuffer "Run program: " shell-name)))
;; Make term, details to see function `make-term' in `term.el'.
(if multi-term-program-switches
(make-term term-name shell-name nil multi-term-program-switches)
(make-term term-name shell-name)))))
(defun multi-term-handle-close ()
"Close current term buffer when `exit' from term buffer."
(when (ignore-errors (get-buffer-process (current-buffer)))
(set-process-sentinel (get-buffer-process (current-buffer))
(lambda (proc change)
(when (string-match "\\(finished\\|exited\\)" change)
(kill-buffer (process-buffer proc)))))))
(defun multi-term-kill-buffer-hook ()
"Function that hook `kill-buffer-hook'."
(when (eq major-mode 'term-mode)
;; Quit the current subjob
;; when have alive process with current term buffer.
;; Must do this job BEFORE `multi-term-switch-after-close' action.
(when (term-check-proc (current-buffer))
;; Quit sub-process.
(term-quit-subjob))
;; Remember dedicated window height.
(multi-term-dedicated-remember-window-height)
;; Try to switch other multi-term buffer
;; when option `multi-term-switch-after-close' is non-nil.
(when multi-term-switch-after-close
(multi-term-switch-internal multi-term-switch-after-close 1))))
(defun multi-term-list ()
"List term buffers presently active."
;; Autload command `remove-if-not'.
(autoload 'remove-if-not "cl-seq")
(sort
(remove-if-not (lambda (b)
(setq case-fold-search t)
(string-match
(format "^\\\*%s<[0-9]+>\\\*$" multi-term-buffer-name)
(buffer-name b)))
(buffer-list))
(lambda (a b)
(< (string-to-number
(cadr (split-string (buffer-name a) "[<>]")))
(string-to-number
(cadr (split-string (buffer-name b) "[<>]")))))))
(defun multi-term-switch (direction offset)
"Switch `multi-term' buffers.
If DIRECTION is `NEXT', switch to the next term.
If DIRECTION `PREVIOUS', switch to the previous term.
Option OFFSET for skip OFFSET number term buffer."
(unless (multi-term-switch-internal direction offset)
(if multi-term-try-create
(progn
(multi-term)
(message "Create a new `multi-term' buffer."))
(message "Haven't any `multi-term' buffer exist."))))
(defun multi-term-switch-internal (direction offset)
"Internal `multi-term' buffers switch function.
If DIRECTION is `NEXT', switch to the next term.
If DIRECTION `PREVIOUS', switch to the previous term.
Option OFFSET for skip OFFSET number term buffer."
(let (terms this-buffer)
(setq terms (multi-term-list))
(if (consp terms)
(progn
(setf (cdr (last terms)) terms)
(setq this-buffer (position (current-buffer) (multi-term-list)))
(if this-buffer
(if (eql direction 'NEXT)
(switch-to-buffer (nth (+ this-buffer offset) terms))
(switch-to-buffer (nth (+ (- (length (multi-term-list)) offset)
this-buffer) terms)))
(switch-to-buffer (car terms)))
t)
nil)))
(defun multi-term-keystroke-setup ()
"Keystroke setup of `term-char-mode'.
By default, the key bindings of `term-char-mode' conflict with user's keystroke.
So this function unbinds some keys with `term-raw-map',
and binds some keystroke with `term-raw-map'."
(let (bind-key bind-command)
;; Unbind base key that conflict with user's keys-tokes.
(dolist (unbind-key term-unbind-key-list)
(cond
((stringp unbind-key) (setq unbind-key (read-kbd-macro unbind-key)))
((vectorp unbind-key) nil)
(t (signal 'wrong-type-argument (list 'array unbind-key))))
(define-key term-raw-map unbind-key nil))
;; Add some i use keys.
;; If you don't like my keystroke,
;; just modified `term-bind-key-alist'
(dolist (element term-bind-key-alist)
(setq bind-key (car element))
(setq bind-command (cdr element))
(cond
((stringp bind-key) (setq bind-key (read-kbd-macro bind-key)))
((vectorp bind-key) nil)
(t (signal 'wrong-type-argument (list 'array bind-key))))
(define-key term-raw-map bind-key bind-command))))
(defun multi-term-dedicated-handle-other-window-advice (activate)
"Handle advice for function `other-window'.
If ACTIVATE is `non-nil', will enable advice
`multi-term-dedicated-other-window-advice'.
Otherwise, disable it."
(if activate
(ad-enable-advice 'other-window 'after 'multi-term-dedicated-other-window-advice)
(ad-disable-advice 'other-window 'after 'multi-term-dedicated-other-window-advice))
(ad-activate 'other-window))
(defun multi-term-current-window-take-height (&optional window)
"Return the height the `window' takes up.
Not the value of `window-height', it returns usable rows available for WINDOW.
If `window' is nil, get current window."
(let ((edges (window-edges window)))
(- (nth 3 edges) (nth 1 edges))))
(defun multi-term-dedicated-get-window ()
"Get `multi-term' dedicated window."
(setq multi-term-dedicated-window
(split-window
(selected-window)
(- (multi-term-current-window-take-height) multi-term-dedicated-window-height))))
(defun multi-term-dedicated-get-buffer-name ()
"Get the buffer name of `multi-term' dedicated window."
(format "*%s*" multi-term-dedicated-buffer-name))
(defun multi-term-dedicated-exist-p ()
"Return `non-nil' if `multi-term' dedicated window exist."
(and (multi-term-buffer-exist-p multi-term-dedicated-buffer)
(multi-term-window-exist-p multi-term-dedicated-window)))
(defun multi-term-window-exist-p (window)
"Return `non-nil' if WINDOW exist.
Otherwise return nil."
(and window (window-live-p window)))
(defun multi-term-buffer-exist-p (buffer)
"Return `non-nil' if `BUFFER' exist.
Otherwise return nil."
(and buffer (buffer-live-p buffer)))
(defun multi-term-dedicated-window-p ()
"Return `non-nil' if current window is `multi-term' dedicated window.
Otherwise return nil."
(equal (multi-term-dedicated-get-buffer-name) (buffer-name (window-buffer))))
(defun multi-term-window-dedicated-only-one-p ()
"Only have one non-dedicated window."
(interactive)
(let ((window-number 0)
(dedicated-window-number 0))
(walk-windows
(lambda (w)
(with-selected-window w
(incf window-number)
(if (window-dedicated-p w)
(incf dedicated-window-number)))))
(if (and (> dedicated-window-number 0)
(= (- window-number dedicated-window-number) 1))
t nil)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Advice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defadvice delete-other-windows (around multi-term-delete-other-window-advice activate)
"This is advice to make `multi-term' avoid dedicated window deleted.
Dedicated window can't deleted by command `delete-other-windows'."
(let ((multi-term-dedicated-active-p (multi-term-window-exist-p multi-term-dedicated-window)))
(if multi-term-dedicated-active-p
(let ((current-window (selected-window)))
(dolist (win (window-list))
(when (and (window-live-p win)
(not (eq current-window win))
(not (window-dedicated-p win)))
(delete-window win))))
ad-do-it)))
(defadvice delete-window (before multi-term-delete-window-advice activate)
"Use `delete-window' delete `multi-term' dedicated window.
Have same effect as command `multi-term-dedicated-close'.
This advice to remember `multi-term' dedicated window height before deleting."
;; Remember window height before deleted.
(multi-term-dedicated-remember-window-height))
(defadvice pop-to-buffer (before multi-term-pop-to-buffer-advice activate)
"This advice fix the problem between `pop-to-buffer' and dedicated window.
By default, function `display-buffer' can't display buffer in selected window
if current window is `dedicated'.
So function `display-buffer' conflicts with `sr-speedbar' window, because
`sr-speedbar' window is a `dedicated' window.
That is to say, when current frame just have one `non-dedicated' window,
any functions that uses `display-buffer' can't split windows
to display buffer, even when the option `pop-up-windows' is enabled.
And the example function that can induce the problem is `pop-to-buffer'.
This advice will fix this problem when current frame just have one `non-dedicated' window."
(when (and pop-up-windows ;`pop-up-windows' is enable
(multi-term-window-dedicated-only-one-p) ;just have one `non-dedicated' window.
(multi-term-window-exist-p multi-term-dedicated-window)
(not (multi-term-dedicated-window-p))) ;not in `sr-speedbar' window
(split-window-vertically)
(windmove-down)))
(defadvice other-window (after multi-term-dedicated-other-window-advice)
"Default, can use `other-window' select window in cyclic ordering of windows.
But sometimes we don't want to select `sr-speedbar' window,
but use `other-window' and just make `multi-term' dedicated
window as a viewable sidebar.
This advice can make `other-window' skip `multi-term' dedicated window."
(let ((count (or (ad-get-arg 0) 1)))
(when (and (multi-term-window-exist-p multi-term-dedicated-window)
(eq multi-term-dedicated-window (selected-window)))
(other-window count))))
(provide 'multi-term)
;; Local Variables:
;; time-stamp-line-limit: 10
;; time-stamp-start: "Last-Updated: <"
;; time-stamp-end: ">"
;; End:
;;; multi-term.el ends here
;;; LocalWords: multi el dir sr Hawley eb ef cd

View File

@ -1,17 +0,0 @@
;;; drupal-mode.el --- major mode for Drupal coding
;;;###autoload
(define-derived-mode drupal-mode php-mode "Drupal"
"Major mode for Drupal coding.\n\n\\{drupal-mode-map}"
(setq c-basic-offset 2)
(setq indent-tabs-mode nil)
(setq fill-column 78)
(setq show-trailing-whitespace t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-close 0)
(c-set-offset 'arglist-intro '+) ; for FAPI arrays and DBTNG
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math) ; for DBTNG fields and values
(run-mode-hooks 'drupal-mode-hook)
)
(provide 'drupal-mode)

View File

@ -1,290 +0,0 @@
;;; kivy-mode.el --- Emacs major mode for editing Kivy files
;;
;; Author: Dean Serenevy <dean@serenevy.net>
;; Version: 0.1.0
;;
;; This document borrowed heavily from yaml-mode.el by Yoshiki Kurihara and
;; Marshall Vandegrift.
;;
;; This file is not part of Emacs
;; 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; version 3.
;; 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;; USA.
;;; Installation:
;; To install, just drop this file into a directory in your `load-path' and
;; (optionally) byte-compile it. To automatically handle files ending in
;; '.kv', add something like:
;;
;; (require 'kivy-mode)
;; (add-to-list 'auto-mode-alist '("\\.kv$" . kivy-mode))
;;
;; to your .emacs file.
;;
;; Unlike python-mode, this mode follows the Emacs convention of not
;; binding the ENTER key to `newline-and-indent'. To get this behavior, add
;; the key definition to `kivy-mode-hook':
;;
;; (add-hook 'kivy-mode-hook
;; '(lambda ()
;; (define-key kivy-mode-map "\C-m" 'newline-and-indent)))
;; User definable variables
(defgroup kivy nil
"Support for the kivy user interface definition format"
:group 'languages
:prefix "kivy-")
(defcustom kivy-mode-hook nil
"*Hook run by `kivy-mode'."
:type 'hook
:group 'kivy)
(defcustom kivy-indent-offset 4
"*Amount of offset per level of indentation."
:type 'integer
:group 'kivy)
(defcustom kivy-backspace-function 'backward-delete-char-untabify
"*Function called by `kivy-electric-backspace' when deleting backwards."
:type 'function
:group 'kivy)
(defface kivy-tab-face
'((((class color)) (:background "red" :foreground "red" :bold t))
(t (:reverse-video t)))
"Face to use for highlighting tabs in kivy files."
:group 'faces
:group 'kivy)
(defcustom kivy-imenu-generic-expression
'((nil "^\\([<>a-zA-Z_-]+\\):" 1))
"The imenu regex to parse an outline of the kivy file."
:type 'string
:group 'kivy)
;; Constants
(defconst kivy-mode-version "0.1.0" "Version of `kivy-mode.'")
(defconst kivy-blank-line-re "^ *$"
"Regexp matching a line containing only (valid) whitespace.")
(defconst kivy-comment-re "\\(?:^\\|\\s-+\\)\\(#.*\\)"
"Regexp matching a line containing a kivy comment or delimiter.")
(defconst kivy-directive-re "^\\(?:#:\\)\\(\\w+ +.*\\)"
"Regexp matching a line contatining a kivy directive.")
(defconst kivy-tag-re "^ *id: *\\([^ \n]+\\)$"
"Rexexp matching a kivy tag.")
(defconst kivy-bare-scalar-re
"\\(?:[^-:,#!\n{\\[ ]\\|[^#!\n{\\[ ]\\S-\\)[^#\n]*?"
"Rexexp matching a kivy bare scalar.")
(defconst kivy-hash-key-re
(concat "^ *"
"\\(" kivy-bare-scalar-re "\\) *:"
"\\(?: +\\|$\\)")
"Regexp matching a single kivy hash key.")
(defconst kivy-nested-map-re
(concat ".*: *$")
"Regexp matching a line beginning a kivy nested structure.")
(defconst kivy-constant-scalars-re
(concat "\\(?:^\\|\\(?::\\|-\\|,\\|{\\|\\[\\) +\\) *"
(regexp-opt
'("True" "False" "None") t)
" *$")
"Regexp matching certain scalar constants in scalar context")
;; Mode setup
(defvar kivy-mode-map ()
"Keymap used in `kivy-mode' buffers.")
(if kivy-mode-map
nil
(setq kivy-mode-map (make-sparse-keymap))
(define-key kivy-mode-map [backspace] 'kivy-electric-backspace)
(define-key kivy-mode-map "\C-c<" 'kivy-indent-shift-left)
(define-key kivy-mode-map "\C-c>" 'kivy-indent-shift-right)
)
(defvar kivy-mode-syntax-table nil
"Syntax table in use in kivy-mode buffers.")
(if kivy-mode-syntax-table
nil
(setq kivy-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?\' "\"" kivy-mode-syntax-table)
(modify-syntax-entry ?\" "\"" kivy-mode-syntax-table)
(modify-syntax-entry ?# "<" kivy-mode-syntax-table)
(modify-syntax-entry ?\n ">" kivy-mode-syntax-table)
(modify-syntax-entry ?\\ "\\" kivy-mode-syntax-table)
(modify-syntax-entry ?- "_" kivy-mode-syntax-table)
(modify-syntax-entry ?_ "w" kivy-mode-syntax-table)
)
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.kv$" . kivy-mode))
;;;###autoload
(define-derived-mode kivy-mode fundamental-mode "kivy"
"Simple mode to edit kivy.
\\{kivy-mode-map}"
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'comment-start-skip) "#+ *")
(set (make-local-variable 'indent-line-function) 'kivy-indent-line)
(set (make-local-variable 'font-lock-defaults)
'(kivy-font-lock-keywords
nil nil nil nil
(font-lock-syntactic-keywords))))
;; Font-lock support
(defvar kivy-font-lock-keywords
(list
(cons kivy-comment-re '(1 font-lock-comment-face))
(cons kivy-constant-scalars-re '(1 font-lock-constant-face))
(cons kivy-tag-re '(1 font-lock-function-name-face))
(cons kivy-hash-key-re '(1 font-lock-variable-name-face t))
(cons kivy-directive-re '(1 font-lock-builtin-face))
'("^[\t]+" 0 'kivy-tab-face t))
"Additional expressions to highlight in kivy mode.")
(defvar kivy-font-lock-syntactic-keywords
(list '())
"Additional syntax features to highlight in kivy mode.")
;; Indentation and electric keys
(defun kivy-compute-indentation ()
"Calculate the maximum sensible indentation for the current line."
(save-excursion
(beginning-of-line)
(forward-line -1)
(while (and (looking-at kivy-blank-line-re)
(> (point) (point-min)))
(forward-line -1))
(+ (current-indentation)
(if (looking-at kivy-nested-map-re) kivy-indent-offset 0)
)))
(defun kivy-indent-line ()
"Indent the current line.
The first time this command is used, the line will be indented to the
maximum sensible indentation. Each immediately subsequent usage will
back-dent the line by `kivy-indent-offset' spaces. On reaching column
0, it will cycle back to the maximum sensible indentation."
(interactive "*")
(let ((ci (current-indentation))
(cc (current-column))
(need (kivy-compute-indentation)))
(save-excursion
(beginning-of-line)
(delete-horizontal-space)
(if (and (equal last-command this-command) (/= ci 0))
(indent-to (* (/ (- ci 1) kivy-indent-offset) kivy-indent-offset))
(indent-to need)))
(if (< (current-column) (current-indentation))
(forward-to-indentation 0))))
(defun kivy-electric-backspace (arg)
"Delete characters or back-dent the current line.
If invoked following only whitespace on a line, will back-dent to the
immediately previous multiple of `kivy-indent-offset' spaces."
(interactive "*p")
(if (or (/= (current-indentation) (current-column)) (bolp))
(funcall kivy-backspace-function arg)
(let ((ci (current-column)))
(beginning-of-line)
(delete-horizontal-space)
(indent-to (* (/ (- ci (* arg kivy-indent-offset))
kivy-indent-offset)
kivy-indent-offset)))))
(defun kivy-set-imenu-generic-expression ()
(make-local-variable 'imenu-generic-expression)
(make-local-variable 'imenu-create-index-function)
(setq imenu-create-index-function 'imenu-default-create-index-function)
(setq imenu-generic-expression kivy-imenu-generic-expression))
(add-hook 'kivy-mode-hook 'kivy-set-imenu-generic-expression)
(add-hook 'kivy-mode-hook
'(lambda ()
(setq indent-tabs-mode 'nil)))
(defun kivy-mode-version ()
"Diplay version of `kivy-mode'."
(interactive)
(message "kivy-mode %s" kivy-mode-version)
kivy-mode-version)
(defun kivy-indent-shift-left (start end &optional count)
"Shift lines contained in region START END by COUNT columns to the left.
COUNT defaults to `kivy-indent-offset'. If region isn't
active, the current line is shifted. The shifted region includes
the lines in which START and END lie. An error is signaled if
any lines in the region are indented less than COUNT columns."
(interactive
(if mark-active
(list (region-beginning) (region-end) current-prefix-arg)
(list (line-beginning-position) (line-end-position) current-prefix-arg)))
(if count
(setq count (prefix-numeric-value count))
(setq count kivy-indent-offset))
(when (> count 0)
(let ((deactivate-mark nil))
(save-excursion
(goto-char start)
(while (< (point) end)
(if (and (< (current-indentation) count)
(not (looking-at "[ \t]*$")))
(error "Can't shift all lines enough"))
(forward-line))
(indent-rigidly start end (- count))))))
(defun kivy-indent-shift-right (start end &optional count)
"Shift lines contained in region START END by COUNT columns to the left.
COUNT defaults to `kivy-indent-offset'. If region isn't
active, the current line is shifted. The shifted region includes
the lines in which START and END lie."
(interactive
(if mark-active
(list (region-beginning) (region-end) current-prefix-arg)
(list (line-beginning-position) (line-end-position) current-prefix-arg)))
(let ((deactivate-mark nil))
(if count
(setq count (prefix-numeric-value count))
(setq count kivy-indent-offset))
(indent-rigidly start end count)))
(provide 'kivy-mode)
;;; kivy-mode.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +0,0 @@
;;; scss-mode.el --- Major mode for editing SCSS files
;;
;; Author: Anton Johansson <anton.johansson@gmail.com> - http://antonj.se
;; 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
;; 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.
;;
;;; Commentary:
;;
;; Command line utility sass is required, see http://sass-lang.com/
;; To install sass:
;; gem install sass
;;
;; Also make sure sass location is in emacs PATH, example:
;; (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)
(setq-default tab-width 2)
(setq-default tab-stop-list number-sequence(2 120 2))
(defgroup scss nil
"Scss mode"
:prefix "scss-"
:group 'css)
(defcustom scss-sass-command "sass"
"Command used to compile SCSS files, should be sass or the
complete path to your sass runnable example:
\"~/.gem/ruby/1.8/bin/sass\""
:group 'scss)
(defcustom scss-compile-at-save t
"If not nil the SCSS buffers will be compiled after each save"
:type 'boolean
:group 'scss)
(defcustom scss-sass-options '()
"Command line Options for sass executable, for example:
'(\"--cache-location\" \"'/tmp/.sass-cache'\")"
:group 'scss)
(defcustom scss-output-directory nil
"Output directory for compiled files, for example:
\"../css\""
: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
HYPERLINK HIGHLIGHT)"
:group 'scss)
(defconst scss-font-lock-keywords
;; Variables
'(("$[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"
(if scss-compile-at-save
(scss-compile)))
(defun scss-compile()
"Compiles the directory belonging to the current buffer, using the --update option"
(interactive)
(compile (concat scss-sass-command " " (mapconcat 'identity scss-sass-options " ") " --update "
(when (string-match ".*/" buffer-file-name)
(concat "'" (match-string 0 buffer-file-name) "'"))
(when scss-output-directory
(concat ":'" scss-output-directory "'")))))
;;;###autoload
(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