Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
Fabián Ezequiel Gallina committed May 21, 2009
1 parent fdf60ce commit b60dc9f
Show file tree
Hide file tree
Showing 10 changed files with 7,832 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions README
@@ -0,0 +1,86 @@
This package contains multi-web-mode.

0. Info

Author: Fabián Ezequiel Gallina
Contact: fgallina at caffeinegroup dot com dot ar
Project homepage: http://github.com/fgallina/multi-web-mode
Wiki: http://github.com/fgallina/multi-web-mode/wikis
My Blog: http://www.caffeinegroup.com.ar
Downloads page: http://github.com/fgallina/multi-web-mode/downloads

1. Introduction

Multi Web Mode is a minor mode wich makes web editing in Emacs much
easier.

Basically what it does is select the appropiate major mode
automatically when you move the point and also calculates the
correct indentation of chunks according to the indentation of the
most relevant major mode.

2. Requirements

You don't need any special libraries to run this package since it
includes already all the necessary major-modes and extras.

Regarding the version of Emacs, this package was tested successfully
with 22.1 and 23.0.60.

3. Installation

To install Multi Web Mode just put
(load "<path-to-multiweb-mode>/load.el") in your .emacs file and
you are done.

Restart Emacs or use M-x load-file ~/.emacs.

4. Usage

Multi Web Mode binds the following keystrokes:

[12] : Sets the major mode to the correct one according to the
chunk where the point is located.

[tab] : Is bound to `mweb-indent'.

[backtab] : Deletes indentation, useful when magic indentation
`mweb-submodes-magic-indent' is nil. It deletes the number of spaces
defined in `mweb-default-submode-indent-offset'.

[M-TAB] : Calls nxml-complete.

5. Included packages

These are third party packages which are called by
multi-web-mode.el. See the license terms on the top of the files.

Major modes can be found on the `major-mode' subdirectory of the
package, the rest is on the `extras' one.

* php-mode.el: PHP major mode modified by Lennart Borgman for
nxhtml.

* espresso.el: Amazing Javascript mode with builtin support for
various frameworks.

* hexcolour.el: Hexadecimal color fontification in buffer, useful
for css-mode.

* fixme-mode.el: Highlights FIXME, TODO, and other warnings in
source code and allows fast navigation through them.

* tabkey2-mode.el: Call the command you want using tab.

6. Bug Reports

If you find a bug please report it to:
fgallina at caffeinegroup dot com dot ar

7. License

multi-web-mode.el and load.el is free software under the GPL v3,
see LICENSE file for details.

For other files included in the package check their licenses in the
top of the files.
107 changes: 107 additions & 0 deletions extras/fixme-mode.el
@@ -0,0 +1,107 @@
;;; fixme-mode.el --- Makes FIXME, TODO, etc. appear in big, angry letters
;; Filename: fixme-mode.el
;; Description: Makes source code warnings (FIXME, TODO, etc.) stand out
;; in a big way.
;; Author: Bryan Waite, based on some code found at
;; http://c2.com/cgi/wiki?FixmeComment
;; Copyright (C) 2009, Bryan Waite
;; License: MIT License (not reproduced for space reasons)
;; Compatibility: Only tested under Emacs 23 CVS.

(require 'cl)

(defconst fixme-mode-version 0.1)

(defgroup fixme-mode nil
"Highlights FIXME, TODO, and other warnings in source code"
:prefix "fixme-"
:link '(url-link "http://www.thesiteiwillonedayhave.com"))

(defcustom fixme-modes '(erlang-mode java-mode c-mode emacs-lisp-mode jde-mode
scheme-mode python-mode ruby-mode cperl-mode
slime-mode common-lisp-mode c++-mode d-mode
js2-mode haskell-mode tuareg-mode lua-mode
pascal-mode fortran-mode prolog-mode asm-mode
csharp-mode sml-mode)
"The modes which fixme should apply to"
:group 'fixme-mode)

(defcustom fixme-highlighted-words '("FIXME" "TODO" "BUG" "KLUDGE")
"Words to highlight"
:group 'fixme-mode)

(defvar fixme-keyword-re-string ""
"The regular expression to use for searching for fixme words. Generated with fixme-register-keyword-re")

(defvar fixme-keyword-font-lock '()
"Font lock keywords. Generated from fixme-register-font-lock-keywords")

(make-face 'font-lock-fixme-face)

(defun fixme-next ()
(interactive)
(lexical-let ((old-case case-fold-search))
(setq case-fold-search nil)
(search-forward-regexp fixme-keyword-re-string)
(setq case-fold-search old-case)))

(defun fixme-prev ()
(interactive)
(lexical-let ((old-case case-fold-search))
(setq case-fold-search nil)
(search-backward-regexp fixme-keyword-re-string)
(setq case-fold-search old-case)))

(defun fixme-show-all-fixmes ()
(interactive)
(let ((buf (buffer-file-name)))
(when buf
(grep (concat "grep -nH -e " (concat "\"" fixme-keyword-re-string "\" " buf))))))

(defun fixme-register-keyword-re ()
(lexical-let ((num-words (length fixme-highlighted-words))
(word-count 0))
(setq fixme-keyword-re-string "")
(dolist (word fixme-highlighted-words)
(incf word-count)
(setq fixme-keyword-re-string (concat fixme-keyword-re-string word))
(when (< word-count num-words)
(setq fixme-keyword-re-string (concat fixme-keyword-re-string "\\|"))))))

(defun fixme-register-font-lock-keywords ()
(lexical-let ((stuff '()))
(dolist (word fixme-highlighted-words)
(setq stuff (append stuff `((,(concat "\\<\\(" word "\\)") 1 'font-lock-fixme-face t)))))
(setq fixme-keyword-font-lock stuff)))

(defun fixme-register-keywords ()
(mapc (lambda (mode)
(font-lock-add-keywords
mode
fixme-keyword-font-lock))
fixme-modes)
(make-face 'font-lock-fixme-face)
(modify-face 'font-lock-fixme-face "Red" "Yellow" nil t nil t nil nil))

(defun fixme-reload-keywords ()
"Run this if you change the fixme-modes or fixme-highlighted-words variables
to update the font-lock and searching variables"
(interactive)
(fixme-register-keyword-re)
(fixme-register-font-lock-keywords)
(fixme-register-keywords)
)

(define-minor-mode fixme-mode
"A minor mode for making FIXME and other warnings stand out"
nil
" Fixme"
nil
:group fixme-mode
:version fixme-mode-version
(fixme-register-keyword-re)
(fixme-register-font-lock-keywords)
(fixme-register-keywords)
)

(provide 'fixme-mode)
37 changes: 37 additions & 0 deletions extras/hexcolour.el
@@ -0,0 +1,37 @@
;; hexadecimal colours fontification
;; http://www.emacswiki.org/emacs/HexColour

(require 'cl)


(defun hexcolour-luminance (color)
"Calculate the luminance of a color string (e.g. \"#ffaa00\", \"blue\").
This is 0.3 red + 0.59 green + 0.11 blue and always between 0 and 255."
(let* ((values (x-color-values color))
(r (car values))
(g (cadr values))
(b (caddr values)))
(floor (+ (* .3 r) (* .59 g) (* .11 b)) 256)))


(defun hexcolour-add-to-font-lock ()
(interactive)
(font-lock-add-keywords
nil `((,(concat "#[0-9a-fA-F]\\{3\\}[0-9a-fA-F]\\{3\\}?\\|"
(regexp-opt (x-defined-colors) 'words))
(0 (let ((colour (match-string-no-properties 0)))
(put-text-property
(match-beginning 0) (match-end 0)
'face `((:foreground ,(if (> 128.0 (hexcolour-luminance colour))
"white" "black"))
(:background ,colour)))))))))


(define-minor-mode hexcolour-mode
"show the color of hexadecimal values in the background of the word containing the color"
nil " HexColour" nil
(hexcolour-add-to-font-lock))


(provide 'hexcolour)
;;; hexcolour.el ends here

0 comments on commit b60dc9f

Please sign in to comment.