forked from jrockway/elisp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
2,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
In Emacs, this file should be read in -*- Outline -*- mode. | ||
$Id: AUTHORS 17069 2009-02-10 08:30:51Z nielsen $ | ||
|
||
Below is a list of people who have made changes or contributed to the | ||
scala emacs mode. | ||
|
||
* Main mode developers | ||
** Michel Schinz <Michel.Schinz at epfl.ch> | ||
** Anders Bach Nielsen <andersbach.nielsen at epfl.ch> | ||
|
||
|
||
* Contributions | ||
** Iulian Dragos <dragos at epfl.ch> | ||
** Stephane Micheloud <michelou at epfl.ch> | ||
** Victor Rodriguez <victorr at gmail.com> | ||
** ? <cwitty at newtonlabs.com> | ||
** Hemant Kumar <gethemant at gmail.com> | ||
** Ulrick Müller <ulm@gentoo.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
-*- Outline -*- | ||
$Id: FUTURE 16681 2008-12-01 22:17:46Z nielsen $ | ||
|
||
* Here is a list of future improvements to the scala mode | ||
|
||
** Automatic indentation should work in all cases | ||
|
||
|
||
Automatic indentation is incredibly basic and doesn't work correctly | ||
in many situations, including: | ||
|
||
- multi-line "case" statements, e.g. | ||
|
||
case Pair(x,y) => | ||
Console.println(x); | ||
Console.println(y); // not indented correctly | ||
|
||
- multi-line "case" patterns, e.g. | ||
|
||
case 'a' | 'b' | 'c' | ||
| 'd' | 'e' | 'f' // not indented correctly | ||
|
||
- multi-line comments, e.g. | ||
|
||
/* | ||
* // not indented correctly | ||
*/ // not indented correctly | ||
|
||
- other cases of single-line constructs as soon as they span | ||
multiple lines. | ||
|
||
** Implement customize variable to toggle smart indent on/off | ||
|
||
** Create templates for normal and scaladoc comments (with menu and shurtcut) | ||
|
||
** Scaladoc font-lock mode | ||
|
||
** Support for XEmacs | ||
|
||
** Add support for Flymode | ||
|
||
(require 'scala-mode) | ||
(require 'compile) | ||
(require 'flymake) | ||
(require 'font-lock) | ||
|
||
(defvar scala-build-commad nil) | ||
(make-variable-buffer-local 'scala-build-command) | ||
|
||
(add-hook 'scala-mode-hook | ||
(lambda () | ||
(flymake-mode-on) | ||
)) | ||
|
||
(defun flymake-scala-init () | ||
(let* ((text-of-first-line (buffer-substring-no-properties (point-min) (min 20 (point-max))))) | ||
(progn | ||
(remove-hook 'after-save-hook 'flymake-after-save-hook t) | ||
(save-buffer) | ||
(add-hook 'after-save-hook 'flymake-after-save-hook nil t) | ||
(if (string-match "^//script" text-of-first-line) | ||
(list "fsc" (list "-Xscript" "MainScript" "-d" "c:/tmp" buffer-file-name)) | ||
(or scala-build-command (list "fsc" (list "-d" "c:/tmp" buffer-file-name)))) | ||
))) | ||
|
||
(push '(".+\\.scala$" flymake-scala-init) flymake-allowed-file-name-masks) | ||
(push '("^\\(.*\\):\\([0-9]+\\): error: \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns) | ||
|
||
(set (make-local-variable 'indent-line-function) 'scala-indent-line) | ||
|
||
(defun scala-indent-line () | ||
"Indent current line of Scala code." | ||
(interactive) | ||
(indent-line-to (max 0 (scala-calculate-indentation)))) | ||
|
||
(defun scala-calculate-indentation () | ||
"Return the column to which the current line should be indented." | ||
(save-excursion | ||
(scala-maybe-skip-leading-close-delim) | ||
(let ((pos (point))) | ||
(beginning-of-line) | ||
(if (not (search-backward-regexp "[^\n\t\r ]" 1 0)) | ||
0 | ||
(progn | ||
(scala-maybe-skip-leading-close-delim) | ||
(+ (current-indentation) (* 2 (scala-count-scope-depth (point) pos)))))))) | ||
|
||
(defun scala-maybe-skip-leading-close-delim () | ||
(beginning-of-line) | ||
(forward-to-indentation 0) | ||
(if (looking-at "\\s)") | ||
(forward-char) | ||
(beginning-of-line))) | ||
|
||
(defun scala-face-at-point (pos) | ||
"Return face descriptor for char at point." | ||
(plist-get (text-properties-at pos) 'face)) | ||
|
||
(defun scala-count-scope-depth (rstart rend) | ||
"Return difference between open and close scope delimeters." | ||
(save-excursion | ||
(goto-char rstart) | ||
(let ((open-count 0) | ||
(close-count 0) | ||
opoint) | ||
(while (and (< (point) rend) | ||
(progn (setq opoint (point)) | ||
(re-search-forward "\\s)\\|\\s(" rend t))) | ||
(if (= opoint (point)) | ||
(forward-char 1) | ||
(cond | ||
|
||
;; Use font-lock-mode to ignore strings and comments | ||
((scala-face-at-point (- (point) 1))) | ||
|
||
((looking-back "\\s)") | ||
(incf close-count)) | ||
((looking-back "\\s(") | ||
(incf open-count)) | ||
))) | ||
(- open-count close-count)))) | ||
|
||
|
||
(provide 'scala-extensions) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
############################################################-*-Makefile-*-#### | ||
# Makefile for compiling the major mode of Emacs | ||
############################################################################## | ||
# $Id: Makefile 16681 2008-12-01 22:17:46Z nielsen $ | ||
|
||
############################################################################## | ||
# Configuration | ||
|
||
ROOT = . | ||
|
||
SOURCE_DIR = $(ROOT) | ||
|
||
############################################################################## | ||
# Variables | ||
|
||
# Emacs Lisp | ||
ELISP_COMMAND ?= emacs | ||
ELISP_OPTIONS += -batch -no-site-file | ||
ELISP_OPTIONS += -L $(ROOT) | ||
ELISP_OPTIONS += -f batch-byte-compile | ||
|
||
|
||
ELISP_FILES += scala-mode | ||
ELISP_FILES += scala-mode-auto | ||
ELISP_FILES += scala-mode-inf | ||
ELISP_FILES += scala-mode-indent | ||
ELISP_FILES += scala-mode-navigation | ||
ELISP_FILES += scala-mode-lib | ||
ELISP_FILES += scala-mode-ui | ||
ELISP_FILES += scala-mode-fontlock | ||
ELISP_FILES += scala-mode-constants | ||
ELISP_FILES += scala-mode-feature | ||
ELISP_FILES += scala-mode-feature-electric | ||
ELISP_FILES += scala-mode-feature-speedbar | ||
ELISP_FILES += scala-mode-feature-tags | ||
|
||
ELISP_SOURCES += $(ELISP_FILES:%=$(SOURCE_DIR)/%.el) | ||
|
||
############################################################################## | ||
|
||
RM ?= rm -f | ||
TOUCH ?= touch | ||
|
||
############################################################################## | ||
# Commands | ||
|
||
all: .latest-build | ||
|
||
clean: | ||
$(RM) *.elc .latest-* autoloads.el | ||
|
||
.PHONY: all | ||
.PHONY: clean | ||
|
||
############################################################################## | ||
# Rules | ||
|
||
.latest-build: $(ELISP_SOURCES) | ||
$(ELISP_COMMAND) $(ELISP_OPTIONS) $(ELISP_SOURCES) | ||
@$(TOUCH) $@ | ||
|
||
############################################################################## | ||
|
||
autoloads: $(ELISP_SOURCES) | ||
emacs -batch -q --no-site-file --eval "(setq make-backup-files nil)" --eval "(setq generated-autoload-file (expand-file-name \"autoloads.el\"))" -f batch-update-autoloads `pwd` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
In Emacs, this file should be read in -*- Outline -*- mode. | ||
|
||
* Introduction | ||
|
||
This directory contains the Emacs mode for Scala programs. This mode | ||
works only in GNU Emacs 21.1 or later. In particular, it doesn't work | ||
on any version of XEmacs, or any 20.x version of GNU Emacs. | ||
|
||
The mode is currently very basic, and offers: | ||
|
||
*** Basic syntax highlighting. | ||
*** Primitive automatic indentation. | ||
*** Support for interaction with the Scala interpreter. | ||
*** Minor mode for inserting ([{" in pairs. | ||
(scala-mode-electric) | ||
*** Tags support in Scala mode for creating, loading and completion using tags files. | ||
The current implementation works with exuberant ctags (http://ctags.sf.net) | ||
Please see the contrib/ directory for more information. | ||
*** Simple interaction with speedbar with support for scala files. | ||
Using the speedbar it is possible to get an overview of the scala | ||
files and using the emacs tags support, to get an overview of the | ||
tags in a scala file. | ||
For this to work please install CEDET (http://cedet.sf.net) | ||
*** The Scala mode has been cleaned up to work better with yasnippet from | ||
(http://code.google.com/p/yasnippet/). This replaces the old template stuff | ||
and the work on scaladoc. | ||
|
||
* Installation | ||
|
||
Put all ".el" files in a location where Emacs can find them, i.e. a | ||
directory appearing in the "load-path" variable. | ||
|
||
(add-to-list 'load-path "/path/to/some/directory/scala-mode") | ||
|
||
It is recommended, but not required to compile all ".el" files to | ||
".elc" files. This will improve load time in emacs of the scala | ||
mode. On Linux/UNIX simply run "make" in the scala mode directory. | ||
|
||
Add the following line to your Emacs startup file, usually "~/.emacs": | ||
|
||
(require 'scala-mode-auto) | ||
|
||
If you want to use yasnippets with the scala mode there are some things you need to do. | ||
First of all install yasnippets from http://code.google.com/p/yasnippet/ (the non-bundle version) | ||
|
||
Now add the following to your .emacs file to pick up the scala snippets | ||
|
||
(setq yas/my-directory "/path/to/some/directory/scala-mode/contrib/yasnippet/snippets") | ||
(yas/load-directory yas/my-directory) | ||
|
||
And then add this to your .emacs file | ||
|
||
(add-hook 'scala-mode-hook | ||
'(lambda () | ||
(yas/minor-mode-on) | ||
)) | ||
|
||
Restart Emacs or evaluate the above line. | ||
|
||
From that point on, loading a file whose name ends in ".scala" | ||
automatically turns Scala mode on. It can also be turned on manually | ||
using the "scala-mode" command. | ||
|
||
The get the best expirience from using the scala mode in emacs, please | ||
visit the costumization options for the scala mode. | ||
|
||
|
||
* Future plans | ||
|
||
See FUTURE file for a list of future enhancements to the scala emacs | ||
mode. If there is something missing, please post comment on | ||
scala-tools@listes.epfl.ch. | ||
|
||
|
||
* Version | ||
|
||
$Id: README 16681 2008-12-01 22:17:46Z nielsen $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
In Emacs, this file should be read in -*- Outline -*- mode. | ||
|
||
* Contribution | ||
|
||
** Exuberant Ctags | ||
|
||
To let ctags know how to parse scala files, put the content of | ||
dot-ctags into your $HOME/.ctags file. This will parse scala files and | ||
give the following kinds. | ||
|
||
Scala | ||
c classes | ||
o objects | ||
t traits | ||
m case-classes | ||
a abstract-classes | ||
f functions | ||
V values | ||
v variables | ||
T types | ||
|
||
The default in the scala mode is to parse scala files for all the | ||
above kinds to produce tags. This can give a rather huge amount of | ||
tags in speedbar for a scala file. This can be reduced by adding | ||
|
||
--Scala-kinds=[+|-]kinds | ||
|
||
where kinds are the one letter abbrevs above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--langdef=Scala | ||
--langmap=Scala:.scala | ||
--regex-Scala=/^[^\*\/]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/ | ||
--regex-Scala=/^[^\*\/]*object[ \t]*([a-zA-Z0-9_]+)/\1/o,objects/ | ||
--regex-scala=/^[^\*\/]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/ | ||
--regex-Scala=/^[^\*\/]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/m,case-classes/ | ||
--regex-Scala=/^[^\*\/]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,abstract-classes/ | ||
--regex-Scala=/^[^\*\/]*def[ \t]*([a-zA-Z0-9_]+)[ \t]*.*[:=]/\1/f,functions/ | ||
--regex-Scala=/^[^\*\/]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/ | ||
--regex-Scala=/^[^\*\/]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/ | ||
--regex-Scala=/^[^\*\/]*type[ \t]*([a-zA-Z0-9_]+)[ \t]*[\[<>=]/\1/T,types/ |
Oops, something went wrong.