diff --git a/init.el b/init.el index f784fc4..818fccb 100644 --- a/init.el +++ b/init.el @@ -13,53 +13,41 @@ (package-initialize) (setq my-required-packages (list 'magit - ;; 'evil - ;; 'evil-tabs - ;; 'evil-jumper - ;; 'evil-visualstar - ;; 'evil-search-highlight-persist - ;; 'surround - ;; 'powerline-evil + 'solarized-theme + 'swiper ;; visual regex search + 'expand-region + 'wrap-region 'exec-path-from-shell 'visual-regexp 'buffer-move ;; used for rotating buffers 'visual-regexp-steroids 'ido-vertical-mode 'yafolding - 'robe 's 'coffee-mode - 'ag - 'git-timemachine + 'git-timemachine ;; Walk through git revisions of a file 'sourcemap + 'slim-mode 'bundler 'projectile 'projectile-rails - 'helm-ack - 'helm-projectile - 'helm-robe - 'rubocop 'scss-mode 'sass-mode 'f 'jump 'discover 'fiplr - ;;'ack-and-a-half 'yard-mode ;; fontification in ruby comments + 'goto-gem ;; Open dired in a gem directory 'ruby-tools - 'persp-projectile 'ruby-block 'ruby-additional 'ruby-hash-syntax 'ruby-refactor - 'magit-gh-pulls - 'rhtml-mode 'dired-details 'yasnippet 'yari 'ibuffer-vc - 'fill-column-indicator 'rvm 'rinari 'web-mode @@ -67,12 +55,13 @@ 'auto-compile 'yaml-mode 'rspec-mode - 'expand-region 'undo-tree 'inf-ruby - 'smartscan ;; Quickly jumps between other symbols found at point in Emacs + 'smartscan ;; Quickly jumps between other symbols found at point in Emacs 'discover-my-major 'goto-chg + 'anzu + 'fullframe )) (dolist (package my-required-packages) @@ -89,19 +78,29 @@ (add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode)) ;; for smooth scrolling and disabling the automatical recentering of emacs when moving the cursor -(setq scroll-margin 1 - scroll-conservatively 0) -(setq-default scroll-up-aggressively 0.01 - scroll-down-aggressively 0.01) +(setq scroll-margin 5 + scroll-preserve-screen-position 1) + +;; Display full path in the window title bar +(setq-default frame-title-format '((:eval (if (buffer-file-name) + (abbreviate-file-name (buffer-file-name)) "%f")))) ;; Disable the scroll bar (scroll-bar-mode 0) -;; Expand region -(require 'expand-region) +(require 'anzu) ;; Shows a count of search matches +(global-anzu-mode +1) +(global-set-key (kbd "M-%") 'anzu-query-replace) +(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp) -;; Enable accents in GUI -(require 'iso-transl) +(require 'iso-transl) ;; Enable accents in GUI +(require 'goto-chg) ;; Go to last change +(require 'fullframe) +(fullframe magit-status magit-mode-quit-window nil) +(require 'slim-mode) + +;; Set fill-column +(setq-default fill-column 80) ;; Enable SmartScan (smartscan-mode 1) @@ -112,25 +111,9 @@ ;; Don't warn me when opening large files (setq large-file-warning-threshold nil) -;; Magit GH pulls -(eval-after-load 'magit - '(define-key magit-mode-map "#gg" - 'endless/load-gh-pulls-mode)) - -(defun endless/load-gh-pulls-mode () - "Start `magit-gh-pulls-mode' only after a manual request." - (interactive) - (require 'magit-gh-pulls) - (add-hook 'magit-mode-hook 'turn-on-magit-gh-pulls) - (magit-gh-pulls-mode 1) - (magit-gh-pulls-reload)) - ;; Enable copy and pasting from clipboard (setq x-select-enable-clipboard t) -;; Disable the menu -(menu-bar-mode 0) - ;; Enable IDO (load "~/.emacs.d/my-ido.el") @@ -142,30 +125,40 @@ ;; Prefer utf-8 encoding (prefer-coding-system 'utf-8) -;; Go to last change -(require 'goto-chg) +;; Display information about the current function +(require 'eldoc) + +;; Configure hippie-expand +(defadvice hippie-expand (around hippie-expand-case-fold) + "Try to do case-sensitive matching (not effective with all functions)." + (let ((case-fold-search nil)) + ad-do-it)) +(ad-activate 'hippie-expand) +(setq hippie-expand-try-functions-list + '(try-expand-dabbrev + try-expand-dabbrev-all-buffers + )) ;; Web mode (require 'web-mode) (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) -(setq web-mode-markup-indent-offset 2) ;; Coffee Script (setq coffee-args-compile '("-c" "-m")) ;; generating sourcemap (add-hook 'coffee-after-compile-hook 'sourcemap-goto-corresponding-point) -(defun coffee-after-compile-delete-file (props) +;; If you want to remove sourcemap file after jumping corresponding point +(defun my/coffee-after-compile-hook (props) + (sourcemap-goto-corresponding-point props) (delete-file (plist-get props :sourcemap))) -(add-hook 'coffee-after-compile-hook 'coffee-after-compile-delete-file t) +(add-hook 'coffee-after-compile-hook 'my/coffee-after-compile-hook) ;; Custom themes (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") ;; Choosing a dark theme ;; (load-theme 'base16-default t) ;; (load-theme 'tango-dark t) -(load-theme 'wilson t) - -;; Prevent adding the coding line -(setq ruby-insert-encoding-magic-comment nil) +;;(load-theme 'wilson t) +(load-theme 'solarized-dark t) ;; Always open split windows horizontally (setq split-height-threshold 0) @@ -183,6 +176,8 @@ (require 'yasnippet) (yas-global-mode 1) (setq yas-snippet-dirs "~/.emacs.d/snippets") +;; Disable skeletons in projectile-rails +(setq projectile-rails-expand-snippet nil) ;; Always ident with 2 spaces (setq-default indent-tabs-mode nil) @@ -190,6 +185,9 @@ (setq-default c-basic-offset 2) (setq css-indent-offset 2) (setq js-indent-level 2) +(setq web-mode-markup-indent-offset 2) +(setq web-mode-code-indent-offset 2) +(setq web-mode-css-indent-offset 2) ;; Use the short version for yes/no (fset 'yes-or-no-p 'y-or-n-p) @@ -202,19 +200,14 @@ ;; Diable bold and underline faces (when (display-graphic-p) - (mapc - (lambda (face) - (set-face-attribute face nil :weight 'normal :underline nil)) - (face-list)) (menu-bar-mode 1) - (set-face-attribute 'default nil :foreground "gray" :font "Inconsolata-13" :height 155) - ) + (set-face-attribute 'default nil :foreground "gray" :font "Inconsolata-13" :height 155)) ;; ;; Showing whitespace (require 'whitespace) (setq whitespace-line-column 80) ;; limit line length -(setq whitespace-style '(face lines-tail)) -(setq whitespace-style (quote (spaces tabs newline space-mark tab-mark newline-mark))) +;;(setq whitespace-style '(spaces tabs newline space-mark tab-mark newline-mark lines-tail)) +(setq whitespace-style '(spaces tabs newline space-mark tab-mark newline-mark face lines-tail)) (setq whitespace-display-mappings ;; all numbers are Unicode codepoint in decimal. e.g. (insert-char 182 1) '( @@ -222,7 +215,10 @@ (newline-mark 10 [172 10]) ; 10 LINE FEED (tab-mark 9 [183 9] [92 9]) ; 9 TAB, MIDDLE DOT )) -(global-whitespace-mode 1) + +;;(add-hook 'prog-mode-hook 'whitespace-mode) +(setq whitespace-global-modes '(not org-mode web-mode "Web" emacs-lisp-mode)) +(global-whitespace-mode) ;; Setting a default line-height (setq-default line-spacing 1) @@ -250,12 +246,6 @@ ;; Custom functions (load "~/.emacs.d/my-functions") -;; Evil stuff -;; (load "~/.emacs.d/my-evil") - -;; Hide the modeline -(load "~/.emacs.d/hidden-mode-line") - ;; Make CMD work like ALT (on the Mac) (setq mac-command-modifier 'meta) ;; (setq mac-option-modifier 'none) @@ -276,10 +266,6 @@ ;; Use frames instead of windows for compilation popups ;; (setq-default display-buffer-reuse-frames t) -;; Show line numbers only in opened files -;; Another option could be: http://www.emacswiki.org/emacs/linum-off.el -;; (add-hook 'find-file-hook (lambda () (linum-mode 1))) - ;; Format line numbers (setq linum-format "%4d ") @@ -314,10 +300,10 @@ (mark " " (name 16 -1) " " filename))) (setq ibuffer-show-empty-filter-groups nil) - +;;(add-to-list 'ibuffer-never-show-predicates "TAGS") +;;(add-to-list 'ibuffer-never-show-predicates "*Backtrace*") (add-hook 'ibuffer-mode-hook '(lambda () - (ibuffer-auto-mode 1) (ibuffer-vc-set-filter-groups-by-vc-root))) ;; Uniquify buffers @@ -333,47 +319,10 @@ (require 'discover) (global-discover-mode 1) -;; RVM -(require 'rvm) -(rvm-use-default) - -;; Cucumber -(require 'feature-mode) -(setq feature-use-rvm t) -(setq feature-cucumber-command "cucumber {options} {feature}") -(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode)) - -;; Rspec -(require 'rspec-mode) -(setq rspec-use-rake-when-possible nil) - ;; Scss (autoload 'scss-mode "scss-mode") (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode)) -(defun my-create-non-existent-directory () - (let ((parent-directory (file-name-directory buffer-file-name))) - (when (and (not (file-exists-p parent-directory)) - (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) - (make-directory parent-directory t)))) -(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory) - -;; Use bash -(setq explicit-shell-file-name "/bin/bash") -(eval-after-load "term" - '(define-key term-raw-map (kbd "C-c C-y") 'term-paste)) -;; Close the terminal buffer on exit -(defun oleh-term-exec-hook () - (let* ((buff (current-buffer)) - (proc (get-buffer-process buff))) - (set-process-sentinel - proc - `(lambda (process event) - (if (string= event "finished\n") - (kill-buffer ,buff)))))) - -(add-hook 'term-exec-hook 'oleh-term-exec-hook) - ;; Undo tree (require 'undo-tree) (global-undo-tree-mode 1) @@ -409,19 +358,9 @@ point reaches the beginning or end of the buffer, stop there." (interactive) (find-file (expand-file-name "init.el" user-emacs-directory))) -;; all buffers, try to reuse windows across all frames -(add-to-list 'display-buffer-alist - '(".*". (display-buffer-reuse-window . - ((reusable-frames . t))))) - -;; except for compilation buffers where you want new and dedicated frames when necessary -(add-to-list 'display-buffer-alist - '("^\\*Compile-Log\\*". ((display-buffer-reuse-window - display-buffer-pop-up-frame) . - ((reusable-frames . t) - (inhibit-same-window . t))))) - ;; Key bindings +(global-set-key (kbd "M-z") 'zap-up-to-char) + (global-set-key (kbd "M-f") 'forward-to-word) (global-set-key (kbd "M-F") 'forward-word) @@ -435,21 +374,19 @@ point reaches the beginning or end of the buffer, stop there." (global-set-key (kbd "") 'open-emacs-init-file) (global-unset-key (kbd "C-c C-x")) (global-set-key (kbd "C-c C-x") 'execute-extended-command) -(global-set-key (kbd "C-c C-a") 'ack-and-a-half) +(global-set-key (kbd "C-c a") 'ag) (global-set-key (kbd "C-c j") 'dired-jump) (global-set-key (kbd "C-c d") 'duplicate-line) -(global-set-key (kbd "C-x b") 'helm-buffers-list) +;;(global-set-key (kbd "C-x b") 'helm-buffers-list) (global-set-key (kbd "C-x C-b") 'ibuffer) (global-set-key (kbd "C-x k") 'kill-this-buffer) (global-set-key (kbd "C-c K") 'kill-buffer-and-window) (global-set-key (kbd "C-c o") 'vi-open-line-below) -(global-set-key (kbd "C-=") 'er/expand-region) (global-set-key (kbd "C-c O") 'vi-open-line-above) -(global-set-key (kbd "C-c a w") 'ace-jump-word-mode) -(global-set-key (kbd "C-c a l") 'ace-jump-line-mode) -(global-set-key (kbd "C-c a c") 'ace-jump-char-mode) (global-set-key (kbd "C-c , s") 'rspec-verify-single) (global-set-key (kbd "C-c , r") 'rspec-rerun) +(global-set-key (kbd "C-s") 'isearch-forward-regexp) +(global-set-key (kbd "C-r") 'isearch-backward-regexp) (global-set-key (kbd "M-/") 'hippie-expand) (global-set-key (kbd "M-") 'cycle-spacing) (global-set-key [(control ?.)] 'goto-last-change) @@ -474,13 +411,14 @@ point reaches the beginning or end of the buffer, stop there." ;; If there is more than one, they won't work right. '(custom-safe-themes (quote - ("cdc7555f0b34ed32eb510be295b6b967526dd8060e5d04ff0dce719af789f8e5" "3a727bdc09a7a141e58925258b6e873c65ccf393b2240c51553098ca93957723" "6a37be365d1d95fad2f4d185e51928c789ef7a4ccf17e7ca13ad63a8bf5b922f" "756597b162f1be60a12dbd52bab71d40d6a2845a3e3c2584c6573ee9c332a66e" "af9761c65a81bd14ee3f32bc2ffc966000f57e0c9d31e392bc011504674c07d6" "a4f8d45297894ffdd98738551505a336a7b3096605b467da83fae00f53b13f01" "1affe85e8ae2667fb571fc8331e1e12840746dae5c46112d5abb0c3a973f5f5a" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "de2c46ed1752b0d0423cde9b6401062b67a6a1300c068d5d7f67725adc6c3afb" "405fda54905200f202dd2e6ccbf94c1b7cc1312671894bc8eca7e6ec9e8a41a2" "41b6698b5f9ab241ad6c30aea8c9f53d539e23ad4e3963abff4b57c0f8bf6730" "b47a3e837ae97400c43661368be754599ef3b7c33a39fd55da03a6ad489aafee" default))) + ("a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" "cdc7555f0b34ed32eb510be295b6b967526dd8060e5d04ff0dce719af789f8e5" "3a727bdc09a7a141e58925258b6e873c65ccf393b2240c51553098ca93957723" "6a37be365d1d95fad2f4d185e51928c789ef7a4ccf17e7ca13ad63a8bf5b922f" "756597b162f1be60a12dbd52bab71d40d6a2845a3e3c2584c6573ee9c332a66e" "af9761c65a81bd14ee3f32bc2ffc966000f57e0c9d31e392bc011504674c07d6" "a4f8d45297894ffdd98738551505a336a7b3096605b467da83fae00f53b13f01" "1affe85e8ae2667fb571fc8331e1e12840746dae5c46112d5abb0c3a973f5f5a" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "de2c46ed1752b0d0423cde9b6401062b67a6a1300c068d5d7f67725adc6c3afb" "405fda54905200f202dd2e6ccbf94c1b7cc1312671894bc8eca7e6ec9e8a41a2" "41b6698b5f9ab241ad6c30aea8c9f53d539e23ad4e3963abff4b57c0f8bf6730" "b47a3e837ae97400c43661368be754599ef3b7c33a39fd55da03a6ad489aafee" default))) '(feature-cucumber-command "bundle exec cucumber {options} {feature}") '(magit-emacsclient-executable "/usr/local/bin/emacsclient") '(magit-restore-window-configuration t) '(magit-server-window-for-commit nil) - '(rspec-spec-command "spring rspec") + '(rspec-spec-command "rspec") '(rspec-use-bundler-when-possible nil) + '(rspec-use-rvm t) '(rspec-use-spring-when-possible t) '(scss-compile-at-save nil)) (custom-set-faces @@ -488,6 +426,7 @@ point reaches the beginning or end of the buffer, stop there." ;; 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. + '(compilation-mode-line-fail ((t (:inherit compilation-error :weight bold)))) '(diff-added ((t (:inherit diff-changed :foreground "#00cc33")))) '(diff-removed ((t (:inherit diff-changed :foreground "tomato")))) '(ediff-even-diff-C ((t nil))) @@ -502,6 +441,7 @@ point reaches the beginning or end of the buffer, stop there." '(web-mode-html-attr-name-face ((t (:foreground "dark gray" :underline nil :weight normal)))) '(web-mode-html-tag-bracket-face ((t (:foreground "gray58" :underline nil :weight normal)))) '(web-mode-html-tag-face ((t (:foreground "dark cyan" :underline nil :weight normal)))) - '(whitespace-newline ((t (:foreground "#3f3f3f" :weight thin))))) + '(whitespace-newline ((t (:foreground "gray31" :weight thin)))) + '(whitespace-space ((t nil)))) (put 'downcase-region 'disabled nil) (put 'dired-find-alternate-file 'disabled nil) diff --git a/my-dired.el b/my-dired.el index abc9c40..4b376ca 100644 --- a/my-dired.el +++ b/my-dired.el @@ -1,6 +1,7 @@ ;; I want this for dired-jump (require 'dired-x) +;; I usually want to see just the file names (require 'dired-details) (dired-details-install) @@ -19,7 +20,7 @@ (setq dired-omit-files "^\\..*$\\|^\\.\\.$") (setq dired-omit-mode t) - +;; List directories first (defun sof/dired-sort () "Dired sort hook to list directories first." (save-excursion @@ -33,6 +34,14 @@ (add-hook 'dired-after-readin-hook 'sof/dired-sort) +;; Automatically create missing directories when creating new files +(defun my-create-non-existent-directory () + (let ((parent-directory (file-name-directory buffer-file-name))) + (when (and (not (file-exists-p parent-directory)) + (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) + (make-directory parent-directory t)))) +(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory) + ;; Use ls from emacs (when (eq system-type 'darwin) (require 'ls-lisp) @@ -56,9 +65,6 @@ (define-key dired-mode-map (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom) -;; Move files between split panes -(setq dired-dwim-target t) - ;; C-a is nicer in dired if it moves back to start of files (defun dired-back-to-start-of-files () (interactive) diff --git a/my-functions.el b/my-functions.el index acbb8e4..cd88e12 100644 --- a/my-functions.el +++ b/my-functions.el @@ -1,9 +1,58 @@ -(defun isearch-exit-other-end (rbeg rend) - "Exit isearch, but at the other end of the search string. - This is useful when followed by an immediate kill." +(defun my-goto-match-beginning () + (when (and isearch-forward isearch-other-end) + (goto-char isearch-other-end))) +(add-hook 'isearch-mode-end-hook 'my-goto-match-beginning) +(defadvice isearch-exit (after my-goto-match-beginning activate) + "Go to beginning of match." + (when (and isearch-forward isearch-other-end) + (goto-char isearch-other-end))) + +;; Search back/forth for the symbol at point +;; See http://www.emacswiki.org/emacs/SearchAtPoint +(defun isearch-yank-symbol () + "*Put symbol at current point into search string." + (interactive) + (let ((sym (symbol-at-point))) + (if sym + (progn + (setq isearch-regexp t + isearch-string (concat "\\_<" (regexp-quote (symbol-name sym)) "\\_>") + isearch-message (mapconcat 'isearch-text-char-description isearch-string "") + isearch-yank-flag t)) + (ding))) + (isearch-search-and-update)) + +(define-key isearch-mode-map "\C-w" 'isearch-yank-symbol) + +;; http://www.emacswiki.org/emacs/ZapToISearch +(defun zap-to-isearch (rbeg rend) + "Kill the region between the mark and the closest portion of +the isearch match string. The behaviour is meant to be analogous +to zap-to-char; let's call it zap-to-isearch. The deleted region +does not include the isearch word. This is meant to be bound only +in isearch mode. The point of this function is that oftentimes +you want to delete some portion of text, one end of which happens +to be an active isearch word. The observation to make is that if +you use isearch a lot to move the cursor around (as you should, +it is much more efficient than using the arrows), it happens a +lot that you could just delete the active region between the mark +and the point, not include the isearch word." (interactive "r") - (isearch-exit) - (goto-char isearch-other-end)) + (when (not mark-active) + (error "Mark is not active")) + (let* ((isearch-bounds (list isearch-other-end (point))) + (ismin (apply 'min isearch-bounds)) + (ismax (apply 'max isearch-bounds)) + ) + (if (< (mark) ismin) + (kill-region (mark) ismin) + (if (> (mark) ismax) + (kill-region ismax (mark)) + (error "Internal error in isearch kill function."))) + (isearch-exit) + )) + +(define-key isearch-mode-map [(meta z)] 'zap-to-isearch) (defun find-tag-at-point () "Runs find-tag with the word at point as the argument" diff --git a/my-ido.el b/my-ido.el index 21e1fd4..c27f465 100644 --- a/my-ido.el +++ b/my-ido.el @@ -1,21 +1,23 @@ ;; Ido -(require 'ido) ;; loading a newer version which fixes flex matching -(require 'ido-vertical-mode) +(require 'ido) (ido-mode 1) + +;; Display results vertically +(require 'ido-vertical-mode) (ido-vertical-mode) (setq ido-enable-prefix nil ido-enable-flex-matching t - ido-case-fold nil - ido-auto-merge-work-directories-length -1 - ido-create-new-buffer 'always - ido-use-filename-at-point nil - ido-max-prospects 10) - -;; disable ido faces to see flx highlights. -(setq ido-use-faces nil) + ido-case-fold t ;; ignore case + ido-auto-merge-work-directories-length -1 ;; disable auto-merge (it's confusing) + ido-create-new-buffer 'always ;; create new files easily + ido-use-filename-at-point nil ;; don't try to be smart about what I want + ) +;; I like visual matching (colors) +(setq ido-use-faces t) +;; Ido buffer intuitive navigation (add-hook 'ido-setup-hook '(lambda () (define-key ido-completion-map "\C-h" 'ido-delete-backward-updir) (define-key ido-completion-map "\C-n" 'ido-next-match) diff --git a/my-magit.el b/my-magit.el index a416c4e..c2d7037 100644 --- a/my-magit.el +++ b/my-magit.el @@ -4,22 +4,10 @@ (set-face-foreground 'diff-context "#666666") (set-face-foreground 'diff-added "#00cc33") (set-face-foreground 'diff-removed "#ff0000") +(setq magit-server-window-for-commit nil) +(setq magit-emacsclient-executable "/usr/local/bin/emacsclient") ;; Enable a right limit of 70 chars for git logs (add-hook 'magit-log-edit-mode-hook 'turn-on-auto-fill) -;; full screen magit-status -(defadvice magit-status (around magit-fullscreen activate) - (window-configuration-to-register :magit-fullscreen) - ad-do-it - (delete-other-windows)) - -(defun magit-quit-session () - "Restores the previous window configuration and kills the magit buffer" - (interactive) - (kill-buffer) - (jump-to-register :magit-fullscreen)) - -(define-key magit-status-mode-map (kbd "q") 'magit-quit-session) - (provide 'my-magit) diff --git a/my-ruby.el b/my-ruby.el index e2f4bcb..9e6f66f 100644 --- a/my-ruby.el +++ b/my-ruby.el @@ -1,3 +1,4 @@ +;; Files with the following extensions should open in ruby-mode (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode)) (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode)) @@ -7,63 +8,65 @@ (require 'ruby-mode) (require 'inf-ruby) -(setq ruby-deep-indent-paren nil) + +;; When folding, take these delimiters into consideration (add-to-list 'hs-special-modes-alist '(ruby-mode "\\(class\\|def\\|do\\|if\\)" "\\(end\\)" "#" (lambda (arg) (ruby-end-of-block)) nil)) +;; RVM support +(require 'rvm) +(rvm-use-default) + +;; Cucumber +(require 'feature-mode) +(setq feature-use-rvm t) ;; Tell cucumber to use RVM +(setq feature-cucumber-command "cucumber {options} {feature}") +;; .feature files should open in feature-mode +(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode)) + +;; Rspec +(require 'rspec-mode) +;; I want rspec instead of rake spec +(setq rspec-use-rake-when-possible nil) +;; Scroll to the first test failure +(setq compilation-scroll-output 'first-error) + ;; Projectile mode (require 'projectile) (projectile-global-mode) (setq projectile-completion-system 'grizzl) -(require 'persp-projectile) -(persp-mode) -(define-key projectile-mode-map (kbd "s-s") 'projectile-persp-switch-project) -(helm-projectile-on) - -;; Populate the `magit-repo-dirs` variable with the .git projects you -;; visited so that when you hit C-u M-x git-status you can choose to -;; open one of those repos -(eval-after-load "projectile" - '(progn (setq magit-repo-dirs (mapcar (lambda (dir) - (substring dir 0 -1)) - (remove-if-not (lambda (project) - (file-directory-p (concat project "/.git/"))) - (projectile-relevant-known-projects))) - - magit-repo-dirs-depth 1))) - -(require 'robe) -(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate) - (rvm-activate-corresponding-ruby)) - -;; Make _ parts of the "word" -(modify-syntax-entry ?_ "w" ruby-mode-syntax-table) +;; Prevent emacs from adding the encoding line at the top of the file +(setq ruby-insert-encoding-magic-comment nil) +;; Functions to help with refactoring (require 'ruby-refactor) +(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch) +;; Easily toggle ruby's hash syntax (require 'ruby-hash-syntax) +;; Ruby rdoc helpers mostly (require 'ruby-additional) -(require 'ruby-block) -(ruby-block-mode t) +;; Helpers to deal with strings and symbols (require 'ruby-tools) +;; Support for YARD (require 'yard-mode) +(add-hook 'ruby-mode-hook 'yard-mode) +;; Support for running rspec tests (require 'rspec-mode) -(require 'eldoc) -(require 'rubocop) - -;; Bind YARI to C-h R -(require 'yari) -(define-key 'help-command "R" 'yari) +;; Turn on eldoc in ruby files to display info about the +;; method or variable at point (add-hook 'ruby-mode-hook 'eldoc-mode) +;; Switch the compilation buffer mode with C-x C-q (useful +;; when interacting with a debugger) (add-hook 'after-init-hook 'inf-ruby-switch-setup) -(add-hook 'ruby-mode-hook 'yard-mode) -(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch) -(add-hook 'ruby-mode-hook 'robe-mode) + (add-hook 'ruby-mode-hook (lambda () (hs-minor-mode 1) ;; Enables folding (modify-syntax-entry ?: "."))) ;; Adds ":" to the word definition + +;; Start projectile-rails (add-hook 'projectile-mode-hook 'projectile-rails-on) diff --git a/vendor/fill-column-indicator.el b/vendor/fill-column-indicator.el deleted file mode 100644 index 7c1c134..0000000 --- a/vendor/fill-column-indicator.el +++ /dev/null @@ -1,904 +0,0 @@ -;;; fill-column-indicator.el --- Graphically indicate the fill column - -;; Copyright (c) 2011-2012 Alp Aker - -;; Author: Alp Aker -;; Version: 1.85 -;; Keywords: convenience - -;; 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. - -;; A copy of the GNU General Public License can be obtained from the -;; Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, -;; MA 02111-1307 USA - -;;; Commentary: - -;; Many modern editors and IDEs can graphically indicate the location of the -;; fill column by drawing a thin line (in design parlance, a `rule') down the -;; length of the editing window. Fill-column-indicator implements this -;; facility in Emacs. - -;; PLEASE NOTE: There is a small incompatibility between this package and the -;; current stable Emacs relase (v24.3). A bug in Emacs's internal display -;; routine that was introduced shortly before that release can cause vertical -;; motion commands to skip blank lines when fci-mode is active. This has -;; been fixed in Emacs trunk. See github.com/alpaker/Fill-Column-Indicator/issues/31 -;; for further discussion. - -;; Installation and Usage -;; ====================== - -;; Put this file in your load path and put: -;; -;; (require 'fill-column-indicator) -;; -;; in your init file. - -;; To toggle graphical indication of the fill column in a buffer, use the -;; command `fci-mode'. - -;; Configuration -;; ============= - -;; By default, fci-mode draws its vertical indicator at the fill column. If -;; you'd like it to be drawn at another column, set `fci-rule-column' to the -;; column number. (A case in which this might be useful is when you want to -;; fill comments at, for example, column 70, but want a vertical rule at -;; column 80 or 100 to indicate the maximum line length for code.) The -;; default behavior (showing the indicator at the fill column) is specified -;; by setting fci-rule-column to nil. Note that this variable becomes buffer -;; local when set. - -;; On graphical displays the fill-column rule is drawn using a bitmap -;; image. Its color is controlled by the variable `fci-rule-color', whose -;; value can be any valid color name. The rule's width in pixels is -;; determined by the variable `fci-rule-width'; the default value is 1. - -;; The rule can be drawn as a solid or dashed line, controlled by the -;; variable `fci-rule-use-dashes'; the default is nil. The dash appearance is -;; controlled by `fci-dash-pattern', which is the ratio of dash length to -;; line height; the default is 0.75. (The value should be a number between 0 -;; and 1; values outside that interval are coerced to the nearest endpoint.) - -;; The image formats fci-mode can use are XPM and PBM. If Emacs has been -;; compiled with the appropriate library it uses XPM images by default; if -;; not it uses PBM images, which are natively supported. You can specify a -;; particular choice of format by setting `fci-rule-image-format' explicitly -;; to xpm or pbm. - -;; On character terminals the rule is drawn using the character specified by -;; `fci-rule-character'; the default is `|' (ascii 124). If -;; `fci-rule-character-color' is nil, then it is drawn using fci-rule-color -;; (or the closest approximation thereto that the terminal is capable of); if -;; it is a color name, then that color is used instead. - -;; If you'd like the rule to be drawn using fci-rule-character even on -;; graphical displays, set `fci-always-use-textual-rule' to a non-nil value. - -;; These variables (as well as those described in the next section) can be -;; given buffer-local bindings. - -;; Other Options -;; ============= - -;; When `truncate-lines' is nil, the effect of drawing a fill-column rule is -;; very odd looking. Indeed, it makes little sense to use a rule to indicate -;; the position of the fill column in that case (the positions at which the -;; fill column falls in the visual display space won't, in general, be -;; collinear). For this reason, fci-mode sets truncate-lines to t in buffers -;; in which it is enabled and restores it to its previous value when -;; disabled. You can turn this feature off by setting -;; `fci-handle-truncate-lines' to nil. - -;; If `line-move-visual' is t, then vertical navigation can behave oddly in -;; several edge cases while fci-mode is enabled (this is due to a bug in -;; Emacs's C code). Accordingly, fci-mode sets line-move-visual to nil in -;; buffers in which it is enabled and restores it to its previous value when -;; disabled. This can be suppressed by setting `fci-handle-line-move-visual' -;; to nil. (But you shouldn't want to do this. There's no reason to use -;; line-move-visual if truncate-lines is t, and it doesn't make sense to use -;; something like fci-mode when truncate-lines is nil.) - -;; Fci-mode needs free use of two characters (specifically, it needs the use -;; of two characters whose display table entries it can change -;; arbitrarily). Its defualt is to use the first two characters of the -;; Private Use Area of the Unicode BMP, viz. U+E000 and U+E001. If you need -;; to use those characters for some other purpose, set `fci-eol-char' and -;; `fci-blank-char' to different values. - -;; Troubleshooting -;; =============== - -;; o Fci-mode is intended to be used with monospaced fonts. If you're using -;; a monospaced font and the fill-column rule is missing or misaligned on a -;; few lines but otherwise appears normal, then most likely (a) there are -;; non-ascii characters on those lines that are being displayed using a -;; non-monospaced font, or (b) your font-lock settings use bold or italics -;; and those font variants aren't monospaced. - -;; o Fci-mode in not currently compatible with Emacs's -;; `show-trailing-whitespace' feature (given the way the latter is -;; implemented, such compatibility is going to be hard to achieve). A -;; workaround is to configure `whitespace-mode' to replicate the -;; functionality of show-trailing-whitespace. This can be done with the -;; following setting: -;; -;; (setq whitespace-style '(face trailing)) -;; -;; With this, whitespace-mode produces the same basic effect as a non-nil -;; value of show-trailing-whitespace, and compatibility with fci-mode is not -;; a problem. - -;; Known Issues -;; ============ - -;; o The indicator extends only to end of the buffer contents (as opposed to -;; running the full length of the editing window). - -;; o When portions of a buffer are invisible, such as when outline-mode is -;; used to hide certain lines, the fill-column rule is hidden as well. - -;; o Fci-mode should work smoothly when simultaneously displaying the same -;; buffer on both a graphical display and on a character terminal. It does -;; not currently support simultaneous display of the same buffer on window -;; frames with different default font sizes. (It would be feasible to -;; support this use case, but thus far there seems to be no demand for -;; it.) - -;; o An issue specific to the Mac OS X (NextStep) port, versions 23.0-23.2: -;; Emacs won't, in these particular versions, draw a cursor on top of an -;; image. Thus on graphical displays the cursor will disappear when -;; positioned directly on top of the fill-column rule. The best way to -;; deal with this is to upgrade to v23.3 or v24 (or downgrade to v22). If -;; that isn't practical, a fix is available via the mini-package -;; fci-osx-23-fix.el, which can be downloaded from: -;; -;; github.com/alpaker/Fill-Column-Indicator -;; -;; Directions for its use are given in the file header. - -;; Todo -;; ==== - -;; o Accommodate non-nil values of `hl-line-sticky-flag' and similar cases. - -;; o Accommodate linum-mode more robustly. - -;; o Compatibility with non-nil `show-trailing-whitespace.' - -;; Acknowledgements -;; ================ - -;; Thanks to Ami Fischman, Christopher Genovese, Michael Hoffman, José -;; Alfredo Romero L., R. Lange, Joe Lisee, José Lombera, Frank Meffert, -;; Mitchell Peabody, sheijk, and an anonymous BT subscriber for bug reports -;; and suggestions. Special thanks to lomew, David Röthlisberger, and Pär -;; Wieslander for code contributions. - -;;; Code: - -(unless (version<= "22" emacs-version) - (error "Fill-column-indicator requires version 22 or later")) - -;;; --------------------------------------------------------------------- -;;; User Options -;;; --------------------------------------------------------------------- - -(defgroup fill-column-indicator nil - "Graphically indicate the fill-column." - :tag "Fill-Column Indicator" - :group 'convenience - :group 'fill) - -;; We should be using :validate instead of :match, but that seems not to -;; work with defcustom widgets. -(defcustom fci-rule-column nil - "Controls where fci-mode displays a vertical line (rule). - -If nil, the rule is drawn at the fill column. Otherwise, it is -drawn at the column given by this variable. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :group 'fill-column-indicator - :tag "Fill-Column rule column" - :type '(choice (const :tag "Use the fill column" nil) - (integer :tag "Use a custom column" - :match (lambda (w val) (fci-posint-p val))))) - -(make-variable-buffer-local 'fci-rule-column) - -(defcustom fci-rule-color "#cccccc" - "Color used to draw the fill-column rule. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :group 'fill-column-indicator - :tag "Fill-column rule color" - :type 'color) - -(defcustom fci-rule-width 1 - "Width in pixels of the fill-column rule on graphical displays. -Note that a value greater than the default character width is -treated as equivalent to the default character width. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Fill-Column Rule Width" - :group 'fill-column-indicator - :type '(integer :match (lambda (w val) (fci-posint-p val)))) - -(defcustom fci-rule-image-format - (if (image-type-available-p 'xpm) 'xpm 'pbm) - "Image format used for the fill-column rule on graphical displays. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Fill-Column Rule Image Format" - :group 'fill-column-indicator - :type '(choice (symbol :tag "XPM" 'xpm) - (symbol :tag "PBM" 'pbm))) - -(defcustom fci-rule-use-dashes nil - "Whether to show the fill-column rule as dashes or as a solid line. -This has no effect on non-graphical displays. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Fill-Column Rule Use Dashes" - :group 'fill-column-indicator - :type 'boolean) - -(defcustom fci-dash-pattern 0.75 - "When using a dashed rule, ratio of dash length to line height. -Values less than 0 or greather than 1 are coerced to the nearest -endpoint of that interval. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Fill-Column Rule Use Dashes" - :group 'fill-column-indicator - :type 'float) - -(defcustom fci-rule-character ?| - "Character used to draw the fill-column rule on character terminals. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Fill-Column Rule Character" - :group 'fill-column-indicator - :type 'character) - -(defcustom fci-rule-character-color nil - "Color used to draw the fill-column rule on character terminals. -If nil, the same color is used as for the graphical rule. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :group 'fill-column-indicator - :tag "Fill-column rule color" - :type '(choice (const :tag "Use same color as graphical rule" nil) - (color :tag "Specify a color"))) - -(defcustom fci-always-use-textual-rule nil - "When non-nil, the rule is always drawn using textual characters. -Specifically, fci-mode will use `fci-rule-character' intead of -bitmap images to draw the rule on graphical displays. - -Changes to this variable do not take effect until the mode -function `fci-mode' is run." - :tag "Don't Use Image for Fill-Column Rule" - :group 'fill-column-indicator - :type 'boolean) - -(defcustom fci-handle-truncate-lines t - "Whether fci-mode should set truncate-lines to t while enabled. -If non-nil, fci-mode will set truncate-lines to t in buffers in -which it is enabled, and restore it to its previous value when -disabled. - -Leaving this option set to the default value is recommended." - :group 'fill-column-indicator - :tag "Locally set truncate-lines to t during fci-mode" - :type 'boolean) - -(defcustom fci-handle-line-move-visual (version<= "23" emacs-version) - "Whether fci-mode should set line-move-visual to nil while enabled. -If non-nil, fci-mode will set line-move-visual to nil in buffers -in which it is enabled, and restore t to its previous value when -disabled. - -Leaving this option set to the default value is recommended." - :group 'fill-column-indicator - :tag "Locally set line-move-visual to nil during fci-mode" - :type 'boolean) - -(defcustom fci-eol-char ?\uE000 - "Character used for internal purposes by fci-mode. -If you need to use this character, set this variable's value to a -character you do not care about (a good choice is a character -from the Private Use Area of the Unicode BMP, i.e., the range -U+E000-U+F8FF, inclusive)." - :group 'fill-column-indicator - :type 'character) - -(defcustom fci-blank-char ?\uE001 - "Character used for internal purposes by fci-mode. -If you need to use this character, set this variable's value to a -character you do not care about (a good choice is a character -from the Private Use Area of the Unicode BMP, i.e., the the range -U+E000-U+F8FF, inclusive)." - :group 'fill-column-indicator - :type 'character) - -;;; --------------------------------------------------------------------- -;;; Internal Variables and Constants -;;; --------------------------------------------------------------------- - -;; Record prior state of buffer. -(defvar fci-saved-line-move-visual) -(defvar fci-line-move-visual-was-buffer-local) -(defvar fci-saved-truncate-lines) -(defvar fci-saved-eol) -(defvar fci-made-display-table) - -;; Record state of fci initialization in this buffer. -(defvar fci-display-table-processed) -(defvar fci-local-vars-set) - -;; Record current state of some quantities, so we can detect changes to them. -(defvar fci-column) -(defvar fci-newline) -(defvar fci-tab-width) -(defvar fci-char-width) -(defvar fci-char-height) - -;; Data used in setting the fill-column rule that only need to be -;; occasionally updated in a given buffer. -(defvar fci-limit) -(defvar fci-pre-limit-string) -(defvar fci-at-limit-string) -(defvar fci-post-limit-string) - -;; The preceding internal variables need to be buffer local and reset when -;; the mode is disabled. -(defconst fci-internal-vars '(fci-saved-line-move-visual - fci-line-move-visual-was-buffer-local - fci-saved-truncate-lines - fci-saved-eol - fci-made-display-table - fci-display-table-processed - fci-local-vars-set - fci-column - fci-newline - fci-tab-width - fci-char-width - fci-char-height - fci-limit - fci-pre-limit-string - fci-at-limit-string - fci-post-limit-string)) - -(dolist (var fci-internal-vars) - (make-variable-buffer-local var)) - -;; Hooks we use. -(defconst fci-hook-assignments - '((after-change-functions fci-redraw-region t) - (before-change-functions fci-extend-rule-for-deletion t) - (window-scroll-functions fci-update-window-for-scroll t) - (window-configuration-change-hook fci-redraw-frame) - (post-command-hook fci-post-command-check t) - (change-major-mode-hook turn-off-fci-mode t) - (longlines-mode-hook fci-update-all-windows t))) - -;;; --------------------------------------------------------------------- -;;; Miscellany -;;; --------------------------------------------------------------------- - -(defun fci-get-buffer-windows (&optional all-frames) - "Return a list of windows displaying the current buffer." - (get-buffer-window-list (current-buffer) 'no-minibuf all-frames)) - -(defun fci-posint-p (x) - "Return true if X is an integer greater than zero." - (and (wholenump x) - (/= 0 x))) - -(if (fboundp 'characterp) - (defalias 'fci-character-p 'characterp) - ;; For v22. - (defun fci-character-p (c) - "Return true if C is a character." - (and (fci-posint-p c) - ;; MAX_CHAR in v22 is (0x1f << 14). We don't worry about - ;; generic chars. - (< c 507904)))) - -;;; --------------------------------------------------------------------- -;;; Mode Definition -;;; --------------------------------------------------------------------- - -;;;###autoload -(define-minor-mode fci-mode - "Toggle fci-mode on and off. -Fci-mode indicates the location of the fill column by drawing a -thin line (a `rule') at the fill column. - -With prefix ARG, turn fci-mode on if and only if ARG is positive. - -The following options control the appearance of the fill-column -rule: `fci-rule-column', `fci-rule-width', `fci-rule-color', -`fci-rule-use-dashes', `fci-dash-pattern', `fci-rule-character', -and `fci-rule-character-color'. For further options, see the -Customization menu or the package file. (See the latter for tips -on troubleshooting.)" - - nil nil nil - - (if fci-mode - ;; Enabling. - (condition-case error - (progn - (fci-check-user-options) - (fci-process-display-table) - (fci-set-local-vars) - (fci-get-frame-dimens) - (dolist (hook fci-hook-assignments) - (add-hook (car hook) (nth 1 hook) nil (nth 2 hook))) - (setq fci-column (or fci-rule-column fill-column) - fci-tab-width tab-width - fci-limit (if fci-newline - (1+ (- fci-column (length fci-saved-eol))) - fci-column)) - (fci-make-overlay-strings) - (fci-update-all-windows t)) - (error - (fci-mode 0) - (signal (car error) (cdr error)))) - - ;; Disabling. - (fci-restore-display-table) - (fci-restore-local-vars) - (dolist (hook fci-hook-assignments) - (remove-hook (car hook) (nth 1 hook) (nth 2 hook))) - (fci-delete-overlays-buffer) - (dolist (var fci-internal-vars) - (set var nil)))) - -;;;###autoload -(defun turn-on-fci-mode () - "Turn on fci-mode unconditionally." - (interactive) - (fci-mode 1)) - -(defun turn-off-fci-mode () - "Turn off fci-mode unconditionally." - (interactive) - (fci-mode 0)) - -;;; --------------------------------------------------------------------- -;;; Display Property Specs -;;; --------------------------------------------------------------------- - -(defun fci-overlay-fills-background-p (olay) - "Return true if OLAY specifies a background color." - (and (overlay-get olay 'face) - (not (eq (face-attribute (overlay-get olay 'face) :background nil t) - 'unspecified)))) - -(defun fci-competing-overlay-p (posn) - "Return true if there is an overlay at POSN that fills the background." - (memq t (mapcar #'fci-overlay-fills-background-p (overlays-at posn)))) - -;; The display spec used in overlay before strings to pad out the rule to the -;; fill-column. -(defconst fci-padding-display - '((when (not (fci-competing-overlay-p buffer-position)) - . (space :align-to fci-column)) - (space :width 0))) - -;; Generate the display spec for the rule. Basic idea is to use a "cascading -;; display property" to display the textual rule if the display doesn't -;; support images and the graphical rule if it does, but in either case only -;; display a rule if no other overlay wants to fill the background at the -;; relevant buffer position. -(defun fci-rule-display (blank rule-img rule-str for-pre-string) - "Generate a display specification for a fill-column rule overlay string." - (let* ((cursor-prop (if (and (not for-pre-string) (not fci-newline)) t)) - (propertized-rule-str (propertize rule-str 'cursor cursor-prop)) - (display-prop (if rule-img - `((when (not (or (display-images-p) - (fci-competing-overlay-p buffer-position))) - . ,propertized-rule-str) - (when (not (fci-competing-overlay-p buffer-position)) - . ,rule-img) - (space :width 0)) - `((when (not (fci-competing-overlay-p buffer-position)) - . ,propertized-rule-str) - (space :width 0))))) - (propertize blank 'cursor cursor-prop 'display display-prop))) - -;;; --------------------------------------------------------------------- -;;; Enabling -;;; --------------------------------------------------------------------- - -(defun fci-check-user-options () - "Check that all user options for fci-mode have valid values." - (unless (memq fci-rule-image-format '(xpm pbm)) - (error "Unrecognized value of `fci-rule-image-format'")) - ;; If the third element of a binding form is t, then nil is an acceptable - ;; value for the variable; otherwise, the variable value must satisfy the - ;; given predicate. - (let ((checks '((fci-rule-color color-defined-p) - (fci-rule-column fci-posint-p t) - (fci-rule-width fci-posint-p t) - (fci-rule-character-color color-defined-p t) - (fci-rule-character fci-character-p) - (fci-blank-char fci-character-p) - (fci-dash-pattern floatp) - (fci-eol-char fci-character-p)))) - (dolist (check checks) - (let ((value (symbol-value (nth 0 check))) - (pred (nth 1 check)) - (nil-is-ok (nth 2 check))) - (unless (or (and nil-is-ok (null value)) - (funcall pred value)) - (signal 'wrong-type-argument (list pred value))))))) - -(defun fci-process-display-table () - "Set up a buffer-local display table for fci-mode." - (unless fci-display-table-processed - (unless buffer-display-table - (setq buffer-display-table (make-display-table) - fci-made-display-table t)) - (aset buffer-display-table fci-blank-char [32]) - (setq fci-saved-eol (aref buffer-display-table 10)) - ;; Assumption: the display-table entry for character 10 is either nil or - ;; a vector whose last element is the newline glyph. - (let ((glyphs (butlast (append fci-saved-eol nil))) - eol) - (if glyphs - (setq fci-newline [10] - eol (vconcat glyphs)) - (setq fci-newline nil - eol [32])) - (aset buffer-display-table 10 fci-newline) - (aset buffer-display-table fci-eol-char eol)) - (setq fci-display-table-processed t))) - -(defun fci-set-local-vars () - "Set miscellaneous local variables when fci-mode is enabled." - (unless fci-local-vars-set - (when (and fci-handle-line-move-visual - (boundp 'line-move-visual)) - (if (local-variable-p 'line-move-visual) - (setq fci-line-move-visual-was-buffer-local t - fci-saved-line-move-visual line-move-visual - line-move-visual nil) - (set (make-local-variable 'line-move-visual) nil))) - (when fci-handle-truncate-lines - (setq fci-saved-truncate-lines truncate-lines - truncate-lines t)) - (setq fci-local-vars-set t))) - -(defun fci-make-rule-string () - "Return a string for drawing the fill-column rule." - (let ((color (or fci-rule-character-color - fci-rule-color))) - ;; Make sure we don't inherit weight or slant from font-lock. - (propertize (char-to-string fci-rule-character) - 'face `(:foreground ,color :weight normal :slant normal)))) - -(defun fci-make-img-descriptor () - "Make an image descriptor for the fill-column rule." - (unless (or (= 0 fci-char-width) - fci-always-use-textual-rule) - ;; No point passing width, height, color etc. directly to the image - ;; functions: those variables have either global or buffer-local - ;; scope, so the image-generating functions can access them directly. - (if (eq fci-rule-image-format 'xpm) - (fci-make-xpm-img) - (fci-make-pbm-img)))) - -(defun fci-get-frame-dimens () - "Determine the frame character height and width. - -If the selected frame cannot display images, use the character -height and width of the first graphic frame in the frame list -displaying the current buffer. (This fallback behavior is just a -rough heuristic.)" - (let ((frame (catch 'found-graphic - (if (display-images-p) - (selected-frame) - (dolist (win (fci-get-buffer-windows t)) - (when (display-images-p (window-frame win)) - (throw 'found-graphic (window-frame win)))))))) - (setq fci-char-width (frame-char-width frame) - fci-char-height (frame-char-height frame)))) - -(defmacro fci-with-rule-parameters (&rest body) - "Define various quantites used in generating rule image descriptors." - (declare (indent defun)) - `(let* ((height-str (number-to-string fci-char-height)) - (width-str (number-to-string fci-char-width)) - (rule-width (min fci-rule-width fci-char-width)) - (hmargin (/ (- fci-char-width rule-width) 2.0)) - (left-margin (floor hmargin)) - (right-margin (ceiling hmargin)) - (segment-ratio (if fci-rule-use-dashes fci-dash-pattern 1)) - (segment-ratio-coerced (min 1 (max 0 segment-ratio))) - (segment-length (round (* segment-ratio-coerced fci-char-height))) - (vmargin (/ (- fci-char-height segment-length) 2.0)) - (top-margin (floor vmargin)) - (bottom-margin (ceiling vmargin))) - ,@body)) - -(defun fci-mapconcat (sep &rest lists) - "Concatenate the strings in LISTS, using SEP as separator." - (mapconcat #'identity (apply 'nconc lists) sep)) - -(defun fci-make-pbm-img () - "Return an image descriptor for the fill-column rule in PBM format." - (fci-with-rule-parameters - (let* ((magic-number "P1\n") - (dimens (concat width-str " " height-str "\n")) - (on-pixels (fci-mapconcat " " - (make-list left-margin "0") - (make-list rule-width "1") - (make-list right-margin "0"))) - (off-pixels (fci-mapconcat " " (make-list fci-char-width "0"))) - (raster (fci-mapconcat "\n" - (make-list top-margin off-pixels) - (make-list segment-length on-pixels) - (make-list bottom-margin off-pixels))) - (data (concat magic-number dimens raster))) - `(image :type pbm - :data ,data - :mask heuristic - :foreground ,fci-rule-color - :ascent center)))) - -(defun fci-make-xpm-img () - "Return an image descriptor for the fill-column rule in XPM format." - (fci-with-rule-parameters - (let* ((identifier "/* XPM */\nstatic char *rule[] = {") - (dimens (concat "\"" width-str " " height-str " 2 1\",")) - (color-spec (concat "\"1 c " fci-rule-color "\",\"0 c None\",")) - (on-pixels (concat "\"" - (make-string left-margin ?0) - (make-string rule-width ?1) - (make-string right-margin ?0) - "\",")) - (off-pixels (concat "\"" (make-string fci-char-width ?0) "\",")) - (raster (fci-mapconcat "" - (make-list top-margin off-pixels) - (make-list segment-length on-pixels) - (make-list bottom-margin off-pixels))) - (end "};") - (data (concat identifier dimens color-spec raster end))) - `(image :type xpm - :data ,data - :mask heuristic - :ascent center)))) - -(defun fci-make-overlay-strings () - "Generate the overlay strings used to display the fill-column rule." - (let* ((str (fci-make-rule-string)) - (img (fci-make-img-descriptor)) - (blank-str (char-to-string fci-blank-char)) - (eol-str (char-to-string fci-eol-char)) - (end-cap (propertize blank-str 'display '(space :width 0))) - (pre-or-post-eol (propertize eol-str - 'cursor t - 'display (propertize eol-str 'cursor t))) - (pre-padding (propertize blank-str 'display fci-padding-display)) - (pre-rule (fci-rule-display blank-str img str t)) - (at-rule (fci-rule-display blank-str img str fci-newline)) - (at-eol (if fci-newline pre-or-post-eol ""))) - (setq fci-pre-limit-string (concat pre-or-post-eol pre-padding pre-rule) - fci-at-limit-string (concat at-eol at-rule) - fci-post-limit-string (concat pre-or-post-eol end-cap)))) - -;;; --------------------------------------------------------------------- -;;; Disabling -;;; --------------------------------------------------------------------- - -(defun fci-restore-local-vars () - "Restore miscellaneous local variables when fci-mode is disabled." - (when fci-local-vars-set - (when (and fci-handle-line-move-visual - (boundp 'line-move-visual)) - (if fci-line-move-visual-was-buffer-local - (setq line-move-visual fci-saved-line-move-visual) - (kill-local-variable 'line-move-visual))) - (when fci-handle-truncate-lines - (setq truncate-lines fci-saved-truncate-lines)))) - -(defun fci-restore-display-table () - "Restore the buffer display table when fci-mode is disabled." - (when (and buffer-display-table - fci-display-table-processed) - (aset buffer-display-table 10 fci-saved-eol) - ;; Don't set buffer-display-table to nil even if we created the display - ;; table; only do so if nothing else has changed it. - (when (and fci-made-display-table - (equal buffer-display-table (make-display-table))) - (setq buffer-display-table nil)))) - -;;; --------------------------------------------------------------------- -;;; Drawing and Erasing -;;; --------------------------------------------------------------------- - -(defun fci-get-overlays-region (start end) - "Return all overlays between START and END displaying the fill-column rule." - (delq nil (mapcar #'(lambda (o) (if (overlay-get o 'fci) o)) - (overlays-in start end)))) - -(defun fci-delete-overlays-region (start end) - "Delete overlays displaying the fill-column rule between START and END." - (mapc #'(lambda (o) (if (overlay-get o 'fci) (delete-overlay o))) - (overlays-in start end))) - -(defun fci-delete-overlays-buffer () - "Delete all overlays displaying the fill-column rule in the current buffer." - (save-restriction - (widen) - (fci-delete-overlays-region (point-min) (point-max)))) - -(defsubst fci-posn-visible-p (posn ranges) - "Return true if POSN falls within an interval in RANGES." - (memq t (mapcar #'(lambda (range) (and (<= (car range) posn) - (< posn (cdr range)))) - ranges))) - -(defsubst fci-get-visible-ranges () - "Return the window start and end for each window on the current buffer." - (mapcar #'(lambda (w) (cons (window-start w) (window-end w 'updated))) - (fci-get-buffer-windows t))) - -(defun fci-delete-unneeded () - "Erase the fill-column rule at buffer positions not visible in any window." - (let ((olays (fci-get-overlays-region (point-min) (point-max))) - (ranges (fci-get-visible-ranges))) - (dolist (o olays) - (unless (fci-posn-visible-p (overlay-start o) ranges) - (delete-overlay o))))) - -;; It would be slightly faster to run this backwards from END to START, but -;; only if we maintained the overlay center at an early position in the -;; buffer. Since other packages that use overlays typically place them while -;; traversing the buffer in a forward direction, that would be a bad idea. -(defun fci-put-overlays-region (start end) - "Place overlays displaying the fill-column rule between START and END." - (goto-char start) - (let (o cc) - (while (search-forward "\n" end t) - (goto-char (match-beginning 0)) - (setq cc (current-column) - o (make-overlay (match-beginning 0) (match-beginning 0))) - (overlay-put o 'fci t) - (cond - ((< cc fci-limit) - (overlay-put o 'after-string fci-pre-limit-string)) - ((> cc fci-limit) - (overlay-put o 'after-string fci-post-limit-string)) - (t - (overlay-put o 'after-string fci-at-limit-string))) - (goto-char (match-end 0))))) - -(defun fci-redraw-region (start end _ignored) - "Erase and redraw the fill-column rule between START and END." - (save-match-data - (save-excursion - (let ((inhibit-point-motion-hooks t)) - (goto-char end) - (setq end (line-beginning-position 2)) - (fci-delete-overlays-region start end) - (fci-put-overlays-region start end))))) - -(defun fci-redraw-window (win &optional start) - "Redraw the fill-column rule in WIN starting from START." - (fci-redraw-region (or start (window-start win)) (window-end win t) 'ignored)) - -;; This doesn't determine the strictly minimum amount by which the rule needs -;; to be extended, but the amount used is always sufficient, and determining -;; the genuine minimum is more expensive than doing the extra drawing. -(defun fci-extend-rule-for-deletion (start end) - "Extend the fill-column rule after a deletion that spans newlines." - (unless (= start end) - (let ((delenda (fci-get-overlays-region start end))) - (when delenda - (let ((lossage (1+ (length delenda))) - (max-end 0) - win-end) - (mapc #'delete-overlay delenda) - (dolist (win (fci-get-buffer-windows t)) - ;; Do not ask for an updated value of window-end. - (setq win-end (window-end win)) - (when (and (< 0 (- (min win-end end) - (max (window-start win) start))) - (< max-end win-end)) - (setq max-end win-end))) - (unless (= max-end (point-max)) - (fci-redraw-region max-end - (save-excursion - (goto-char max-end) - (line-beginning-position lossage)) - nil))))))) - -(defun fci-update-window-for-scroll (win start) - "Redraw the fill-column rule in WIN after it has been been scrolled." - (fci-delete-unneeded) - (fci-redraw-window win start)) - -(defun fci-update-all-windows (&optional all-frames) - "Redraw the fill-column rule in all windows showing the current buffer." - (dolist (win (fci-get-buffer-windows all-frames)) - (fci-redraw-window win))) - -(defun fci-redraw-frame () - "Redraw the fill-column rule in all windows on the selected frame." - (let* ((wins (window-list (selected-frame) 'no-minibuf)) - (bufs (delete-dups (mapcar #'window-buffer wins)))) - (dolist (buf bufs) - (with-current-buffer buf - (when fci-mode - (fci-delete-unneeded) - (fci-update-all-windows)))))) - -;;; --------------------------------------------------------------------- -;;; Workarounds -;;; --------------------------------------------------------------------- - -;; This in placed in post-command-hook and does four things: -;; 1. If the display table has been deleted or something has changed the -;; display table for newline chars, we regenerate overlay strings after -;; reprocessing the display table. -;; 2. If the default char width or height has changed, we regenerate the rule -;; image. (This handles both font changes and also cases where we -;; activate the mode while displaying on a char terminal then subsequently -;; display the buffer on a window frame.) -;; 3. If the value of `tab-width' or `fill-column' has changed, we reset the -;; rule. (We could set things up so that the rule adjusted automatically -;; to such changes, but it wouldn't work on v22 or v23.) -;; 4. Cursor properties are ignored when they're out of sight because of -;; horizontal scrolling. We detect such situations and force a return -;; from hscrolling to bring our requested cursor position back into view. -;; These are all fast tests, so despite the large remit this function -;; shouldn't noticeably affect editing speed. -(defun fci-post-command-check () - "This function is a gross hack." - (cond - ((not (and buffer-display-table - (equal (aref buffer-display-table 10) fci-newline))) - (setq fci-display-table-processed nil) - (fci-mode 1)) - ((and (< 1 (frame-char-width)) - (not fci-always-use-textual-rule) - (not (and (= (frame-char-width) fci-char-width) - (= (frame-char-height) fci-char-height)))) - (fci-mode 1)) - ((not (and (= (or fci-rule-column fill-column) fci-column) - (= tab-width fci-tab-width))) - (fci-mode 1)) - ((and (< 0 (window-hscroll)) - auto-hscroll-mode - (<= (current-column) (window-hscroll))) - ;; Fix me: Rather than setting hscroll to 0, this should reproduce the - ;; relevant part of the auto-hscrolling algorithm. Most people won't - ;; notice the difference in behavior, though. - (set-window-hscroll (selected-window) 0)))) - -(provide 'fill-column-indicator) - -;;; fill-column-indicator.el ends here diff --git a/vendor/web-mode.el b/vendor/web-mode.el deleted file mode 100644 index ffda067..0000000 --- a/vendor/web-mode.el +++ /dev/null @@ -1,9404 +0,0 @@ -;;; web-mode.el --- major mode for editing html templates -;;; -*- coding: utf-8 -*- - -;; Copyright 2011-2014 François-Xavier Bois - -;; Version: 8.0.3 -;; Author: François-Xavier Bois -;; Maintainer: François-Xavier Bois -;; Created: July 2011 -;; Keywords: html template php javascript js css web -;; django jsp asp erb twig jinja blade dust closure -;; freemarker mustache velocity cheetah smarty -;; URL: http://web-mode.org -;; Repository: http://github.com/fxbois/web-mode - -;; ========================================================================= -;; This work is sponsored by Kernix : Digital Agency (Web & Mobile) in Paris -;; ========================================================================= - -;; 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; 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., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;; Code goes here - -;;new lexer/highlighter : web-mode.el is now compatible with minor modes relying on font-locking -;;compatibility with *.js.erb (javascript content type), *.css.erb (css content type) -;;engine compatibility : web2py (python), mako (python), mason (perl) -;;jshint compatibility : web-mode-jshint -;;alertnative delimiters can be defined for smarty (see web-mode-engines-alternate-delimiters) - -;;todo : -;; phphint -;; navigation blocs mako -;; tester django-extra comments -;; test whitespaces -;; colorer : and )." - :group 'web-mode-faces) - -(defface web-mode-html-tag-bracket-face -;; '((t :inherit web-mode-html-tag-face)) - '((((class color) (min-colors 88) (background dark)) :foreground "Snow3") - (((class color) (min-colors 88) (background light)) :foreground "grey14") - (((class color) (min-colors 16) (background dark)) :foreground "Snow3") - (((class color) (min-colors 16) (background light)) :foreground "grey14") - (((class color) (min-colors 8)) :foreground "Snow3") - (((type tty) (class mono)) :inverse-video t) - (t :foreground "Snow3")) - "Face for HTML tags angle brackets (< and >)." - :group 'web-mode-faces) - -(defface web-mode-html-attr-name-face - '((((class color) (min-colors 88) (background dark)) :foreground "Snow3") - (((class color) (min-colors 88) (background light)) :foreground "grey13") - (((class color) (min-colors 16) (background dark)) :foreground "Snow3") - (((class color) (min-colors 16) (background light)) :foreground "grey13") - (((class color) (min-colors 8)) :foreground "Snow3") - (((type tty) (class mono)) :inverse-video t) - (t :foreground "Snow4")) - "Face for HTML attribute names." - :group 'web-mode-faces) - -(defface web-mode-html-attr-custom-face - '((t :inherit web-mode-html-attr-name-face)) - "Face for custom attribute names (e.g. data-*)." - :group 'web-mode-faces) - -(defface web-mode-html-attr-equal-face - '((t :inherit web-mode-html-attr-name-face)) - "Face for the = character between name and value." - :group 'web-mode-faces) - -(defface web-mode-html-attr-value-face - '((t :inherit font-lock-string-face)) - "Face for HTML attribute values." - :group 'web-mode-faces) - -(defface web-mode-block-attr-name-face - '((t :foreground "#8fbc8f")) ;; inherit web-mode-html-attr-name-face)) - "Face for block attribute names." - :group 'web-mode-faces) - -(defface web-mode-block-attr-value-face - '((t :inherit web-mode-html-attr-value-face)) - "Face for block attribute values." - :group 'web-mode-faces) - -(defface web-mode-css-selector-face - '((t :inherit font-lock-keyword-face)) - "Face for CSS rules." - :group 'web-mode-faces) - -(defface web-mode-css-pseudo-class-face - '((t :inherit font-lock-builtin-face)) - "Face for CSS pseudo-classes." - :group 'web-mode-faces) - -(defface web-mode-css-at-rule-face - '((t :inherit font-lock-constant-face)) - "Face for CSS at-rules." - :group 'web-mode-faces) - -(defface web-mode-css-property-name-face - '((t :inherit font-lock-variable-name-face)) - "Face for CSS props." - :group 'web-mode-faces) - -(defface web-mode-css-color-face - '((t :inherit font-lock-builtin-face)) - "Face for CSS colors (#xxx)." - :group 'web-mode-faces) - -(defface web-mode-css-priority-face - '((t :inherit font-lock-builtin-face)) - "Face for CSS priority (!important)." - :group 'web-mode-faces) - -(defface web-mode-css-function-face - '((t :inherit font-lock-builtin-face)) - "Face for CSS functions." - :group 'web-mode-faces) - -(defface web-mode-variable-name-face - '((t :inherit font-lock-variable-name-face)) - "Face for variable names." - :group 'web-mode-faces) - -(defface web-mode-function-name-face - '((t :inherit font-lock-function-name-face)) - "Face for function names." - :group 'web-mode-faces) - -(defface web-mode-function-call-face - '((t :inherit font-lock-function-name-face)) - "Face for function calls." - :group 'web-mode-faces) - -(defface web-mode-string-face - '((t :inherit font-lock-string-face)) - "Face for strings." - :group 'web-mode-faces) - -(defface web-mode-block-string-face - '((t :inherit web-mode-string-face)) - "Face for block strings." - :group 'web-mode-faces) - -(defface web-mode-part-string-face - '((t :inherit web-mode-string-face)) - "Face for part strings." - :group 'web-mode-faces) - -(defface web-mode-javascript-string-face - '((t :inherit web-mode-string-face)) - "Face for javascript strings." - :group 'web-mode-faces) - -(defface web-mode-css-string-face - '((t :inherit web-mode-string-face)) - "Face for css strings." - :group 'web-mode-faces) - -(defface web-mode-json-key-face - '((t :foreground "plum")) - "Face for json key strings." - :group 'web-mode-faces) - -(defface web-mode-json-context-face - '((t :foreground "orchid3")) - "Face for json context strings." - :group 'web-mode-faces) - -(defface web-mode-json-string-face - '((t :inherit web-mode-string-face)) - "Face for json strings." - :group 'web-mode-faces) - -(defface web-mode-comment-face - '((t :inherit font-lock-comment-face)) - "Face for comments." - :group 'web-mode-faces) - -(defface web-mode-block-comment-face - '((t :inherit web-mode-comment-face)) - "Face for server comments." - :group 'web-mode-faces) - -(defface web-mode-part-comment-face - '((t :inherit web-mode-comment-face)) - "Face for part comments." - :group 'web-mode-faces) - -(defface web-mode-json-comment-face - '((t :inherit web-mode-comment-face)) - "Face for json comments." - :group 'web-mode-faces) - -(defface web-mode-javascript-comment-face - '((t :inherit web-mode-comment-face)) - "Face for javascript comments." - :group 'web-mode-faces) - -(defface web-mode-css-comment-face - '((t :inherit web-mode-comment-face)) - "Face for css comments." - :group 'web-mode-faces) - -(defface web-mode-constant-face - '((t :inherit font-lock-constant-face)) - "Face for language constants." - :group 'web-mode-faces) - -(defface web-mode-type-face - '((t :inherit font-lock-type-face)) - "Face for language types." - :group 'web-mode-faces) - -(defface web-mode-keyword-face - '((t :inherit font-lock-keyword-face)) - "Face for language keywords." - :group 'web-mode-faces) - -(defface web-mode-param-name-face - '((t :foreground "Snow3")) - "Face for server attribute names." - :group 'web-mode-faces) - -(defface web-mode-whitespace-face - '((t :background "DarkOrchid4")) - "Face for whitespaces." - :group 'web-mode-faces) - -(defface web-mode-block-face - '((((class color) (min-colors 88) (background dark)) - :background "black") ;""grey18") - (((class color) (min-colors 88) (background light)) - :background "LightYellow1") - (((class color) (min-colors 16) (background dark)) - :background "grey18") - (((class color) (min-colors 16) (background light)) - :background "LightYellow1") - (((class color) (min-colors 8)) - :background "Black") - (((type tty) (class mono)) - :inverse-video t) - (t :background "grey")) - "Face for blocks (useful for setting a background for example). -Must be used in conjunction with web-mode-enable-block-face." - :group 'web-mode-faces) - -(defface web-mode-part-face - '((t :inherit web-mode-block-face)) - "Face for parts." - :group 'web-mode-faces) - -(defface web-mode-folded-face - '((t :underline t)) - "Overlay face for folded." - :group 'web-mode-faces) - -(defface web-mode-current-element-highlight-face - '((t :background "#000000")) - "Overlay face for element highlight." - :group 'web-mode-faces) - -(defface web-mode-comment-keyword-face - '((t :weight bold :box t)) - "Comment keywords." - :group 'web-mode-faces) - -(defvar web-mode-void-elements - '("area" "base" "br" "col" "command" "embed" "hr" "img" "input" "keygen" - "link" "meta" "param" "source" "track" "wbr") - "Void (self-closing) tags.") - -(defvar web-mode-scan-properties - (list 'tag-beg nil 'tag-end nil 'tag-name nil 'tag-type nil 'tag-attr nil 'tag-attr-end nil - 'part-side nil 'part-token nil - 'block-side nil 'block-token nil 'block-beg nil 'block-end nil) - "Text properties used for tokens.") - -(defvar web-mode-scan-properties2 - (list 'tag-beg nil 'tag-end nil 'tag-name nil 'tag-type nil 'tag-attr nil 'tag-attr-end nil - 'part-side nil 'part-token nil) - "Text properties used for tokens.") - -(defvar web-mode-large-embed-threshold 512 - "Threshold for large part/block.") - -(defvar web-mode-has-any-large-part nil - "Does the current buffer has large parts ?") - -(defvar web-mode-has-any-large-block nil - "Does the current buffer has large blocks ?") - -(defvar web-mode-is-scratch nil - "Is scratch buffer ?") - -(defvar web-mode-time nil - "For benchmarking") - -(defvar web-mode-start-tag-overlay nil) - -(defvar web-mode-end-tag-overlay nil) - -(defvar web-mode-expand-initial-pos nil - "First mark pos.") - -(defvar web-mode-expand-previous-state "" - "Last mark state.") - -(defvar web-mode-tag-regexp "<\\(/?[[:alpha:]][[:alnum:]-]*\\)" - "Regular expression for HTML/XML tag.") - -(defvar web-mode-start-tag-regexp "<\\([[:alpha:]][[:alnum:]-]*\\)" - "Regular expression for HTML/XML start tag.") - -(defvar web-mode-whitespaces-regexp - "^[ \t]\\{2,\\}$\\| \t\\|\t \\|[ \t]+$\\|^[ \n\t]+\\'\\|^[ \t]?[\n]\\{2,\\}" - "Regular expression for whitespaces.") - -(defvar web-mode-engine nil - "Template engine") - -(defvar web-mode-engine-font-lock-keywords nil - "Font-lock keywords associated with the engine.") - -(defvar web-mode-engines - '(("angular" . ("angular.js" "angularjs")) - ("asp" . ()) - ("aspx" . ()) - ("blade" . ("laravel")) - ("closure" . ("soy")) - ("ctemplate" . ("mustache" "handlebars" "hapax" "ngtemplate" "ember" - "kite" "meteor")) - ("django" . ("dtl" "twig" "swig" "jinja" "jinja2" "erlydtl" "liquid")) - ("dust" . ("dustjs")) - ("erb" . ("eruby" "erubis")) - ("go" . ("gtl")) - ("jsp" . ()) - ("mason" . ("poet")) - ("python" . ()) - ("razor" . ("play" "play2")) - ("underscore" . ("underscorejs")) - ("velocity" . ("vtl" "cheetah")) - ("web2py" . ())) - "Engine name aliases") - -(defvar web-mode-content-types - '(("css" . "\\.css\\'\\|\\.css\\.erb\\'") - ("javascript" . "\\.js\\'\\|\\.js\\.erb\\'") - ("json" . "\\.\\(json\\|jsonld\\)\\'") - ("html" . ".")) - "content types") - -(defvar web-mode-engine-file-regexps - '(("asp" . "\\.asp\\'") - ("aspx" . "\\.as[cp]x\\'") - ("angular" . "angular") - ("blade" . "\\.blade") - ("closure" . "\\.soy\\'") - ("ctemplate" . "\\.\\(chtml\\)\\'") - ("django" . "\\.\\(djhtml\\|tmpl\\|dtl\\|liquid\\)\\'") - ("django" . "twig") - ("dust" . "\\.dust\\'") - ("erb" . "\\.\\(erb\\|rhtml\\)\\'") - ("freemarker" . "\\.ftl\\'") - ("go" . "\\.go\\(html\\|tmpl\\)\\'") - ("handlebars" . "\\(handlebars\\|.\\hbs\\'\\)") - ("jsp" . "\\.jsp\\'") - ("mako" . "\\.mako\\'") - ("mason" . "\\.mas\\'") - ("mustache" . "\\.mustache\\'") - ("php" . "\\.\\(php\\|ctp\\|psp\\|inc\\)\\'") - ("python" . "\\.pml\\'") - ("razor" . "play\\|scala\\|\\.razor\\'\\|\\.cshtml\\'\\|\\.vbhtml\\'") - ("smarty" . "\\.tpl\\'") - ("template-toolkit" . "\\.tt.?\\'") - ("underscore" . "\\.underscore\\'") - ("velocity" . "\\.\\(vsl\\|vtl\\|vm\\)\\'") - ("web2py" . "web2py")) - "Engine file extensions.") - -(defvar web-mode-smart-quotes - '("«" . "»") - "Preferred smart quotes") - -(defvar web-mode-xml-chars - '((?\& . "&") - (?\< . "<") - (?\> . ">")) - "XML chars") - -(defvar web-mode-html-entities - '(("egrave" . 232) - ("eacute" . 233) - ("ecirc" . 234) - ("euml" . 235) - ("agrave" . 224) - ("aacute" . 225) - ("aelig" . 230) - ("ccedil" . 231) - ("times" . 215) - ("quot" . 34) - ("amp" . 38) - ("lt" . 60) - ("gt" . 62) - ("laquo" . 171) - ("raquo" . 187) - ("lsquo" . 8249) - ("rsquo" . 8250) - ("ldquo" . 8220) - ("rdquo" . 8221) - ("lsaquo" . 8249) - ("rsaquo" . 8250) - ("apos" . 39) - ("frac14" . 188) - ("frac12" . 189) - ("frac34" . 190) - ("para" . 182) - ("middot" . 183) - ("ndash" . 8211) - ("mdash" . 8212) - ("bull" . 8226) - ("hellip" . 8230) - ("trade" . 8482) - ("larr" . 8592) - ("uarr" . 8593) - ("rarr" . 8594) - ("darr" . 8595) - ("harr" . 8596) - ("crarr" . 8629) - ("and" . 8743) - ("or" . 8744) - ("sdot" . 8901) - ) - "HTML entities") - -;;(message "%S" web-mode-engines-alternate-delimiters) - -(defvar web-mode-engines-alternate-delimiters - (if (boundp 'web-mode-engines-alternate-delimiters) web-mode-engines-alternate-delimiters '()) - "Engine delimiters. Useful for engines that provide alternate delimiters.") - -(defun web-mode-highlight-whitespaces (beg end) - "Scan whitespaces." - (save-excursion - (goto-char beg) - (while (re-search-forward web-mode-whitespaces-regexp end t) - (add-text-properties (match-beginning 0) (match-end 0) - '(face web-mode-whitespace-face)) - ) ;while - )) - -(defun web-mode-engine-delimiter-open (engine default) - "alternative open delimiter" -;; (setq engine (if (eq engine t) )) - (let (delim) - (setq delim (car (cdr (assoc engine web-mode-engines-alternate-delimiters)))) - (or delim default) - )) - -(defun web-mode-engine-delimiter-close (engine default) - "alternative close delimiter" - ;; (setq engine (if (eq engine t) )) - (let (delim) - (setq delim (cdr (cdr (assoc engine web-mode-engines-alternate-delimiters)))) - (or delim default) - )) - -(defvar web-mode-jshint-errors 0 - "JSHint errors") - -(defvar web-mode-content-type "" - "Buffer file type.") - -(defvar web-mode-comments-invisible nil - "Comments visbility.") - -(defvar web-mode-is-narrowed nil - "Buffer has been narrowed.") - -(defvar web-mode-hook nil - "List of functions to be executed with web-mode.") - -(defvar web-mode-buffer-highlighted nil - "Is buffer highlighted.") - -;; http://webdesign.about.com/od/localization/l/blhtmlcodes-ascii.htm -(defvar web-mode-display-table - (let ((table (make-display-table))) - (aset table 9 (vector ?\xBB ?\t)) ;tab - (aset table 10 (vector ?\xB6 ?\n)) ;line feed - (aset table 32 (vector ?\xB7)) - table) - "Display table.") - -(defvar web-mode-hl-line-mode-flag nil - "Is hl-line-mode enabled ?") - -(defvar web-mode-blade-active-blocks - '("else" "elseif" "foreach" "forelse" "for" "if" "section" "stop" "unless" "while") - "Blade controls.") - -(defvar web-mode-closure-active-blocks - '("call" "case" "default" "deltemplate" "else" "elseif" "for" "foreach" - "if" "ifempty" "let" "literal" "msg" "param" "switch" "template") - "Closure controls.") - -(defvar web-mode-django-active-blocks - '("assets" "autoescape" "block" "blocktrans" "cache" "call" "comment" - "elif" "else" "elseif" "elsif" "embed" "empty" "filter" "foreach" "for" - "ifchanged" "ifequal" "ifnotequal" "if" - "macro" "draw" "random" "sandbox" "spaceless" "verbatim" "with") - "Django controls.") - -(defvar web-mode-go-active-blocks - '("else" "end" "if" "range" "with") - "Go controls.") - -(defvar web-mode-php-active-blocks - '("declare" "else" "elseif" "for" "foreach" "if" "while") - "PHP controls.") - -(defvar web-mode-smarty-active-blocks - '("block" "else" "elseif" "foreach" "for" "if" "section" "while") - "Smarty controls.") - -(defvar web-mode-velocity-active-blocks - '("define" "else" "elseif" "end" "for" "foreach" "if" "macro") - "Velocity controls.") - -(defvar web-mode-web2py-active-blocks - '("block" "def" "elif" "else" "end" "except" "finally" "for" - "if" "pass" "return" "try" "while") - "Web2py active controls") - -(defvar web-mode-active-block-regexps - (list - (cons "asp" "----") - (cons "aspx" "----") - (cons "angular" "----") - (cons "blade" (concat "@\\(end\\)?" (regexp-opt web-mode-blade-active-blocks t))) - (cons "closure" (concat "{/?" (regexp-opt web-mode-closure-active-blocks t))) - (cons "ctemplate" "{{[#^/]\\([[:alnum:]_]+\\)") - (cons "django" (concat "{%[-]?[ ]+\\(end\\)?" (regexp-opt web-mode-django-active-blocks t))) - (cons "dust" "{[#/:?@><+^]\\([[:alpha:]_]+\\)") - (cons "erb" "<%[-=]?[ ]+\\(.* do \\|for\\|unless\\|end\\|if\\|else\\)") - (cons "freemarker" "") - ("for" . "") - ("foreach" . "") - ("while" . ""))) - ) - "Closing blocks (see web-mode-block-close)" - ) - -(defvar web-mode-engines-auto-pairs - '( - ("angular" . (("{{ " " }}"))) - ("asp" . (("<% " " %>"))) - ("aspx" . (("<% " " %>") - ("<%=" "%>") - ("<%#" "%>") - ("<%$" "%>") - ("<%@" "%>") - ("<%:" "%>") - ("<%-" "- " " --%>"))) - ("blade" . (("{{ " " }}") - ("{{-" "- " " --}}"))) - ("django" . (("{{ " " }}") - ("{% " " %}") - ("{# " " #}"))) - ("erb" . (("<% " " %>") - ("<%=" "%>") - ("<%#" "%>"))) - ("freemarker" . (("<% " " %>") - ("${ " " }") - ("[% " " %]") - ("[# " " #]") - ("[#-" "- " " --]"))) - ("jsp" . (("<% " " %>") - ("<%-" "- " " %>") - ("<%=" "%>") - ("<%!" "%>") - ("<%@" "%>") - ("${ " " }"))) - ("mako" . (("<% " " %>") - ("<%!" " " " %>") - ("${ " " }"))) - ("mason" . (("<% " " %>"))) - ("php" . (("") - ("") - (""))) - ("underscore" . (("<% " " %>"))) - ("web2py" . (("{{ " " }}") - ("{{=" "}}"))) - (nil . ((""))) - - ) - "Engines auto-pairs") - -(defvar web-mode-snippets nil - "Snippets") - -(defvar web-mode-engines-snippets - '(("erb" . (("if" . ("<% if " . " %>\n\n<% end %>")))) - ("php" . (("if" . ("\n\n")) - ("while" . ("\n\n")) - ("for" . ("\n\n")) - ("foreach" . ("\n\n")) - ("switch" . ("\n\n\n\n\n\n\n")))) - ("django" . (("block" . ("{% block " . " %}\n\n{% endblock %}")) - ("comment" . ("{% comment " . " %}\n\n{% endcomment %}")) - ("cycle" . ("{% cycle " . " as %}\n\n{% endcycle %}")) - ("filter" . ("{% filter " . " %}\n\n{% endfilter %}")) - ("for" . ("{% for " . " in %}\n\n{% endfor %}")) - ("if" . ("{% if " . " %}\n\n{% endif %}")))) - (nil . (("html5" . ("\n\n\n\n\n\n\n" . "\n\n")) - ("table" . ("\n\n\n\n\n
" . "
")) - ("ul" . ("
    \n
  • " . "
  • \n
  • \n
")))) - ) - "Engines snippets") - -(defvar web-mode-block-regexps - (list - '("angular" . "{{") - '("asp" . "<%") - '("aspx" . "<%") - '("blade" . "{{.\\|^[ \t]*@[[:alpha:]]") - '("closure" . "{.\\|/\\*\\| //") - '("ctemplate" . "[$]?{{.") - '("django" . "{[#{%].") - '("dust" . "{.") - '("erb" . "<%\\|^%.") - '("freemarker" . "<%\\|${\\|\\|<+^]?" 0 'web-mode-preprocessor-face) - '("{[#:/?@><+^]\\([[:alpha:]_]+\\)" 1 'web-mode-block-control-face) - '(":\\([[:alpha:]]+\\)" 1 'web-mode-keyword-face) - '("\\<\\([[:alpha:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_]*\\)" - (1 'web-mode-block-attr-name-face) - (2 'web-mode-block-attr-value-face)) - '("\\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-template-toolkit-font-lock-keywords - (list - '("\\[%[-+]?\\|[-+=]?%\\]" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-template-toolkit-keywords "\\)\\>") - '(1 'web-mode-keyword-face)) - '("\\\([[:alpha:]][[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("\\\([[:alpha:]][[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-smarty-font-lock-keywords - (list - (cons (concat - "[#]?" - (web-mode-engine-delimiter-close "smarty" "}") - "\\|" - (web-mode-engine-delimiter-open "smarty" "{") - "[/#]?") - '(0 'web-mode-preprocessor-face)) - (cons (concat "[ ]\\(" web-mode-smarty-keywords "\\)[ ]") - '(1 'web-mode-keyword-face)) - (cons (concat (web-mode-engine-delimiter-open "smarty" "{") "/?\\([[:alpha:]_]+\\)") - '(1 'web-mode-block-control-face)) - '("\\<\\([$]\\)\\([[:alnum:]_]+\\)" (1 nil) (2 'web-mode-variable-name-face)) - '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) - '(" \\(\\sw+[ ]?=\\)" 1 'web-mode-param-name-face) - '(" \\(\\sw+\\)[ }]" 1 'web-mode-param-name-face) - '("|\\([[:alnum:]_]+\\)" 1 'web-mode-function-call-face) - '("\\(->\\)\\(\\sw+\\)" (1 nil) (2 'web-mode-variable-name-face)) - '("[.]\\([[:alnum:]_-]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[.]\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) - '("#\\([[:alnum:]_]+\\)#" 1 'web-mode-variable-name-face) - )) - -(defvar web-mode-velocity-font-lock-keywords - (list - '("\\([#]\\)\\([[:alpha:]]+\\)\\>" - (1 'web-mode-preprocessor-face) - (2 'web-mode-block-control-face)) - (cons (concat "[ ]\\(" web-mode-velocity-keywords "\\)[ ]") '(1 'web-mode-keyword-face t t)) - '("#macro([ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-function-name-face) - '("[.]\\([[:alnum:]_-]+\\)" 1 'web-mode-variable-name-face) - '("\\<\\($[!]?[{]?\\)\\([[:alnum:]_-]+\\)[}]?" (1 nil) (2 'web-mode-variable-name-face)) - )) - -(defvar web-mode-mako-tag-font-lock-keywords - (list - '("" 0 'web-mode-preprocessor-face) - '("\\<\\([[:alpha:]]+=\\)\\(\"[^\"]*\"\\)" - (1 'web-mode-block-attr-name-face t t) - (2 'web-mode-block-attr-value-face t t)) - )) - -(defvar web-mode-mako-block-font-lock-keywords - (list - '("<%!?\\|%>" 0 'web-mode-preprocessor-face) - '("\\(%\\)" 1 'web-mode-preprocessor-face) - '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) - (cons (concat "\\<\\(" web-mode-python-constants "\\)\\>") '(1 'web-mode-constant-face)) - (cons (concat "\\<\\(" web-mode-python-keywords "\\)\\>") '(1 'web-mode-keyword-face)) - (cons (concat "\\<\\(endfor\\|endif\\|endwhile\\)\\>") '(1 'web-mode-keyword-face)) - )) - -(defvar web-mode-web2py-font-lock-keywords - (list - '("{{[=]?\\|}}" 0 'web-mode-preprocessor-face) - '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) - (cons (concat "\\<\\(" web-mode-python-constants "\\)\\>") '(1 'web-mode-constant-face)) - (cons (concat "\\<\\(" web-mode-python-keywords "\\)\\>") '(1 'web-mode-keyword-face)) - (cons (concat "\\<\\(block\\|extend\\|super\\|end\\|include\\)\\>") '(1 'web-mode-keyword-face)) - )) - -(defvar web-mode-django-expr-font-lock-keywords - (list - '("\\({{\\)[ ]?" 1 'web-mode-preprocessor-face) - '("[ ]?\\(}}\\)" 1 'web-mode-preprocessor-face) - '("|[ ]?\\([[:alpha:]_]+\\)\\>" 1 'web-mode-function-call-face) - (cons (concat "\\<\\(" web-mode-django-types "\\)\\>") '(1 'web-mode-type-face)) - '("\\<\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alnum:]_]+" 0 'web-mode-variable-name-face) - ) - "Font lock keywords for dtl expr") - -(defvar web-mode-django-code-font-lock-keywords - (list - '("{%\\|%}" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-django-keywords "\\)\\>") '(1 'web-mode-keyword-face)) - (cons (concat "\\<\\(" web-mode-django-types "\\)\\>") '(1 'web-mode-type-face)) - '("|[ ]?\\([[:alpha:]_]+\\)\\>" 1 'web-mode-function-call-face) -;; (cons (concat "|[ ]?\\(" web-mode-django-filters "\\)\\>") '(1 'web-mode-function-name-face t t)) - '("\\<\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alnum:]_]+" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-ctemplate-font-lock-keywords - (list - '("${{\\|{{[>#/{%^&]?\\|[}]?}}" 0 'web-mode-preprocessor-face) - '("{{[#/>][ ]*\\([[:alnum:]_-]+\\)" 1 'web-mode-block-control-face) - '("[[:alnum:]_]" 0 'web-mode-variable-name-face) - '("[ ]+\\([[:alnum:]_]+=\\)" 1 'web-mode-param-name-face t t) - '("[:=]\\([[:alpha:]_]+\\)" 1 'web-mode-function-call-face t t) - )) - -(defvar web-mode-razor-font-lock-keywords - (list - '("@" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-razor-keywords "\\)\\>") - '(1 'web-mode-keyword-face t t)) -;; '("\\([[:alnum:]]+\\):" 1 'web-mode-symbol-face) - '("@\\([[:alnum:]_.]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("@\\([[:alnum:]_.]+\\)" 1 'web-mode-variable-name-face) -;; '("<\\([[:alnum:]_]+\\)>" 1 'web-mode-type-face) -;; '("\\<\\([[:alnum:].]+\\)[ ]+[{[:alpha:]]+" 1 'web-mode-type-face) -;; '("[[:alnum:]_]+" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-closure-font-lock-keywords - (list - '("{/?\\|/?}" 0 'web-mode-preprocessor-face) - '("{/?\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face) - '("{param[ ]+\\([[:alnum:]]+\\)" 1 'web-mode-symbol-face) - '("\\<\\(true\\|false\\|null\\)\\>" 1 'web-mode-type-face) - (cons (concat "\\<\\(" web-mode-closure-keywords "\\)\\>") - '(1 'web-mode-keyword-face)) - '("{\\(alias\\|call\\|delcall\\|delpackage\\|deltemplate\\|namespace\\|template\\)[ ]+\\([[:alnum:].]+\\)" 2 'web-mode-constant-face) - '("\\(allowemptydefault\\|data\\|desc\\|meaning\\|autoescape\\|private\\|variant\\)=" 0 'web-mode-block-attr-name-face) - '("|\\([[:alpha:]]+\\)" 1 'web-mode-function-call-face) - '("\\<\\([[:alnum:]]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("$\\([[:alnum:]._]+\\)" 1 'web-mode-variable-name-face) - )) - -(defvar web-mode-go-font-lock-keywords - (list - '("{{\\|}}" 0 'web-mode-preprocessor-face) - '("{{\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face) - (cons (concat "\\<\\(" web-mode-go-keywords "\\)\\>") - '(1 'web-mode-keyword-face)) - (cons (concat "\\<\\(" web-mode-go-functions "\\)\\>") - '(1 'web-mode-function-call-face)) - '("[$.]\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face t t) - )) - -(defvar web-mode-expression-font-lock-keywords - (list - '("<%\\$\\|%>" 0 'web-mode-preprocessor-face) - '("[[:alpha:]_]" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-angular-font-lock-keywords - (list - '("{{\\|}}" 0 'web-mode-preprocessor-face) - '("[[:alpha:]_]" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-selector-font-lock-keywords - (list - (cons (concat "@\\(" web-mode-css-at-rules "\\)\\>") - '(1 'web-mode-css-at-rule-face)) - '("\\<\\(all\|braille\\|embossed\\|handheld\\|print\\|projection\\|screen\\|speech\\|tty\\|tv\\|and\\|or\\)\\>" 1 'web-mode-keyword-face) - (cons (concat ":\\(" web-mode-css-pseudo-classes "\\)\\>") - '(1 'web-mode-css-pseudo-class-face)) - '("[[:alnum:]-]+" 0 'web-mode-css-selector-face) - '("\\[.*?\\]\\|(.*?)" 0 nil t t) - '("url(\\(.+?\\))" 1 'web-mode-string-face) - )) - -(defvar web-mode-declaration-font-lock-keywords - (list - (cons (concat "@\\(" web-mode-css-at-rules "\\)\\>") '(1 'web-mode-css-at-rule-face)) - '("url(\\([^)]+\\)" 1 'web-mode-string-face) - '("\\([[:alpha:]-]+\\)[ ]?:" 1 'web-mode-css-property-name-face) - '("\\([[:alpha:]-]+\\)[ ]?(" 1 'web-mode-css-function-face) - '("#[[:alnum:]]\\{1,6\\}" 0 'web-mode-css-color-face t t) - '("![ ]?important" 0 'web-mode-css-priority-face t t) - )) - -(defvar web-mode-html-font-lock-keywords - (list - '("]\\|>" 0 'web-mode-html-tag-face t) - '(" \\([[:alnum:]-]+=\\)\\(\"[^\"]+\"\\)" - (1 'web-mode-html-attr-name-face) - (2 'web-mode-html-attr-value-face)) - )) - -(defvar web-mode-javascript-font-lock-keywords - (list - (cons (concat "\\<\\(" web-mode-javascript-keywords "\\)\\>") - '(0 'web-mode-keyword-face)) - (cons (concat "\\<\\(" web-mode-javascript-constants "\\)\\>") - '(0 'web-mode-constant-face)) - '("\\<\\(new\\|instanceof\\) \\([[:alnum:]_.]+\\)\\>" 2 'web-mode-type-face) - '("\\<\\([[:alnum:]_]+\\):[ ]*function[ ]*(" 1 'web-mode-function-name-face) - '("\\[ ]+" -;; (1 'web-mode-keyword-face) -;; ("\\([[:alnum:]_]+\\)\\([ ]*=[^,;]*\\)?[,; ]" nil nil (1 'web-mode-variable-name-face))) - '("\\<\\(function\\)[ ]*(" - (1 'web-mode-keyword-face) - ("\\([[:alnum:]_]+\\)\\([ ]*=[^,)]*\\)?[,)]" nil nil (1 'web-mode-variable-name-face))) - '("\\([[:alnum:]_]+\\):" 1 'web-mode-variable-name-face) - )) - -(defvar web-mode-underscore-font-lock-keywords - (list - '("<%[-=]?\\|%>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-javascript-keywords "\\)\\>") - '(0 'web-mode-keyword-face)) - '("\\<\\(_\.[[:alpha:]]+\\)(" 1 'web-mode-function-call-face) - '("\\" 1 'web-mode-type-face) - '("\\<\\([[:alnum:]_]+\\):[ ]*function[ ]*(" 1 'web-mode-function-name-face) - '("\\<\\(var\\)\\>[ ]+\\([[:alnum:]_]+\\)" - (1 'web-mode-keyword-face) - (2 'web-mode-variable-name-face)) - )) - -(defvar web-mode-asp-font-lock-keywords - (list - '("<%=?\\|%>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-asp-keywords "\\)\\>") - '(0 'web-mode-keyword-face)) - (cons (concat "\\<\\(" web-mode-asp-types "\\)\\>") - '(0 'web-mode-type-face)) - (cons (concat "\\<\\(" web-mode-asp-constants "\\)\\>") - '(0 'web-mode-constant-face)) - '("\\(Class\\|new\\) \\([[:alnum:]_]+\\)" 2 'web-mode-type-face) - '("Const \\([[:alnum:]_]+\\)" 1 'web-mode-constant-face) - '("\\" - (0 'web-mode-keyword-face) - ("[[:alnum:]_]+" nil nil (0 'web-mode-variable-name-face))) - '("\\<\\(public\\|private\\|sub\\|function\\)\\> \\([[:alnum:]_]+\\)[ ]*(" - 2 'web-mode-function-name-face) - '("\\<\\(public\\|private\\|dim\\)\\> \\([[:alnum:]_]+\\)" - 2 'web-mode-variable-name-face) - )) - -(defvar web-mode-aspx-font-lock-keywords - (list - '("<%[:=#]?\\|%>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-aspx-keywords "\\)\\>") '(0 'web-mode-keyword-face)) - '("\\<\\([[:alnum:].]+\\)[ ]+[[:alpha:]]+" 1 'web-mode-type-face) - )) - -;;Unified Expression Language -(defvar web-mode-uel-font-lock-keywords - (list - '("[$#{]{\\|}" 0 'web-mode-preprocessor-face) - '("\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("|[ ]*\\(trim\\|x\\|u\\)" 1 'web-mode-function-call-face) - '("[[:alpha:]_]" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-php-var-interpolation-font-lock-keywords - (list - '("[[:alpha:]_]" 0 'web-mode-variable-name-face) - '("\".+\"\\|'.*'" 0 'web-mode-string-face) - )) - -(defvar web-mode-freemarker-square-font-lock-keywords - (list - '("\\[/?[#@]\\|/?>\\|/?\\]" 0 'web-mode-preprocessor-face) - '("\\[/?[#@]\\([[:alpha:]_.]*\\)" 1 'web-mode-block-control-face) - '("#\\(macro\\|function\\) \\([[:alpha:]]+\\)" 2 'web-mode-function-name-face) - (cons (concat "\\<\\(" web-mode-freemarker-keywords "\\)\\>") - '(1 'web-mode-keyword-face)) - '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face) - )) - -(defvar web-mode-freemarker-font-lock-keywords - (list - '("\\|/?>" 0 'web-mode-preprocessor-face) - '("") '(1 'web-mode-keyword-face)) - '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face) - )) - -;;TODO : definir web-mode-block-attr-name-face et web-mode-block-attr-name-face -(defvar web-mode-jsp-tag-font-lock-keywords - (list - '("" 0 'web-mode-preprocessor-face) - '("\\|<%\\(!\\|=\\|#=\\)?" 0 'web-mode-preprocessor-face) - '("\\(throws\\|new\\|extends\\)[ ]+\\([[:alnum:].]+\\)" 2 'web-mode-type-face) - (cons (concat "\\<\\(" web-mode-jsp-keywords "\\)\\>") '(0 'web-mode-keyword-face)) - '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) - '("@\\(\\sw*\\)" 1 'web-mode-variable-name-face) - '("\\<\\([[:alnum:].]+\\)[ ]+[{[:alpha:]]+" 1 'web-mode-type-face) - )) - -(defvar web-mode-directive-font-lock-keywords - (list - '("<%@\\|%>" 0 'web-mode-preprocessor-face) - '("<%@[ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-block-control-face) - '("\\<\\([[:alpha:]]+=\\)\\(\"[^\"]*\"\\)" - (1 'web-mode-block-attr-name-face t t) - (2 'web-mode-block-attr-value-face t t)) - )) - -(defvar web-mode-erb-font-lock-keywords - (list - '("-?%>\\|^%\\|<%[=-]?" 0 'web-mode-preprocessor-face) - '("[^:]\\(:[[:alnum:]_]+\\)" 1 'web-mode-symbol-face) - '("\\([[:alnum:]_]+:\\)[ ]+" 1 'web-mode-symbol-face) - (cons (concat "\\<\\(" web-mode-erb-builtins "\\)\\>") - '(0 'web-mode-builtin-face)) - (cons (concat "\\<\\(" web-mode-erb-keywords "\\)\\>") - '(0 'web-mode-keyword-face)) - '("\\<\\(self\\|true\\|false\\|nil\\)\\>" 0 'web-mode-variable-name-face) - '("[@$]@?\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) - '("class[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-type-face) - '("def[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) - '("\\(?:\\_<\\|::\\)\\([A-Z]+[[:alnum:]_]+\\)" - 1 (unless (eq ?\( (char-after)) 'web-mode-type-face)) - '("/[^/]+/" 0 'web-mode-string-face) - )) - -(defvar web-mode-python-font-lock-keywords - (list - '("<\\?\\|\\?>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-python-keywords "\\)\\>") '(0 'web-mode-keyword-face)) - )) - -(defvar web-mode-mason-font-lock-keywords - (list - '("^\\(%\\)" 1 'web-mode-preprocessor-face) - '("<%\\(def\\|method\\).*>" 0 'web-mode-preprocessor-face) - '("\\|\\|<[%&]|?\\|[%&]>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-mason-keywords "\\)\\>") - '(0 'web-mode-keyword-face)) - '("sub[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) - '(" | \\([hun]+\\) " 1 'web-mode-function-name-face) - '("\\<\\([[:alnum:]_]+\\)[ ]?::" 1 'web-mode-type-face) - '("\\([@]\\)\\([[:alnum:]#_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) - '("\\<\\([$%]\\)\\([[:alnum:]@#_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) - '("{\\([[:alnum:]_]+\\)}" 1 'web-mode-variable-name-face) - '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alnum:]_][ ]?::[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) - '("->[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) - )) - -(defvar web-mode-php-font-lock-keywords - (list -;; '("<\\?\\(php\\|=\\)?\\|\\?>" 0 'web-mode-preprocessor-face) - (cons (concat "\\<\\(" web-mode-php-keywords "\\)\\>") '(0 'web-mode-keyword-face)) - (cons (concat "(\\<\\(" web-mode-php-types "\\)\\>") '(1 'web-mode-type-face)) - (cons (concat "\\<\\(" web-mode-php-constants "\\)\\>") '(0 'web-mode-constant-face)) - '("function[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) - '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) - '("[[:alnum:]_][ ]?::[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-constant-face) - '("->[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) - '("\\<\\([[:alnum:]_]+\\)[ ]?::" 1 'web-mode-type-face) - '("\\<\\(instanceof\\|class\\|extends\\|new\\)[ ]+\\([[:alnum:]_]+\\)" 2 'web-mode-type-face) - '("\\<\\([$]\\)\\([[:alnum:]_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) - )) - -(defvar web-mode-blade-font-lock-keywords - (append - (list - '("{{\\|}}" 0 'web-mode-preprocessor-face) - '("\\(@\\)\\([[:alpha:]_]+\\)" - (1 'web-mode-preprocessor-face) - (2 'web-mode-block-control-face))) - web-mode-php-font-lock-keywords)) - -(defvar web-mode-engines-font-lock-keywords - '(("angular" . web-mode-angular-font-lock-keywords) - ("asp" . web-mode-asp-font-lock-keywords) - ("blade" . web-mode-blade-font-lock-keywords) - ("closure" . web-mode-closure-font-lock-keywords) - ("ctemplate" . web-mode-ctemplate-font-lock-keywords) - ("dust" . web-mode-dust-font-lock-keywords) - ("erb" . web-mode-erb-font-lock-keywords) - ("go" . web-mode-go-font-lock-keywords) - ("mason" . web-mode-mason-font-lock-keywords) - ("php" . web-mode-php-font-lock-keywords) - ("python" . web-mode-python-font-lock-keywords) - ("razor" . web-mode-razor-font-lock-keywords) - ("smarty" . web-mode-smarty-font-lock-keywords) - ("template-toolkit" . web-mode-template-toolkit-font-lock-keywords) - ("underscore" . web-mode-underscore-font-lock-keywords) - ("web2py" . web-mode-web2py-font-lock-keywords) - ("velocity" . web-mode-velocity-font-lock-keywords)) - "Engines font-lock keywords") - -(defvar web-mode-syntax-table - (let ((table (make-syntax-table))) - (modify-syntax-entry ?_ "w" table) - - (modify-syntax-entry ?< "." table) - (modify-syntax-entry ?> "." table) - (modify-syntax-entry ?& "." table) - (modify-syntax-entry ?/ "." table) - (modify-syntax-entry ?= "." table) - - table) - "Syntax table in use in web-mode buffers.") - -(defvar web-mode-map - (let ((map (make-sparse-keymap))) - - (define-key map [menu-bar wm] (cons "Web-Mode" (make-sparse-keymap))) - (define-key map [menu-bar wm dom] (cons "Dom" (make-sparse-keymap))) - (define-key map [menu-bar wm blk] (cons "Block" (make-sparse-keymap))) - (define-key map [menu-bar wm tag] (cons "Html Tag" (make-sparse-keymap))) - (define-key map [menu-bar wm elt] (cons "Html Element" (make-sparse-keymap))) - - (define-key map [menu-bar wm sep-1] '(menu-item "--")) - - (define-key map [menu-bar wm dom dom-xpa] '(menu-item "XPath" web-mode-dom-xpath)) - (define-key map [menu-bar wm dom dom-tra] '(menu-item "Traverse" web-mode-dom-traverse)) - (define-key map [menu-bar wm dom dom-err] '(menu-item "Show error(s)" web-mode-dom-errors-show)) - (define-key map [menu-bar wm dom dom-ent] '(menu-item "Replace HTML entities" web-mode-dom-entities-replace)) - (define-key map [menu-bar wm dom dom-quo] '(menu-item "Replace dumb quotes" web-mode-dom-quotes-replace)) - (define-key map [menu-bar wm dom dom-apo] '(menu-item "Replace apostrophes" web-mode-dom-apostrophes-replace)) - (define-key map [menu-bar wm dom dom-nor] '(menu-item "Normalise" web-mode-dom-normalize)) - - (define-key map [menu-bar wm blk blk-sel] '(menu-item "Select" web-mode-block-select)) - (define-key map [menu-bar wm blk blk-pre] '(menu-item "Previous" web-mode-block-previous)) - (define-key map [menu-bar wm blk blk-nex] '(menu-item "Next" web-mode-block-next)) - (define-key map [menu-bar wm blk blk-kil] '(menu-item "Kill" web-mode-block-kill)) - (define-key map [menu-bar wm blk blk-end] '(menu-item "End" web-mode-block-beginning)) - (define-key map [menu-bar wm blk blk-clo] '(menu-item "Close" web-mode-block-close)) - (define-key map [menu-bar wm blk blk-beg] '(menu-item "Beginning" web-mode-block-beginning)) - - (define-key map [menu-bar wm tag tag-sel] '(menu-item "Select" web-mode-tag-select)) - (define-key map [menu-bar wm tag tag-pre] '(menu-item "Previous" web-mode-tag-previous)) - (define-key map [menu-bar wm tag tag-nex] '(menu-item "Next" web-mode-tag-next)) - (define-key map [menu-bar wm tag tag-mat] '(menu-item "Match" web-mode-tag-match)) - (define-key map [menu-bar wm tag tag-end] '(menu-item "End" web-mode-tag-beginning)) - (define-key map [menu-bar wm tag tag-beg] '(menu-item "Beginning" web-mode-tag-beginning)) - - (define-key map [menu-bar wm elt elt-wra] '(menu-item "Wrap" web-mode-element-wrap)) - (define-key map [menu-bar wm elt elt-van] '(menu-item "Vanish" web-mode-element-vanish)) - (define-key map [menu-bar wm elt elt-exc] '(menu-item "Transpose" web-mode-element-transpose)) - (define-key map [menu-bar wm elt elt-sel] '(menu-item "Select" web-mode-element-select)) - (define-key map [menu-bar wm elt elt-ren] '(menu-item "Rename" web-mode-element-rename)) - (define-key map [menu-bar wm elt elt-pre] '(menu-item "Previous" web-mode-element-previous)) - (define-key map [menu-bar wm elt elt-par] '(menu-item "Parent" web-mode-element-parent)) - (define-key map [menu-bar wm elt elt-nex] '(menu-item "Next" web-mode-element-next)) - (define-key map [menu-bar wm elt elt-mut] '(menu-item "Mute blanks" web-mode-element-mute-blanks)) - (define-key map [menu-bar wm elt elt-del] '(menu-item "Kill" web-mode-element-kill)) - (define-key map [menu-bar wm elt elt-end] '(menu-item "End" web-mode-element-end)) - (define-key map [menu-bar wm elt elt-inn] '(menu-item "Content (select)" web-mode-element-content-select)) - (define-key map [menu-bar wm elt elt-clo] '(menu-item "Close" web-mode-element-close)) - (define-key map [menu-bar wm elt elt-dup] '(menu-item "Clone" web-mode-element-clone)) - (define-key map [menu-bar wm elt elt-cfo] '(menu-item "Children fold" web-mode-element-children-fold-or-unfold)) - (define-key map [menu-bar wm elt elt-chi] '(menu-item "Child" web-mode-element-child)) - (define-key map [menu-bar wm elt elt-beg] '(menu-item "Beginning" web-mode-element-beginning)) - - (define-key map [menu-bar wm fol] '(menu-item "Fold/Unfold" web-mode-fold-or-unfold)) - (define-key map [menu-bar wm ind] '(menu-item "Indent buffer" web-mode-buffer-indent)) - (define-key map [menu-bar wm nav] '(menu-item "Tag/Block navigation" web-mode-tag-match)) - (define-key map [menu-bar wm exp] '(menu-item "Mark and Expand" web-mode-mark-and-expand)) - (define-key map [menu-bar wm spa] '(menu-item "Toggle whitespaces" web-mode-whitespaces-show)) - (define-key map [menu-bar wm sni] '(menu-item "Insert snippet" web-mode-snippet-insert)) - - ;;-------------------------------------------------------------------------- - ;; "C-c letter" are reserved for users - - (define-key map (kbd "C-c C-b c") 'web-mode-block-close) - (define-key map (kbd "C-c C-b b") 'web-mode-block-beginning) - (define-key map (kbd "C-c C-b e") 'web-mode-block-end) - (define-key map (kbd "C-c C-b k") 'web-mode-block-kill) - (define-key map (kbd "C-c C-b n") 'web-mode-block-next) - (define-key map (kbd "C-c C-b p") 'web-mode-block-previous) - (define-key map (kbd "C-c C-b s") 'web-mode-block-select) - - (define-key map (kbd "C-c C-d a") 'web-mode-dom-apostrophes-replace) - (define-key map (kbd "C-c C-d n") 'web-mode-dom-normalize) - (define-key map (kbd "C-c C-d d") 'web-mode-dom-errors-show) - (define-key map (kbd "C-c C-d e") 'web-mode-dom-entities-replace) - (define-key map (kbd "C-c C-d q") 'web-mode-dom-quotes-replace) - (define-key map (kbd "C-c C-d t") 'web-mode-dom-traverse) - (define-key map (kbd "C-c C-d x") 'web-mode-dom-xpath) - - (define-key map (kbd "C-c C-e b") 'web-mode-element-beginning) - (define-key map (kbd "C-c C-e c") 'web-mode-element-clone) - (define-key map (kbd "C-c C-e d") 'web-mode-element-child) - (define-key map (kbd "C-c C-e e") 'web-mode-element-end) - (define-key map (kbd "C-c C-e f") 'web-mode-element-children-fold-or-unfold) - (define-key map (kbd "C-c C-e i") 'web-mode-element-content-select) - (define-key map (kbd "C-c C-e k") 'web-mode-element-kill) - (define-key map (kbd "C-c C-e m") 'web-mode-element-mute-blanks) - (define-key map (kbd "C-c C-e n") 'web-mode-element-next) - (define-key map (kbd "C-c C-e p") 'web-mode-element-previous) - (define-key map (kbd "C-c C-e r") 'web-mode-element-rename) - (define-key map (kbd "C-c C-e s") 'web-mode-element-select) - (define-key map (kbd "C-c C-e t") 'web-mode-element-transpose) - (define-key map (kbd "C-c C-e u") 'web-mode-element-parent) - (define-key map (kbd "C-c C-e v") 'web-mode-element-vanish) - (define-key map (kbd "C-c C-e w") 'web-mode-element-wrap) - - (define-key map (kbd "C-c C-t b") 'web-mode-tag-beginning) - (define-key map (kbd "C-c C-t e") 'web-mode-tag-end) - (define-key map (kbd "C-c C-t m") 'web-mode-tag-match) - (define-key map (kbd "C-c C-t n") 'web-mode-tag-next) - (define-key map (kbd "C-c C-t p") 'web-mode-tag-previous) - (define-key map (kbd "C-c C-t s") 'web-mode-tag-select) - - ;;-------------------------------------------------------------------------- - - (define-key map (kbd "C-;") 'web-mode-comment-or-uncomment) - (define-key map (kbd "M-;") 'web-mode-comment-or-uncomment) - - ;;C-c C-b : block - ;;C-c C-d : dom - ;;C-c C-e : element - (define-key map (kbd "C-c C-f") 'web-mode-fold-or-unfold) - (define-key map (kbd "C-c C-i") 'web-mode-buffer-indent) - (define-key map (kbd "C-c C-j") 'web-mode-jshint) - (define-key map (kbd "C-c C-m") 'web-mode-mark-and-expand) - (define-key map (kbd "C-c C-s") 'web-mode-snippet-insert) - ;;C-c C-t : tag - (define-key map (kbd "C-c C-w") 'web-mode-whitespaces-show) - - ;; compatibility with nxml - ;;(define-key map (kbd "M-C-u") 'web-mode-element-parent) - ;;(define-key map (kbd "M-C-d") 'web-mode-element-child) - ;;(define-key map (kbd "M-C-n") 'web-mode-element-next) - ;;(define-key map (kbd "M-C-p") 'web-mode-element-previous) - - ;;(define-key map (kbd "C-c /") 'web-mode-element-close) - ;;(define-key map (kbd "C-c <") 'web-mode-element-beginning) - ;;(define-key map (kbd "C-c >") 'web-mode-element-end) - - ;;(define-key map (kbd "C-c C-c") 'web-mode-block-close) - ;;(define-key map (kbd "C-c C-n") 'web-mode-tag-match) - ;;(define-key map (kbd "C-c C-p") 'web-mode-element-parent) - ;;(define-key map (kbd "C-c C-v") 'web-mode-dom-traverse) - - map) - "Keymap for `web-mode'.") - -;;--- compatibility - -(eval-and-compile - - (defalias 'web-mode-prog-mode - (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode)) - - (if (fboundp 'with-silent-modifications) - (defalias 'web-mode-with-silent-modifications 'with-silent-modifications) - (defmacro web-mode-with-silent-modifications (&rest body) - "For compatibility with Emacs pre 23.3" - `(let ((old-modified-p (buffer-modified-p)) - (inhibit-modification-hooks t) - (buffer-undo-list t)) - (unwind-protect - ,@body - (set-buffer-modified-p old-modified-p))))) - - ) ;eval-and-compile - -(defvar web-mode-font-lock-keywords - '(web-mode-font-lock-highlight)) - -(defun web-mode-font-lock-extend-region () - (save-excursion -;; (message "before : font-lock-beg=%S - font-lock-end=%S" font-lock-beg font-lock-end) - (setq font-lock-beg (or (web-mode-previous-tag-at-bol-pos font-lock-beg) - (point-min)) - font-lock-end (or (web-mode-next-tag-at-eol-pos font-lock-end) - (point-max))) -;; (message "after : font-lock-beg=%S - font-lock-end=%S" font-lock-beg font-lock-end) - nil)) - -(defun web-mode-font-lock-highlight (limit) - "font-lock matcher" -;; (message "web-mode-font-lock-highlight : point=%S limit=%S" (point) limit) - (web-mode-highlight-region (point) limit) - nil) - -;;;###autoload -(define-derived-mode web-mode web-mode-prog-mode "Web" - "Major mode for editing web templates (HTML documents with embedded parts and blocks)." - - (make-local-variable 'web-mode-auto-pairs) - (make-local-variable 'web-mode-buffer-highlighted) - (make-local-variable 'web-mode-comment-style) - (make-local-variable 'web-mode-content-type) - (make-local-variable 'web-mode-display-table) - (make-local-variable 'web-mode-engine) - (make-local-variable 'web-mode-block-regexps) - (make-local-variable 'web-mode-enable-block-face) - (make-local-variable 'web-mode-enable-part-face) - (make-local-variable 'web-mode-engine-file-regexps) - (make-local-variable 'web-mode-expand-initial-pos) - (make-local-variable 'web-mode-expand-previous-state) - (make-local-variable 'web-mode-has-any-large-block) - (make-local-variable 'web-mode-has-any-large-part) - (make-local-variable 'web-mode-hl-line-mode-flag) - (make-local-variable 'web-mode-indent-style) - (make-local-variable 'web-mode-is-narrowed) - (make-local-variable 'web-mode-jshint-errors) - (make-local-variable 'web-mode-block-regexp) - (make-local-variable 'web-mode-start-tag-overlay) - (make-local-variable 'web-mode-end-tag-overlay) - (make-local-variable 'web-mode-time) - - (make-local-variable 'after-change-functions) - (make-local-variable 'change-major-mode-hook) - (make-local-variable 'fill-paragraph-function) - (make-local-variable 'font-lock-defaults) - (make-local-variable 'font-lock-extend-region-functions) - (make-local-variable 'font-lock-maximum-size) - (make-local-variable 'font-lock-support-mode) - (make-local-variable 'imenu-case-fold-search) - (make-local-variable 'imenu-create-index-function) - (make-local-variable 'imenu-generic-expression) - (make-local-variable 'indent-line-function) - - (setq fill-paragraph-function 'web-mode-fill-paragraph - font-lock-defaults '(web-mode-font-lock-keywords t) - font-lock-extend-region-functions '(web-mode-font-lock-extend-region) - font-lock-support-mode nil - font-lock-maximum-size nil - ;; font-lock-fontify-buffer-function 'web-mode-scan-buffer - ;; font-lock-unfontify-buffer-function 'web-mode-scan-buffer - imenu-case-fold-search t - imenu-create-index-function 'web-mode-imenu-index - indent-line-function 'web-mode-indent-line) - -;; (remove-hook 'after-change-functions 'font-lock-after-change-function t) - - (if (and (fboundp 'global-hl-line-mode) - global-hl-line-mode) - (setq web-mode-hl-line-mode-flag t)) - - (when web-mode-enable-current-element-highlight - (add-hook 'post-command-hook 'web-mode-highlight-current-element nil t)) - - (add-hook 'after-change-functions 'web-mode-on-after-change t t) - (add-hook 'change-major-mode-hook 'web-mode-on-exit nil t) - - (add-hook 'after-save-hook - '(lambda () - (when web-mode-is-scratch - (web-mode-guess-engine-and-content-type) - (web-mode-scan-buffer) -;; (message "-->%S" (buffer-file-name)) - ) - nil) - t t) - - (cond - ((boundp 'yas-after-exit-snippet-hook) - (add-hook 'yas-after-exit-snippet-hook - 'web-mode-yasnippet-exit-hook - t t)) - ((boundp 'yas/after-exit-snippet-hook) - (add-hook 'yas/after-exit-snippet-hook - 'web-mode-yasnippet-exit-hook - t t)) - ) - - (when web-mode-enable-whitespaces - (web-mode-whitespaces-on)) - - (web-mode-guess-engine-and-content-type) -;; (web-mode-scan-buffer) - - (web-mode-scan-region (point-min) (point-max)) - - ) - -;; (add-hook 'web-mode-hook -;; (lambda() -;; (let (mode modes found) -;; (setq modes '(esk-add-watchwords -;; esk-pretty-lambdas -;; fic-ext-mode -;; fic-mode -;; global-whitespace-mode -;; idle-highlight-mode -;; rainbow-mode -;; whitespace-mode)) -;; ;; (message "==> %S" column-number-mode) -;; ;; (when (and (boundp 'global-whitespace-mode) global-whitespace-mode) -;; ;; (message "==> %S" global-whitespace-mode)) -;; (dolist (mode modes) -;; ;; (message "> %S (%S) has been disabled" mode (symbol-value mode)) -;; (when (and (boundp mode) (symbol-value mode)) -;; (message "=> %S (%S) has been disabled" mode (symbol-value mode)) -;; (setq found t) -;; (funcall mode -1)) -;; ) ;dolist -;; (when found -;; (web-mode-scan-buffer) -;; ) -;; ))) - -(defun web-mode-yasnippet-exit-hook () - "Yasnippet exit hook" - (when (and (boundp 'yas-snippet-beg) (boundp 'yas-snippet-end)) -;; (web-mode-highlight-region yas-snippet-beg yas-snippet-end) -;; (redisplay) - (indent-region yas-snippet-beg yas-snippet-end))) - -(defun web-mode-forward-sexp (&optional arg) - "Move forward." - (interactive "p") - (unless arg (setq arg 1)) - (cond - ((> arg 0) - (while - (progn - (web-mode-tag-next) - (> (setq arg (1- arg)) 0)))) - ((< arg 0) - (while - (progn - (web-mode-tag-previous) - (< (setq arg (1+ arg)) 0)))) - )) - -(defun web-mode-set-engine (engine) - "set engine" - (interactive - (list (completing-read - "Engine: " - (let (engines elt) - (dolist (elt web-mode-engines) - (setq engines (append engines (list (car elt))))) - engines)))) - (setq web-mode-content-type "html" - web-mode-engine engine) - (web-mode-on-engine-setted) - (web-mode-scan-buffer)) - -(defun web-mode-on-engine-setted () - "engine setted" - (let (elt elts engines) -;; (when (string= web-mode-engine "razor") (setq web-mode-enable-block-face t)) - (cond - ((member web-mode-content-type '("css" "javascript" "json")) - (setq web-mode-has-any-large-part t)) - ((member web-mode-content-type '("php")) - (setq web-mode-has-any-large-block nil)) - ) ;cond - - (setq web-mode-electric-chars nil) - (when (string= web-mode-content-type "html") - (unless (string= web-mode-engine "none") - (setq web-mode-active-block-regexp - (cdr (assoc web-mode-engine web-mode-active-block-regexps))) - (setq web-mode-close-block-regexp - (cdr (assoc web-mode-engine web-mode-close-block-regexps))) - (setq web-mode-engine-control-matcher - (intern-soft (concat "web-mode-match-" web-mode-engine "-block"))) - ) - (setq web-mode-electric-chars - (append '(?\<) - (cdr (assoc web-mode-engine web-mode-block-electric-chars))) - ) - ) ;when - - (setq elt (assoc web-mode-engine web-mode-block-regexps)) - (if elt - (setq web-mode-block-regexp (cdr elt)) - (setq web-mode-engine "none")) - - (unless (boundp 'web-mode-extra-auto-pairs) - (setq web-mode-extra-auto-pairs nil)) - - (setq web-mode-auto-pairs - (append - (cdr (assoc web-mode-engine web-mode-engines-auto-pairs)) - (cdr (assoc nil web-mode-engines-auto-pairs)) - (cdr (assoc web-mode-engine web-mode-extra-auto-pairs)) - (cdr (assoc nil web-mode-extra-auto-pairs)))) - - (unless (boundp 'web-mode-extra-snippets) - (setq web-mode-extra-snippets nil)) - - (setq elts - (append - (cdr (assoc web-mode-engine web-mode-extra-snippets)) - (cdr (assoc nil web-mode-extra-snippets)) - (cdr (assoc web-mode-engine web-mode-engines-snippets)) - (cdr (assoc nil web-mode-engines-snippets)))) - - (dolist (elt elts) - (unless (assoc (car elt) web-mode-snippets) - (setq web-mode-snippets (append (list elt) web-mode-snippets))) - ) - -;; (message "wms=%S" web-mode-snippets) - - (setq web-mode-closing-blocks (cdr (assoc web-mode-engine web-mode-engines-closing-blocks))) - - (setq web-mode-engine-font-lock-keywords - (symbol-value (cdr (assoc web-mode-engine web-mode-engines-font-lock-keywords)))) - -;; (message "%S" (symbol-value (cdr (assoc web-mode-engine web-mode-engines-font-lock-keywords)))) - - ;; (message "%S\n%S\n%S\n%S" web-mode-active-block-regexp web-mode-close-block-regexp web-mode-engine-control-matcher web-mode-electric-chars ) - - )) - -(defun web-mode-guess-engine-and-content-type () - "Try to guess the server engine and the content type." - (let (buff-name elt found) - (setq buff-name (buffer-file-name)) - (unless buff-name (setq buff-name (buffer-name))) - (setq web-mode-is-scratch (string= buff-name "*scratch*")) - (setq web-mode-content-type nil) - - (when (boundp 'web-mode-content-types-alist) - (setq found nil) - (dolist (elt web-mode-content-types-alist) - (when (and (not found) (string-match-p (cdr elt) buff-name)) - (setq web-mode-content-type (car elt) - found t)) - ) - ) - (unless web-mode-content-type - (setq found nil) - (dolist (elt web-mode-content-types) - (when (and (not found) (string-match-p (cdr elt) buff-name)) - (setq web-mode-content-type (car elt) - found t)) - ) - ) - (when (boundp 'web-mode-engines-alist) - (setq found nil) - (dolist (elt web-mode-engines-alist) - (cond - ((stringp (cdr elt)) - (when (string-match-p (cdr elt) buff-name) - (setq web-mode-engine (car elt)))) - ((functionp (cdr elt)) - (setq web-mode-engine (car elt))) - ) ;cond - ) ;dolist - ) - (unless web-mode-engine - (setq found nil) - (dolist (elt web-mode-engine-file-regexps) -;; (message "%S %S" (cdr elt) buff-name) - (when (and (not found) (string-match-p (cdr elt) buff-name)) - - (setq web-mode-engine (car elt) - found t)) - ) - ) - (when web-mode-engine - (setq found nil) - (dolist (elt web-mode-engines) - (when (and (not found) (member web-mode-engine (cdr elt))) - (setq web-mode-engine (car elt) - found t)) - ) - ) - (when (and (null found) - (string-match-p "php" (buffer-substring-no-properties - (line-beginning-position) - (line-end-position)))) - (setq web-mode-engine "php" - found t) - ) - -;; (message "engine=%S" web-mode-engine) - - (web-mode-on-engine-setted) - )) - -(defun web-mode-imenu-index () - "Return a table of contents." - (let (toc-index) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "]*\\)>\\([^<]*\\)" nil t) - (setq toc-index - (cons (cons (concat (make-string - (* 2 (1- (string-to-number (match-string 1)))) - ?\s) - (match-string 3)) - (line-beginning-position)) - toc-index)))) - (nreverse toc-index))) - -(defun web-mode-scan-buffer () - "Scan entine buffer." - (interactive) - (web-mode-scan-region (point-min) (point-max)) - (font-lock-fontify-buffer)) - -;;(syntax-propertize) - -(defun web-mode-scan-region (beg end &optional content-type) - "Identify nodes/parts/blocks and syntactic symbols (strings/comments)." - (interactive) - -;; (message "lexing buffer from %d to %d" beg end) - (web-mode-with-silent-modifications - (save-excursion - (save-restriction - (save-match-data - (let ((inhibit-modification-hooks t) - (inhibit-point-motion-hooks t) - (inhibit-quit t)) - (setq beg (if web-mode-is-narrowed 1 beg)) - (remove-text-properties beg end web-mode-scan-properties) - (cond - ((member web-mode-content-type '("javascript" "json" "css")) - (web-mode-scan-blocks beg end) - (web-mode-scan-part beg end) - ) - ((string= web-mode-engine "none") - (web-mode-scan-tags beg end) - (web-mode-scan-parts beg end) - ) - ;; ((and content-type (member content-type '("css"))) - ;; (remove-text-properties beg end web-mode-scan-properties2) - ;; (web-mode-scan-blocks beg end) - ;; (web-mode-scan-part beg end) - ;; ) - ;; ((and content-type (member content-type '("asp"))) - ;; (remove-text-properties beg end '(block-token nil font nil)) - ;; (web-mode-scan-block beg end) - ;; ) - (t - (web-mode-scan-blocks beg end) - (web-mode-scan-tags beg end) - (web-mode-scan-parts beg end) - ) - ) ;cond - (web-mode-trace "web-mode-scan-region") - )))))) - -;;(defvar web-mode-aa t) - -(defun web-mode-highlight-region (beg end &optional content-type) - "Identify code blocks (clientside and serverside) and syntactic symbols (strings/comments)." - (interactive) - (web-mode-with-silent-modifications - (save-excursion - (save-restriction - (save-match-data - (let ((inhibit-modification-hooks t) - (inhibit-point-motion-hooks t) - (inhibit-quit t)) - (setq beg (if web-mode-is-narrowed 1 beg)) - (remove-text-properties beg end '(font-lock-face nil)) - (cond - ((member web-mode-content-type '("javascript" "json" "css")) - (web-mode-highlight-part beg end) - (web-mode-highlight-blocks beg end)) - ((string= web-mode-engine "none") - (web-mode-highlight-tags beg end) - (web-mode-highlight-parts beg end)) - ;; ((and content-type (member content-type '("css"))) - ;; (web-mode-highlight-part beg end) - ;; (web-mode-highlight-blocks beg end)) - ;; ((and content-type (member content-type '("asp"))) - ;; (web-mode-highlight-block beg end) - ;; ) - (t - (web-mode-highlight-tags beg end) - (web-mode-highlight-parts beg end) - (web-mode-highlight-blocks beg end)) - ) ;cond - (when web-mode-enable-whitespaces - (web-mode-highlight-whitespaces beg end)) - )))))) - -(defun web-mode-scan-blocks (reg-beg reg-end) - "Identifies blocks (with block-side, block-beg, block-end text properties)." - (save-excursion - - (let ((i 0) open close closing-string start sub1 sub2 pos tagopen l tmp delim-open delim-close) - - (goto-char reg-beg) - - ;; (message "%S: %Sx%S" (point) reg-beg reg-end) - ;; (message "regexp=%S" web-mode-block-regexp) - (while (and (< i 1200) - (> reg-end (point)) - (re-search-forward web-mode-block-regexp reg-end t)) - - (setq i (1+ i) - closing-string nil - close nil - tagopen (match-string 0) - open (match-beginning 0) - delim-open nil - delim-open close - pos nil) - (setq l (length tagopen)) - - (when (member (string-to-char tagopen) '(?\s ?\t)) - (setq tagopen (replace-regexp-in-string "\\`[ \t]*" "" tagopen)) -;; (message "tagopen=%s (%S)" tagopen (point)) - (setq open (+ open (- l (length tagopen)))) - (setq l (length tagopen)) - ) - - (setq sub1 (substring tagopen 0 1) - sub2 (substring tagopen 0 (if (>= l 2) 2 1))) - - (cond - - ((string= web-mode-engine "php") - (unless (member (char-after (point)) '(?\x ?\X)) ;; (looking-at-p "xml ") - (setq closing-string '("<\\?". "\\?>"))) - (cond - ((eq (char-after (+ (point) 2)) ?\=) - (setq delim-open "") - ) ;php - - ((string= web-mode-engine "django") - (cond - ((string= sub2 "{{") - (setq closing-string '("{{" . "}}"))) - ((string= sub2 "{%") - (setq closing-string "%}")) - (t - (setq closing-string "#}")) - ) - ) ;django - - ((string= web-mode-engine "mako") - (cond - ((member tagopen '("<% " "<%!")) - (setq closing-string "%>")) - ((member sub2 '("<%" "")) - ((string= sub2 "${") - (setq closing-string "}")) - (t - (setq closing-string "EOL")) - ) - ) ;mako - - ((string= web-mode-engine "ctemplate") - (setq closing-string "}}") - ) ;ctemplate - - ((or (string= web-mode-engine "asp") - (string= web-mode-engine "aspx")) - (setq closing-string "%>") - ) ;asp - - ((string= web-mode-engine "blade") - (cond - ((string= tagopen "{{-") - (setq closing-string "--}}")) - ((string= sub2 "{{") - (setq closing-string "}}")) - ((string= sub1 "@") - (setq closing-string "EOL")) - ) - ) ;blade - - ((string= web-mode-engine "smarty") -;; (message "l=%S tagopen=%S" l tagopen) - (setq l (length (web-mode-engine-delimiter-open web-mode-engine "{"))) - (setq tagopen (substring-no-properties tagopen 0 l)) - (cond - ((string= tagopen (concat (web-mode-engine-delimiter-open web-mode-engine "{") "*")) - (setq closing-string (concat "*" (web-mode-engine-delimiter-close web-mode-engine "}")))) - ((string= tagopen (concat (web-mode-engine-delimiter-open web-mode-engine "{") "#")) - (setq closing-string (concat "#" (web-mode-engine-delimiter-close web-mode-engine "}")))) - (t - (setq closing-string (web-mode-engine-delimiter-close web-mode-engine "}"))) - ) - ) ;smarty - - ((string= web-mode-engine "web2py") - (setq closing-string "}}") - ) ;web2py - - ((string= web-mode-engine "dust") - (cond - ((string= sub2 "{!") - (setq closing-string "!}")) - (t - (setq closing-string "}") - ) - ) - ) ;dust - - ((string= web-mode-engine "closure") - (cond - ((string= sub2 "//") - (setq closing-string "EOL") - ) - ((string= sub2 "/*") - (setq closing-string "*/") - ) - (t - (setq closing-string "}") - ) - ) - ) ;closure - - ((string= web-mode-engine "ctemplate") - (cond - ((string= tagopen "{{{") - (setq closing-string "}}}")) - (t - (setq closing-string "}}")) - ) - ) ;ctemplate - - ((string= web-mode-engine "go") - (setq closing-string "}}") - ) ;go - - ((string= web-mode-engine "angular") - (setq closing-string "}}") - ) ;angular - - ((string= web-mode-engine "erb") - (cond - ((string= sub2 "<%") - (setq closing-string "%>")) - (t - (setq closing-string "EOL")) - ) - ) ;erb - - ((string= web-mode-engine "mason") - (cond - ((member tagopen '("<%def" "") - ) - ((> (length tagopen) 4) - (setq closing-string (concat "")) - ) - ((string= sub2 "<%") - (setq closing-string "%>")) - ((string= sub2 "<&") - (setq closing-string "&>")) - (t - (setq closing-string "EOL")) - ) - ) ;mason - - ((string= web-mode-engine "jsp") - (cond - ((string= sub2 "<%") - (setq closing-string "%>")) - ((string= sub2 "${") - (setq closing-string "}")) - (t - (setq closing-string ">")) - ) - ) ;jsp - - ((string= web-mode-engine "underscore") - (setq closing-string "%>") - ) ;underscore - - ((string= web-mode-engine "template-toolkit") - (cond - ((string= sub2 "[#") - (setq closing-string "#]")) - (t - (setq closing-string "%]")) - ) - ) ;underscore - - ((string= web-mode-engine "freemarker") - (cond - ((string= sub1 "<") - (setq closing-string ">")) - ((string= sub1 "[") - (setq closing-string "]")) - (t - (setq closing-string "}")) - ) - ) ;freemarker - - ((string= web-mode-engine "velocity") - (cond - ((string= sub2 "##") - (setq closing-string "EOL")) - ((string= sub2 "#*") - (setq closing-string "*#")) - (t - (setq closing-string "EOV")) - ) - ) ;velocity - - ((string= web-mode-engine "razor") - (cond - ((string= sub2 "@@") - (forward-char 2) - (setq closing-string nil)) - ((string= sub2 "@*") - (setq closing-string "*@")) - ((string= sub1 "@") - (setq closing-string "EOR")) - ((string= sub1 "}") - (setq closing-string "EOR")) - ) - ) ;razor - - ((string= web-mode-engine "python") - (unless (looking-at-p "xml ") - (setq closing-string "?>")) - ) ;python - - ) ;cond - - (when closing-string - - (cond - - ((listp closing-string) - (if (web-mode-rsf-balanced (car closing-string) (cdr closing-string) reg-end t) - (setq close (match-end 0) - pos (point)) - (when (and (string= web-mode-engine "php") - (string= "= reg-end pos)) - ;;(message "pos(%S) : open(%S) close(%S)" pos open close) - (put-text-property open close 'block-side t) - (put-text-property open (1+ open) 'block-beg 0) - (put-text-property (1- close) close 'block-end t) - (when delim-open - (web-mode-block-delimiters-set open close delim-open delim-close)) - (if (string= web-mode-engine "razor") - (web-mode-razor-tag-exclude open close) - (web-mode-scan-block open close)) - ) - - (if pos (goto-char pos)) - - ) ;when closing-string - - ) ;while - - (cond - ((>= i 1200) - (message "** strange loop (web-mode-scan-blocks) **")) - ((string= web-mode-engine "razor") - (web-mode-process-blocks reg-beg reg-end "scan")) - ((string= web-mode-engine "django") - (web-mode-scan-django-block-comments reg-beg reg-end)) - ((string= web-mode-engine "mako") - (web-mode-scan-mako-block-comments reg-beg reg-end)) - ) ;cond - - ))) - -(defun web-mode-block-delimiters-set (reg-beg reg-end delim-open delim-close) - "Set text-property 'block-token to 'delimiter on block delimiters (e.g. )" - -;; (message "reg-beg(%S) reg-end(%S) delim-open(%S) delim-close(%S)" reg-beg reg-end delim-open delim-close) - - (put-text-property reg-beg (+ reg-beg (length delim-open)) 'block-token 'delimiter) - (when delim-close -;; (message "%S > %S" (- reg-end (length delim-close)) reg-end) - (put-text-property (- reg-end (length delim-close)) reg-end 'block-token 'delimiter) - )) - -(defun web-mode-highlight-blocks (reg-beg reg-end) - "Highlight blocks." - (web-mode-process-blocks reg-beg reg-end "highlight")) - -;;todo : passer en funcall -(defun web-mode-process-blocks (reg-beg reg-end type) - "Process blocks. The scan relies on the 'block-beg and 'block-end text-properties." - (let ((i 0) (continue t) (block-beg reg-beg) (block-end nil)) - (while continue - (setq block-end nil - i (1+ i)) - (unless (get-text-property block-beg 'block-beg) - (setq block-beg (web-mode-block-next-position block-beg))) - (when (and block-beg (< block-beg reg-end)) - (setq block-end (web-mode-block-end-position block-beg))) - (cond - ((or (null block-end) (> block-end reg-end) (> i 1200)) - (setq continue nil) - (if (> i 1200) (message "*** invalid loop (web-mode-process-blocks) ***"))) - (t - (setq block-end (1+ block-end)) - (cond - ((string= type "scan") - (web-mode-scan-block block-beg block-end)) - (t - (web-mode-highlight-block block-beg block-end)) - ) - (setq block-beg block-end) - ) - ) ;cond - ) ;while - )) - -(defun web-mode-scan-parts (reg-beg reg-end) - "Scan parts." - (web-mode-process-parts reg-beg reg-end "scan")) - -(defun web-mode-highlight-parts (reg-beg reg-end) - "Highlight parts." - (web-mode-process-parts reg-beg reg-end "highlight")) - -;;todo : passer en funcall -(defun web-mode-process-parts (reg-beg reg-end type) - "Process parts. The scan relies on the 'part-beg and 'part-end text-properties." - (let ((i 0) (continue t) (part-beg reg-beg) (part-end nil)) - (while continue - (setq part-end nil - i (1+ i)) - (unless (get-text-property part-beg 'part-side) - (setq part-beg (web-mode-part-next-position part-beg))) - (when (and part-beg (< part-beg reg-end)) - (setq part-end (web-mode-part-end-position part-beg))) - (cond - ((or (null part-end) (> part-end reg-end) (> i 1200)) - (setq continue nil) - (if (> i 1200) (message "*** invalid loop (web-mode-process-parts) ***"))) - (t - (setq part-end (1+ part-end)) - (cond - ((string= type "scan") - (web-mode-scan-part part-beg part-end)) - (t - (web-mode-highlight-part part-beg part-end)) - ) - (setq part-beg part-end) - ) - ) ;cond - ) ;while - )) - -(defun web-mode-scan-block (reg-beg reg-end) - "Scan a block." - (let (sub1 sub2 sub3 regexp props continue beg match char (flags 0)) - - ;;(message "beg=%S end=%S" reg-beg reg-end) - ;;(remove-text-properties reg-beg reg-end web-mode-scan-properties) - - (when (and (not web-mode-has-any-large-block) - (> (- reg-end reg-beg) web-mode-large-embed-threshold)) - (setq web-mode-has-any-large-block t)) - - (goto-char reg-beg) - - (setq sub1 (buffer-substring-no-properties reg-beg (+ reg-beg 1)) - sub2 (buffer-substring-no-properties reg-beg (+ reg-beg 2)) - sub3 (buffer-substring-no-properties reg-beg (+ reg-beg (if (>= (point-max) (+ reg-beg 3)) 3 2)))) - - (cond - - ((string= web-mode-engine "php") - (setq regexp "//\\|/\\*\\|\"\\|'\\|<<<['\"]?\\([[:alnum:]]+\\)['\"]?") - (setq flags (logior flags 1)) - ) ;php - - ((string= web-mode-engine "django") - (cond - ((member sub2 '("{{" "{%")) - (setq regexp "\"\\|'")) - ((string= sub2 "{#") - (setq props '(block-token comment))) - ) - ) ;django - - ((string= web-mode-engine "ctemplate") - (cond - ((string= sub3 "{{%") - (setq regexp "\"\\|'")) - ((string= sub3 "{{!") - (setq props '(block-token comment))) - ) - ) ;ctemplate - - ((string= web-mode-engine "go") - (cond - ((string= sub3 "{{/") - (setq props '(block-token comment))) - ((string= sub2 "{{") - (setq regexp "\"\\|'")) - ) - ) ;go - - ((string= web-mode-engine "razor") - (cond - ((string= sub2 "@*") - (setq props '(block-token comment))) - (t - (setq regexp "//\\|\"\\|'")) - ) - ) ;razor - - ((string= web-mode-engine "mako") - (setq regexp "\"\\|'\\|#") - ) ;mako - - ((string= web-mode-engine "python") - (setq regexp "\"\\|'\\|#") - ) ;python - - ((string= web-mode-engine "web2py") - (setq regexp "\"\\|'") - ) ;web2py - - ((string= web-mode-engine "blade") - (cond - ((string= sub3 "{{-") - (setq props '(block-token comment))) - (t - (setq regexp "\"\\|'")) - ) - ) ;blade - - ((string= web-mode-engine "velocity") - (cond - ((member sub2 '("##" "#*")) - (setq props '(block-token comment))) - ((string= sub1 "$") - (setq regexp "\"\\|'")) - ((string= sub1 "#") - (setq regexp "\"\\|'")) - ) - ) ;velocity - - ((string= web-mode-engine "jsp") - (cond - ((string= sub3 "<%-") - (setq props '(block-token comment))) - ((string= sub3 "<%@") - (setq regexp "/\\*")) - ((member sub2 '("${" "#{")) - (setq regexp "\"\\|'")) - ((string= sub2 "<%") - (setq regexp "//\\|/\\*\\|\"\\|'")) - ) - ) ;jsp - - ((string= web-mode-engine "freemarker") - (cond - ((member sub3 '("<#-" "[#-")) - (setq props '(block-token comment))) - ((member sub2 '("${" "#{")) - (setq regexp "\"\\|'")) - ((or (member sub2 '("<@" "[@" "<#" "[#")) - (member sub3 '("= (point-max) (+ reg-beg 3)) 3 2)))) - ) - - (cond - - ((eq (get-text-property reg-beg 'block-token) 'comment) - (put-text-property reg-beg reg-end 'font-lock-face 'web-mode-comment-face) - ) ;comment block - - (web-mode-engine-font-lock-keywords - (setq keywords web-mode-engine-font-lock-keywords) - ) - - ((string= web-mode-engine "django") - (cond - ((string= sub2 "{{") - (setq keywords web-mode-django-expr-font-lock-keywords)) - ((string= sub2 "{%") - (setq keywords web-mode-django-code-font-lock-keywords)) - )) ;django - - ((string= web-mode-engine "mako") - (cond - ((member sub3 '("<% " "<%\n" "<%!")) - (setq keywords web-mode-mako-block-font-lock-keywords)) - ((string= sub2 "% ") - (setq keywords web-mode-mako-block-font-lock-keywords)) - ((member sub2 '("<%" " (logand flags 1) 0)) - (setq end reg-beg) - (while continue -;; (message "end=%S %S" end (get-text-property end 'block-token)) - (if (and (= reg-beg end) - (eq (get-text-property end 'block-token) 'delimiter)) - (setq beg end) - (setq beg (next-single-property-change end 'block-token)) - ) - (setq end nil) - (when beg (setq char (char-after beg))) - (if (and beg (< beg reg-end)) - (progn - (setq token-type (get-text-property beg 'block-token)) - (setq face (cond - ((eq token-type 'string) 'web-mode-block-string-face) - ((eq token-type 'comment) 'web-mode-block-comment-face) - (t 'web-mode-block-delimiter-face))) - (setq end (next-single-property-change beg 'block-token)) - (if (and end (<= end reg-end)) - (progn - (remove-text-properties beg end '(face nil)) - (put-text-property beg end 'font-lock-face face)) - (setq continue nil - end nil) - ) ;if end - ) ;progn beg - (setq continue nil - end nil) - ) ;if beg - (when (and beg end) - (save-match-data - (when (and web-mode-enable-heredoc-fontification - (eq char ?\<) - (> (- end beg) 8) - ;; (progn (message "ici%S" (buffer-substring-no-properties beg end)) t) - ;; (member web-mode-engine '("php")) - (> (logand flags 2) 0) - (string-match-p "JS\\|JAVASCRIPT\\|HTM\\|CSS" (buffer-substring-no-properties beg end))) - (setq keywords (if (eq ?H (char-after (+ beg 3))) - web-mode-html-font-lock-keywords - web-mode-javascript-font-lock-keywords)) -;; (remove-text-properties beg end '(font-lock-face nil)) - (web-mode-fontify-region beg end keywords) - )) -;; (message "%S %c %S beg=%S end=%S" web-mode-enable-string-interpolation char web-mode-engine beg end) - (when (and web-mode-enable-string-interpolation - (member char '(?\" ?\<)) - (member web-mode-engine '("php" "erb")) - (> (- end beg) 4)) - (web-mode-interpolate-string beg end)) - (when (and web-mode-enable-comment-keywords - (eq token-type 'comment) - (> (- end beg) 3)) - (web-mode-interpolate-comment beg end t) - ) ;when - ) ;when beg end - ) ;while - ) ;when keywords - - (when (and (member web-mode-engine '("jsp" "mako")) - (> (- reg-end reg-beg) 12) - (eq ?\< (char-after reg-beg))) - (web-mode-interpolate-block-tag reg-beg reg-end)) - - (when web-mode-enable-block-face - (font-lock-append-text-property reg-beg reg-end 'face 'web-mode-block-face)) - - )) - -(defun web-mode-scan-mako-block-comments (reg-beg reg-end) - "Scan extra" - (save-excursion - (let (beg end) - (goto-char reg-beg) - (while (and (< (point) reg-end) - (re-search-forward "<%doc>" reg-end t)) - (goto-char (match-beginning 0)) - (setq beg (point)) - (when (re-search-forward "" reg-end t) - (setq end (point)) - (remove-text-properties beg end web-mode-scan-properties) - (add-text-properties beg end '(block-side t block-token comment)) - (put-text-property beg (1+ beg) 'block-beg t) - (put-text-property (1- end) end 'block-end t) - ) ;when - ) ;while - ))) - -(defun web-mode-scan-django-block-comments (reg-beg reg-end) - "Scan extra" - (save-excursion - (let (beg end) - (goto-char reg-beg) - (while (and (< (point) reg-end) - (re-search-forward "{% comment %}" reg-end t)) - (setq beg (point)) - (goto-char (1+ (match-beginning 0))) - (when (web-mode-match-django-block) - (setq end (1- (point))) - (remove-text-properties beg end web-mode-scan-properties) - (add-text-properties beg end '(block-token comment font-lock-face web-mode-comment-face)) - ) - ) - ))) - -(defun web-mode-interpolate-block-tag (beg end) - "Scan a block tag (jsp / mako) to fontify ${ } blocks" - (save-excursion - (goto-char (+ 4 beg)) - (setq end (1- end)) - (while (re-search-forward "${.*}" end t) - (remove-text-properties (match-beginning 0) (match-end 0) '(font-lock-face nil)) - (web-mode-fontify-region (match-beginning 0) (match-end 0) - web-mode-uel-font-lock-keywords) - ) - )) - -;; todo : parsing plus compliqué: {$obj->values[3]->name} -(defun web-mode-interpolate-string (beg end) - "Interpolate php/erb strings." - (save-excursion - (goto-char (1+ beg)) - (setq end (1- end)) - (cond - ((string= web-mode-engine "php") - (while (re-search-forward "$[[:alnum:]_]+\\(->[[:alnum:]_]+\\)*\\|{[ ]*$.+}" end t) - ;;web-mode-php-var-interpolation-font-lock-keywords -;; (message "la%S" (point)) - (remove-text-properties (match-beginning 0) (match-end 0) '(font-lock-face nil)) - (web-mode-fontify-region (match-beginning 0) (match-end 0) - web-mode-php-var-interpolation-font-lock-keywords) - - ;; (put-text-property (match-beginning 0) (match-end 0) - ;; 'font-lock-face nil) - ;; (put-text-property (1+ (match-beginning 0)) (match-end 0) - ;; 'font-lock-face 'web-mode-variable-name-face) - - )) - ((string= web-mode-engine "erb") - (while (re-search-forward "#{.*}" end t) - (remove-text-properties (match-beginning 0) (match-end 0) '(font-lock-face nil)) - (put-text-property (match-beginning 0) (match-end 0) - 'font-lock-face 'web-mode-variable-name-face) - )) - ) ;cond - )) - -(defun web-mode-interpolate-comment (beg end block-side) - "Interpolate comment" - (save-excursion - (let (regexp) - (goto-char beg) - (setq regexp (concat "\\<\\(" web-mode-comment-keywords "\\)\\>")) - (while (re-search-forward regexp end t) - (font-lock-prepend-text-property (match-beginning 1) (match-end 1) - 'font-lock-face - 'web-mode-comment-keyword-face) - ) - ))) - -;;todo : -;; tag-type : start / end / void / comment / cdata / doctype / declaration -;; tag-name uniquement sur les html tag - -;; piste d'optim : associer tagname à 'tag-end - -;; flags -;; (1)attrs (2)custom (4)slash-beg (8)slash-end (16)brackend-end - -;; http://dev.w3.org/html5/html-author/#tags -;; http://www.w3schools.com/jsref/prop_node_nodetype.asp -;; start-tag, end-tag, tag-name, element (
xsx, an element is delimited by tags), void-element -;; http://www.w3.org/TR/html-markup/syntax.html#syntax-elements -(defun web-mode-scan-tags (reg-beg reg-end) - "Scan html nodes (tags/attrs/comments/doctype)." - (save-excursion - (let (part-beg part-end flags limit close-expr props tname tbeg tend tstop element-content-type attrs-end close-found is-tag slash-beg slash-end regexp regexp1 regexp2) - - (setq regexp1 "<\\(/?[[:alpha:]][[:alnum:]-]*\\|!--\\|!\\[CDATA\\[\\|!doctype\\|\?xml\\)" - regexp2 "<\\(/?[[:alpha:]][[:alnum:]-]*\\|!--\\|!\\[CDATA\\[\\)") - - (setq regexp regexp1) - - (goto-char reg-beg) - - (while (web-mode-rsf-client regexp reg-end t) - - (setq flags 0 - tname (downcase (match-string-no-properties 1)) - tbeg (match-beginning 0) - tend nil - tstop (point) - element-content-type nil - limit reg-end - part-beg nil - part-end nil - props nil - close-expr ">" - close-found nil - is-tag nil - slash-beg nil - slash-end nil) - - (cond - ((string= tname "!--") - (setq close-expr "-->" - props '(tag-type comment))) - ((string= tname "?xml") - (setq regexp regexp2 - close-expr "?>" - props '(tag-type declaration))) - ((string= tname "![cdata[") - (setq close-expr "]]>" - props '(tag-type cdata))) - ((string= tname "!doctype") - (setq regexp regexp2 - props '(tag-type doctype))) - (t - (setq is-tag t) - (when (string-match-p "-" tname) - (setq flags (logior flags 2))) - (cond - ((eq ?\/ (aref tname 0)) - (setq props (list 'tag-name (substring tname 1) 'tag-type 'end) - slash-beg t - flags (logior flags 4)) - (setq limit (if (> reg-end (line-end-position)) (line-end-position) reg-end)) - ) - ((web-mode-is-void-element tname) - (setq props (list 'tag-name tname 'tag-type 'void)) - ) - (t - (setq props (list 'tag-name tname 'tag-type 'start)) - ) - ) ;cond - ) ;t - ) ;cond - - (if (web-mode-sf-client close-expr limit t) - (progn - (setq attrs-end (- (point) (length close-expr)) - tend (point) - flags (logior flags 16) - close-found t) - (when (eq ?\/ (char-after (- (point) 2))) - (setq attrs-end (1- attrs-end) - props (plist-put props 'tag-type 'void) - slash-end t - flags (logior flags 8))) - ) ;progn - (setq attrs-end (line-end-position) - tend (line-end-position)) - ) ;if - - (cond - ((string= tname "script") - (let (script) - (setq script (buffer-substring-no-properties tbeg tend)) - (cond - ((string-match-p " type[ ]*=[ ]*[\"']text/\\(x-handlebars\\|html\\|ng-template\\)" script) - (setq element-content-type "html")) - ((string-match-p " type[ ]*=[ ]*[\"']application/\\(ld\\+json\\|json\\)" script) - (setq element-content-type "json")) - (t - (setq element-content-type "javascript")) - ) - ;; (message "tag=%S : %S" tname element-content-type) - ) - ) ;case script - ((string= tname "style") - (setq element-content-type "css") - ) - ) - - ;; (message "tag=%S (%S > %S)\n%S" tname tbeg tend props) - (add-text-properties tbeg tend props) - -;; (when is-tag - - (when (and is-tag - (not slash-beg) - (> (- attrs-end tstop) 2) - (> (web-mode-scan-attrs tstop attrs-end) 0)) - (setq flags (logior flags 1))) - - ;; (progn - (put-text-property tbeg (1+ tbeg) 'tag-beg flags) - ;; (when close-found - (put-text-property (1- tend) tend 'tag-end t) - ;; ) - ;; ) ;progn - ;; (add-text-properties tbeg (1+ tbeg) '(tag-beg t)) - ;; (add-text-properties (1- tend) tend '(tag-end t)) -;; ) - - (when (and is-tag close-found) - - (cond - ((and (string= tname "script") - (member element-content-type '("javascript" "json"))) - (setq close-expr "")) - ((string= tname "style") - (setq close-expr "")) - (t - (setq close-expr nil)) - ) - - ;; si