16 changed files with 0 additions and 11592 deletions
-
1vendor/erlang
-
15vendor/erlang-2.7.0/AUTHORS
-
55vendor/erlang-2.7.0/README
-
448vendor/erlang-2.7.0/erlang-eunit.el
-
103vendor/erlang-2.7.0/erlang-flymake.el
-
3vendor/erlang-2.7.0/erlang-pkg.el
-
1267vendor/erlang-2.7.0/erlang-skels-old.el
-
1553vendor/erlang-2.7.0/erlang-skels.el
-
121vendor/erlang-2.7.0/erlang-start.el
-
5588vendor/erlang-2.7.0/erlang.el
-
1345vendor/erlang-2.7.0/erlang_appwiz.el
-
1vendor/feature-mode
-
591vendor/groovy-mode.el
-
110vendor/melpa.el
-
253vendor/ruby-block.el
-
138vendor/ruby-end.el
@ -1 +0,0 @@ |
|||
erlang-2.7.0 |
|||
@ -1,15 +0,0 @@ |
|||
Original Authors: |
|||
The Erlang emacs mode was written by Anders Lindgren. |
|||
|
|||
Contributors: |
|||
Luke Gorrie |
|||
Dave Love |
|||
|
|||
Maintainers: |
|||
Sverker Wiberg |
|||
Kent Boortz |
|||
Björn Gustavsson |
|||
|
|||
Currently maintained by: |
|||
Ingela Anderton Andin |
|||
Dan Gudmundsson |
|||
@ -1,55 +0,0 @@ |
|||
User configuration notes |
|||
======================== |
|||
|
|||
Below is a quick guide to necessary configurations for getting |
|||
started with the Erlang mode for Emacs. Please refer to the |
|||
Users guide and reference manual in the documentation for the |
|||
Erlang/OTP application tools for more information. |
|||
|
|||
|
|||
For UNIX users |
|||
-------------- |
|||
|
|||
To set up the Erlang Emacs mode on UNIX systems, edit/create the file |
|||
.emacs in the your home directory. |
|||
|
|||
Below is a complete example of what should be added to a user's .emacs |
|||
provided that OTP is installed in the directory /usr/local/otp: |
|||
|
|||
(setq load-path (cons "/usr/local/otp/lib/tools-<ToolsVer>/emacs" |
|||
load-path)) |
|||
(setq erlang-root-dir "/usr/local/otp") |
|||
(setq exec-path (cons "/usr/local/otp/bin" exec-path)) |
|||
(require 'erlang-start) |
|||
|
|||
|
|||
For Windows users |
|||
----------------- |
|||
|
|||
To set up the Erlang Emacs mode on Windows systems, edit/create the |
|||
file .emacs, the location of the file depends on the configuration of |
|||
the system. If the HOME environment variable is set, Emacs will look |
|||
for the .emacs file in the directory indicated by the HOME |
|||
variable. If HOME is not set, Emacs will look for the .emacs file in |
|||
C:\. |
|||
|
|||
Below is a complete example of what should be added to a user's .emacs |
|||
provided that OTP is installed in the directory C:\Program |
|||
Files\erl-<Ver>: |
|||
|
|||
(setq load-path (cons "C:/Program Files/erl<Ver>/lib/tools-<ToolsVer>/emacs" |
|||
load-path)) |
|||
(setq erlang-root-dir "C:/Program Files/erl<Ver>") |
|||
(setq exec-path (cons "C:/Program Files/erl<Ver>/bin" exec-path)) |
|||
(require 'erlang-start) |
|||
|
|||
|
|||
Miscellaneous addons |
|||
-------------------- |
|||
|
|||
In order to check erlang source code on the fly, add the following |
|||
line to your .emacs file (after erlang-start, see above). See |
|||
erlang-flymake.el for more information on how to customize the syntax |
|||
check. |
|||
|
|||
(require 'erlang-flymake) |
|||
@ -1,448 +0,0 @@ |
|||
;; |
|||
;; %CopyrightBegin% |
|||
;; |
|||
;; Copyright Ericsson AB 2009-2010. All Rights Reserved. |
|||
;; |
|||
;; The contents of this file are subject to the Erlang Public License, |
|||
;; Version 1.1, (the "License"); you may not use this file except in |
|||
;; compliance with the License. You should have received a copy of the |
|||
;; Erlang Public License along with this software. If not, it can be |
|||
;; retrieved online at http://www.erlang.org/. |
|||
;; |
|||
;; Software distributed under the License is distributed on an "AS IS" |
|||
;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
|||
;; the License for the specific language governing rights and limitations |
|||
;; under the License. |
|||
;; |
|||
;; %CopyrightEnd% |
|||
;;; |
|||
;;; Purpose: Provide EUnit utilities. |
|||
;;; |
|||
;;; Author: Klas Johansson |
|||
|
|||
(eval-when-compile |
|||
(require 'cl)) |
|||
|
|||
(defvar erlang-eunit-src-candidate-dirs '("../src" ".") |
|||
"*Name of directories which to search for source files matching |
|||
an EUnit test file. The first directory in the list will be used, |
|||
if there is no match.") |
|||
|
|||
(defvar erlang-eunit-test-candidate-dirs '("../test" ".") |
|||
"*Name of directories which to search for EUnit test files matching |
|||
a source file. The first directory in the list will be used, |
|||
if there is no match.") |
|||
|
|||
(defvar erlang-eunit-autosave nil |
|||
"*Set to non-nil to automtically save unsaved buffers before running tests. |
|||
This is useful, reducing the save-compile-load-test cycle to one keychord.") |
|||
|
|||
(defvar erlang-eunit-recent-info '((mode . nil) (module . nil) (test . nil) (cover . nil)) |
|||
"Info about the most recent running of an EUnit test representation.") |
|||
|
|||
;;; |
|||
;;; Switch between src/EUnit test buffers |
|||
;;; |
|||
(defun erlang-eunit-toggle-src-and-test-file-other-window () |
|||
"Switch to the src file if the EUnit test file is the current |
|||
buffer and vice versa" |
|||
(interactive) |
|||
(if (erlang-eunit-test-file-p buffer-file-name) |
|||
(erlang-eunit-open-src-file-other-window buffer-file-name) |
|||
(erlang-eunit-open-test-file-other-window buffer-file-name))) |
|||
|
|||
;;; |
|||
;;; Open the EUnit test file which corresponds to a src file |
|||
;;; |
|||
(defun erlang-eunit-open-test-file-other-window (src-file-path) |
|||
"Open the EUnit test file which corresponds to a src file" |
|||
(find-file-other-window (erlang-eunit-test-filename src-file-path))) |
|||
|
|||
;;; |
|||
;;; Open the src file which corresponds to the an EUnit test file |
|||
;;; |
|||
(defun erlang-eunit-open-src-file-other-window (test-file-path) |
|||
"Open the src file which corresponds to the an EUnit test file" |
|||
(find-file-other-window (erlang-eunit-src-filename test-file-path))) |
|||
|
|||
;;; Return the name and path of the EUnit test file |
|||
;;, (input may be either the source filename itself or the EUnit test filename) |
|||
(defun erlang-eunit-test-filename (file-path) |
|||
(if (erlang-eunit-test-file-p file-path) |
|||
file-path |
|||
(erlang-eunit-rewrite-filename file-path erlang-eunit-test-candidate-dirs))) |
|||
|
|||
;;; Return the name and path of the source file |
|||
;;, (input may be either the source filename itself or the EUnit test filename) |
|||
(defun erlang-eunit-src-filename (file-path) |
|||
(if (erlang-eunit-src-file-p file-path) |
|||
file-path |
|||
(erlang-eunit-rewrite-filename file-path erlang-eunit-src-candidate-dirs))) |
|||
|
|||
;;; Rewrite a filename from the src or test filename to the other |
|||
(defun erlang-eunit-rewrite-filename (orig-file-path candidate-dirs) |
|||
(or (erlang-eunit-locate-buddy orig-file-path candidate-dirs) |
|||
(erlang-eunit-buddy-file-path orig-file-path (car candidate-dirs)))) |
|||
|
|||
;;; Search for a file's buddy file (a source file's EUnit test file, |
|||
;;; or an EUnit test file's source file) in a list of candidate |
|||
;;; directories. |
|||
(defun erlang-eunit-locate-buddy (orig-file-path candidate-dirs) |
|||
(when candidate-dirs |
|||
(let ((buddy-file-path (erlang-eunit-buddy-file-path |
|||
orig-file-path |
|||
(car candidate-dirs)))) |
|||
(if (file-readable-p buddy-file-path) |
|||
buddy-file-path |
|||
(erlang-eunit-locate-buddy orig-file-path (cdr candidate-dirs)))))) |
|||
|
|||
(defun erlang-eunit-buddy-file-path (orig-file-path buddy-dir-name) |
|||
(let* ((orig-dir-name (file-name-directory orig-file-path)) |
|||
(buddy-dir-name (file-truename |
|||
(filename-join orig-dir-name buddy-dir-name))) |
|||
(buddy-base-name (erlang-eunit-buddy-basename orig-file-path))) |
|||
(filename-join buddy-dir-name buddy-base-name))) |
|||
|
|||
;;; Return the basename of the buddy file: |
|||
;;; /tmp/foo/src/x.erl --> x_tests.erl |
|||
;;; /tmp/foo/test/x_tests.erl --> x.erl |
|||
(defun erlang-eunit-buddy-basename (file-path) |
|||
(let ((src-module-name (erlang-eunit-source-module-name file-path))) |
|||
(cond |
|||
((erlang-eunit-src-file-p file-path) |
|||
(concat src-module-name "_tests.erl")) |
|||
((erlang-eunit-test-file-p file-path) |
|||
(concat src-module-name ".erl"))))) |
|||
|
|||
;;; Checks whether a file is a source file or not |
|||
(defun erlang-eunit-src-file-p (file-path) |
|||
(not (erlang-eunit-test-file-p file-path))) |
|||
|
|||
;;; Checks whether a file is a EUnit test file or not |
|||
(defun erlang-eunit-test-file-p (file-path) |
|||
(erlang-eunit-string-match-p "^\\(.+\\)_tests.erl$" file-path)) |
|||
|
|||
;;; Return the module name of the source file |
|||
;;; /tmp/foo/src/x.erl --> x |
|||
;;; /tmp/foo/test/x_tests.erl --> x |
|||
(defun erlang-eunit-source-module-name (file-path) |
|||
(interactive) |
|||
(let ((module-name (erlang-eunit-module-name file-path))) |
|||
(if (string-match "^\\(.+\\)_tests$" module-name) |
|||
(substring module-name (match-beginning 1) (match-end 1)) |
|||
module-name))) |
|||
|
|||
;;; Return the module name of the file |
|||
;;; /tmp/foo/src/x.erl --> x |
|||
;;; /tmp/foo/test/x_tests.erl --> x_tests |
|||
(defun erlang-eunit-module-name (file-path) |
|||
(interactive) |
|||
(file-name-sans-extension (file-name-nondirectory file-path))) |
|||
|
|||
;;; Older emacsen don't have string-match-p. |
|||
(defun erlang-eunit-string-match-p (regexp string &optional start) |
|||
(if (fboundp 'string-match-p) ;; appeared in emacs 23 |
|||
(string-match-p regexp string start) |
|||
(save-match-data ;; fallback for earlier versions of emacs |
|||
(string-match regexp string start)))) |
|||
|
|||
;;; Join filenames |
|||
(defun filename-join (dir file) |
|||
(if (or (= (elt file 0) ?/) |
|||
(= (car (last (append dir nil))) ?/)) |
|||
(concat dir file) |
|||
(concat dir "/" file))) |
|||
|
|||
;;; Get info about the most recent running of EUnit |
|||
(defun erlang-eunit-recent (key) |
|||
(cdr (assq key erlang-eunit-recent-info))) |
|||
|
|||
;;; Record info about the most recent running of EUnit |
|||
;;; Known modes are 'module-mode and 'test-mode |
|||
(defun erlang-eunit-record-recent (mode module test) |
|||
(setcdr (assq 'mode erlang-eunit-recent-info) mode) |
|||
(setcdr (assq 'module erlang-eunit-recent-info) module) |
|||
(setcdr (assq 'test erlang-eunit-recent-info) test)) |
|||
|
|||
;;; Record whether the most recent running of EUnit included cover |
|||
;;; compilation |
|||
(defun erlang-eunit-record-recent-compile (under-cover) |
|||
(setcdr (assq 'cover erlang-eunit-recent-info) under-cover)) |
|||
|
|||
;;; Determine options for EUnit. |
|||
(defun erlang-eunit-opts () |
|||
(if current-prefix-arg ", [verbose]" "")) |
|||
|
|||
;;; Determine current test function |
|||
(defun erlang-eunit-current-test () |
|||
(save-excursion |
|||
(erlang-end-of-function 1) |
|||
(erlang-beginning-of-function 1) |
|||
(erlang-name-of-function))) |
|||
|
|||
(defun erlang-eunit-simple-test-p (test-name) |
|||
(if (erlang-eunit-string-match-p "^\\(.+\\)_test$" test-name) t nil)) |
|||
|
|||
(defun erlang-eunit-test-generator-p (test-name) |
|||
(if (erlang-eunit-string-match-p "^\\(.+\\)_test_$" test-name) t nil)) |
|||
|
|||
;;; Run one EUnit test |
|||
(defun erlang-eunit-run-test (module-name test-name) |
|||
(let ((command |
|||
(cond ((erlang-eunit-simple-test-p test-name) |
|||
(format "eunit:test({%s, %s}%s)." |
|||
module-name test-name (erlang-eunit-opts))) |
|||
((erlang-eunit-test-generator-p test-name) |
|||
(format "eunit:test({generator, %s, %s}%s)." |
|||
module-name test-name (erlang-eunit-opts))) |
|||
(t (format "%% WARNING: '%s' is not a test function" test-name))))) |
|||
(erlang-eunit-record-recent 'test-mode module-name test-name) |
|||
(erlang-eunit-inferior-erlang-send-command command))) |
|||
|
|||
;;; Run EUnit tests for the current module |
|||
(defun erlang-eunit-run-module-tests (module-name) |
|||
(let ((command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts)))) |
|||
(erlang-eunit-record-recent 'module-mode module-name nil) |
|||
(erlang-eunit-inferior-erlang-send-command command))) |
|||
|
|||
(defun erlang-eunit-compile-and-run-recent () |
|||
"Compile the source and test files and repeat the most recent EUnit test run. |
|||
|
|||
With prefix arg, compiles for debug and runs tests with the verbose flag set." |
|||
(interactive) |
|||
(case (erlang-eunit-recent 'mode) |
|||
('test-mode |
|||
(erlang-eunit-compile-and-test |
|||
'erlang-eunit-run-test (list (erlang-eunit-recent 'module) |
|||
(erlang-eunit-recent 'test)))) |
|||
('module-mode |
|||
(erlang-eunit-compile-and-test |
|||
'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module)) |
|||
(erlang-eunit-recent 'cover))) |
|||
(t (error "EUnit has not yet been run. Please run a test first.")))) |
|||
|
|||
(defun erlang-eunit-cover-compile () |
|||
"Cover compile current module." |
|||
(interactive) |
|||
(let* ((erlang-compile-extra-opts |
|||
(append (list 'debug_info) erlang-compile-extra-opts)) |
|||
(module-name |
|||
(erlang-add-quotes-if-needed |
|||
(erlang-eunit-module-name buffer-file-name))) |
|||
(compile-command |
|||
(format "cover:compile_beam(%s)." module-name))) |
|||
(erlang-compile) |
|||
(if (erlang-eunit-last-compilation-successful-p) |
|||
(erlang-eunit-inferior-erlang-send-command compile-command)))) |
|||
|
|||
(defun erlang-eunit-analyze-coverage () |
|||
"Analyze the data collected by cover tool for the module in the |
|||
current buffer. |
|||
|
|||
Assumes that the module has been cover compiled prior to this |
|||
call. This function will do two things: print the number of |
|||
covered and uncovered functions in the erlang shell and display a |
|||
new buffer called *<module name> coverage* which shows the source |
|||
code along with the coverage analysis results." |
|||
(interactive) |
|||
(let* ((module-name (erlang-add-quotes-if-needed |
|||
(erlang-eunit-module-name buffer-file-name))) |
|||
(tmp-filename (make-temp-file "cover")) |
|||
(analyze-command (format "cover:analyze_to_file(%s, \"%s\"). " |
|||
module-name tmp-filename)) |
|||
(buf-name (format "*%s coverage*" module-name))) |
|||
(erlang-eunit-inferior-erlang-send-command analyze-command) |
|||
;; The purpose of the following snippet is to get the result of the |
|||
;; analysis from a file into a new buffer (or an old, if one with |
|||
;; the specified name already exists). Also we want the erlang-mode |
|||
;; *and* view-mode to be enabled. |
|||
(save-excursion |
|||
(let ((buf (get-buffer-create (format "*%s coverage*" module-name)))) |
|||
(set-buffer buf) |
|||
(setq buffer-read-only nil) |
|||
(insert-file-contents tmp-filename nil nil nil t) |
|||
(if (= (buffer-size) 0) |
|||
(kill-buffer buf) |
|||
;; FIXME: this would be a good place to enable (emacs-mode) |
|||
;; to get some nice syntax highlighting in the |
|||
;; coverage report, but it doesn't play well with |
|||
;; flymake. Leave it off for now. |
|||
(view-buffer buf)))) |
|||
(delete-file tmp-filename))) |
|||
|
|||
(defun erlang-eunit-compile-and-run-current-test () |
|||
"Compile the source and test files and run the current EUnit test. |
|||
|
|||
With prefix arg, compiles for debug and runs tests with the verbose flag set." |
|||
(interactive) |
|||
(let ((module-name (erlang-add-quotes-if-needed |
|||
(erlang-eunit-module-name buffer-file-name))) |
|||
(test-name (erlang-eunit-current-test))) |
|||
(erlang-eunit-compile-and-test |
|||
'erlang-eunit-run-test (list module-name test-name)))) |
|||
|
|||
(defun erlang-eunit-compile-and-run-module-tests () |
|||
"Compile the source and test files and run all EUnit tests in the module. |
|||
|
|||
With prefix arg, compiles for debug and runs tests with the verbose flag set." |
|||
(interactive) |
|||
(let ((module-name (erlang-add-quotes-if-needed |
|||
(erlang-eunit-source-module-name buffer-file-name)))) |
|||
(erlang-eunit-compile-and-test |
|||
'erlang-eunit-run-module-tests (list module-name)))) |
|||
|
|||
;;; Compile source and EUnit test file and finally run EUnit tests for |
|||
;;; the current module |
|||
(defun erlang-eunit-compile-and-test (test-fun test-args &optional under-cover) |
|||
"Compile the source and test files and run the EUnit test suite. |
|||
|
|||
If under-cover is set to t, the module under test is compile for |
|||
code coverage analysis. If under-cover is left out or not set, |
|||
coverage analysis is disabled. The result of the code coverage |
|||
is both printed to the erlang shell (the number of covered vs |
|||
uncovered functions in a module) and written to a buffer called |
|||
*<module> coverage* (which shows the source code for the module |
|||
and the number of times each line is covered). |
|||
With prefix arg, compiles for debug and runs tests with the verbose flag set." |
|||
(erlang-eunit-record-recent-compile under-cover) |
|||
(let ((src-filename (erlang-eunit-src-filename buffer-file-name)) |
|||
(test-filename (erlang-eunit-test-filename buffer-file-name))) |
|||
|
|||
;; The purpose of out-maneuvering `save-some-buffers', as is done |
|||
;; below, is to ask the question about saving buffers only once, |
|||
;; instead of possibly several: one for each file to compile, |
|||
;; for instance for both x.erl and x_tests.erl. |
|||
(save-some-buffers erlang-eunit-autosave) |
|||
(flet ((save-some-buffers (&optional any) nil)) |
|||
|
|||
;; Compilation of the source file is mandatory (the file must |
|||
;; exist, otherwise the procedure is aborted). Compilation of the |
|||
;; test file on the other hand, is optional, since eunit tests may |
|||
;; be placed in the source file instead. Any compilation error |
|||
;; will prevent the subsequent steps to be run (hence the `and') |
|||
(and (erlang-eunit-compile-file src-filename under-cover) |
|||
(if (file-readable-p test-filename) |
|||
(erlang-eunit-compile-file test-filename) |
|||
t) |
|||
(apply test-fun test-args) |
|||
(if under-cover |
|||
(save-excursion |
|||
(set-buffer (find-file-noselect src-filename)) |
|||
(erlang-eunit-analyze-coverage))))))) |
|||
|
|||
(defun erlang-eunit-compile-and-run-module-tests-under-cover () |
|||
"Compile the source and test files and run the EUnit test suite and measure |
|||
code coverage. |
|||
|
|||
With prefix arg, compiles for debug and runs tests with the verbose flag set." |
|||
(interactive) |
|||
(let ((module-name (erlang-add-quotes-if-needed |
|||
(erlang-eunit-source-module-name buffer-file-name)))) |
|||
(erlang-eunit-compile-and-test |
|||
'erlang-eunit-run-module-tests (list module-name) t))) |
|||
|
|||
(defun erlang-eunit-compile-file (file-path &optional under-cover) |
|||
(if (file-readable-p file-path) |
|||
(save-excursion |
|||
(set-buffer (find-file-noselect file-path)) |
|||
;; In order to run a code coverage analysis on a |
|||
;; module, we have two options: |
|||
;; |
|||
;; * either compile the module with cover:compile instead of the |
|||
;; regular compiler |
|||
;; |
|||
;; * or first compile the module with the regular compiler (but |
|||
;; *with* debug_info) and then compile it for coverage |
|||
;; analysis using cover:compile_beam. |
|||
;; |
|||
;; We could accomplish the first by changing the |
|||
;; erlang-compile-erlang-function to cover:compile, but there's |
|||
;; a risk that that's used for other purposes. Therefore, a |
|||
;; safer alternative (although with more steps) is to add |
|||
;; debug_info to the list of compiler options and go for the |
|||
;; second alternative. |
|||
(if under-cover |
|||
(erlang-eunit-cover-compile) |
|||
(erlang-compile)) |
|||
(erlang-eunit-last-compilation-successful-p)) |
|||
(let ((msg (format "Could not read %s" file-path))) |
|||
(erlang-eunit-inferior-erlang-send-command |
|||
(format "%% WARNING: %s" msg)) |
|||
(error msg)))) |
|||
|
|||
(defun erlang-eunit-last-compilation-successful-p () |
|||
(save-excursion |
|||
(set-buffer inferior-erlang-buffer) |
|||
(goto-char compilation-parsing-end) |
|||
(erlang-eunit-all-list-elems-fulfill-p |
|||
(lambda (re) (let ((continue t) |
|||
(result t)) |
|||
(while continue ; ignore warnings, stop at errors |
|||
(if (re-search-forward re (point-max) t) |
|||
(if (erlang-eunit-is-compilation-warning) |
|||
t |
|||
(setq result nil) |
|||
(setq continue nil)) |
|||
(setq result t) |
|||
(setq continue nil))) |
|||
result)) |
|||
(mapcar (lambda (e) (car e)) erlang-error-regexp-alist)))) |
|||
|
|||
(defun erlang-eunit-is-compilation-warning () |
|||
(erlang-eunit-string-match-p |
|||
"[0-9]+: Warning:" |
|||
(buffer-substring (line-beginning-position) (line-end-position)))) |
|||
|
|||
(defun erlang-eunit-all-list-elems-fulfill-p (pred list) |
|||
(let ((matches-p t)) |
|||
(while (and list matches-p) |
|||
(if (not (funcall pred (car list))) |
|||
(setq matches-p nil)) |
|||
(setq list (cdr list))) |
|||
matches-p)) |
|||
|
|||
;;; Evaluate a command in an erlang buffer |
|||
(defun erlang-eunit-inferior-erlang-send-command (command) |
|||
"Evaluate a command in an erlang buffer." |
|||
(interactive "P") |
|||
(inferior-erlang-prepare-for-input) |
|||
(inferior-erlang-send-command command) |
|||
(sit-for 0) ;; redisplay |
|||
(inferior-erlang-wait-prompt)) |
|||
|
|||
|
|||
;;;==================================================================== |
|||
;;; Key bindings |
|||
;;;==================================================================== |
|||
|
|||
(defconst erlang-eunit-key-bindings |
|||
'(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window) |
|||
("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests) |
|||
("\C-c\C-ej" erlang-eunit-compile-and-run-current-test) |
|||
("\C-c\C-el" erlang-eunit-compile-and-run-recent) |
|||
("\C-c\C-ec" erlang-eunit-compile-and-run-module-tests-under-cover) |
|||
("\C-c\C-ev" erlang-eunit-cover-compile) |
|||
("\C-c\C-ea" erlang-eunit-analyze-coverage))) |
|||
|
|||
(defun erlang-eunit-add-key-bindings () |
|||
(dolist (binding erlang-eunit-key-bindings) |
|||
(erlang-eunit-bind-key (car binding) (cadr binding)))) |
|||
|
|||
(defun erlang-eunit-bind-key (key function) |
|||
(erlang-eunit-ensure-keymap-for-key key) |
|||
(local-set-key key function)) |
|||
|
|||
(defun erlang-eunit-ensure-keymap-for-key (key-seq) |
|||
(let ((prefix-keys (butlast (append key-seq nil))) |
|||
(prefix-seq "")) |
|||
(while prefix-keys |
|||
(setq prefix-seq (concat prefix-seq (make-string 1 (car prefix-keys)))) |
|||
(setq prefix-keys (cdr prefix-keys)) |
|||
(if (not (keymapp (lookup-key (current-local-map) prefix-seq))) |
|||
(local-set-key prefix-seq (make-sparse-keymap)))))) |
|||
|
|||
(add-hook 'erlang-mode-hook 'erlang-eunit-add-key-bindings) |
|||
|
|||
|
|||
(provide 'erlang-eunit) |
|||
;; erlang-eunit ends here |
|||
@ -1,103 +0,0 @@ |
|||
;; erlang-flymake.el |
|||
;; |
|||
;; Syntax check erlang source code on the fly (integrates with flymake). |
|||
;; |
|||
;; Start using flymake with erlang by putting the following somewhere |
|||
;; in your .emacs file: |
|||
;; |
|||
;; (require 'erlang-flymake) |
|||
;; |
|||
;; Flymake is rather eager and does its syntax checks frequently by |
|||
;; default and if you are bothered by this, you might want to put the |
|||
;; following in your .emacs as well: |
|||
;; |
|||
;; (erlang-flymake-only-on-save) |
|||
;; |
|||
;; There are a couple of variables which control the compilation options: |
|||
;; * erlang-flymake-get-code-path-dirs-function |
|||
;; * erlang-flymake-get-include-dirs-function |
|||
;; * erlang-flymake-extra-opts |
|||
;; |
|||
;; This code is inspired by http://www.emacswiki.org/emacs/FlymakeErlang. |
|||
|
|||
(require 'flymake) |
|||
(eval-when-compile |
|||
(require 'cl)) |
|||
|
|||
(defvar erlang-flymake-command |
|||
"erlc" |
|||
"The command that will be used to perform the syntax check") |
|||
|
|||
(defvar erlang-flymake-get-code-path-dirs-function |
|||
'erlang-flymake-get-code-path-dirs |
|||
"Return a list of ebin directories to add to the code path.") |
|||
|
|||
(defvar erlang-flymake-get-include-dirs-function |
|||
'erlang-flymake-get-include-dirs |
|||
"Return a list of include directories to add to the compiler options.") |
|||
|
|||
(defvar erlang-flymake-extra-opts |
|||
(list "+warn_obsolete_guard" |
|||
"+warn_unused_import" |
|||
"+warn_shadow_vars" |
|||
"+warn_export_vars" |
|||
"+strong_validation" |
|||
"+report") |
|||
"A list of options that will be passed to the compiler") |
|||
|
|||
(defun erlang-flymake-only-on-save () |
|||
"Trigger flymake only when the buffer is saved (disables syntax |
|||
check on newline and when there are no changes)." |
|||
(interactive) |
|||
;; There doesn't seem to be a way of disabling this; set to the |
|||
;; largest int available as a workaround (most-positive-fixnum |
|||
;; equates to 8.5 years on my machine, so it ought to be enough ;-) ) |
|||
(setq flymake-no-changes-timeout most-positive-fixnum) |
|||
(setq flymake-start-syntax-check-on-newline nil)) |
|||
|
|||
|
|||
(defun erlang-flymake-get-code-path-dirs () |
|||
(list (concat (erlang-flymake-get-app-dir) "ebin"))) |
|||
|
|||
(defun erlang-flymake-get-include-dirs () |
|||
(list (concat (erlang-flymake-get-app-dir) "include") |
|||
(concat (erlang-flymake-get-app-dir) "deps"))) |
|||
|
|||
(defun erlang-flymake-get-app-dir () |
|||
(let ((src-path (file-name-directory (buffer-file-name)))) |
|||
(file-name-directory (directory-file-name src-path)))) |
|||
|
|||
(defun erlang-flymake-init () |
|||
(let* ((temp-file |
|||
(flet ((flymake-get-temp-dir () (erlang-flymake-temp-dir))) |
|||
(flymake-init-create-temp-buffer-copy |
|||
'flymake-create-temp-with-folder-structure))) |
|||
(code-dir-opts |
|||
(erlang-flymake-flatten |
|||
(mapcar (lambda (dir) (list "-pa" dir)) |
|||
(funcall erlang-flymake-get-code-path-dirs-function)))) |
|||
(inc-dir-opts |
|||
(erlang-flymake-flatten |
|||
(mapcar (lambda (dir) (list "-I" dir)) |
|||
(funcall erlang-flymake-get-include-dirs-function)))) |
|||
(compile-opts |
|||
(append inc-dir-opts |
|||
code-dir-opts |
|||
erlang-flymake-extra-opts))) |
|||
(list erlang-flymake-command (append compile-opts (list temp-file))))) |
|||
|
|||
(defun erlang-flymake-temp-dir () |
|||
;; Squeeze the user's name in there in order to make sure that files |
|||
;; for two users who are working on the same computer (like a linux |
|||
;; box) don't collide |
|||
(format "%s/flymake-%s" temporary-file-directory user-login-name)) |
|||
|
|||
(defun erlang-flymake-flatten (list) |
|||
(apply #'append list)) |
|||
|
|||
(add-to-list 'flymake-allowed-file-name-masks |
|||
'("\\.erl\\'" erlang-flymake-init)) |
|||
(add-hook 'erlang-mode-hook 'flymake-mode) |
|||
|
|||
(provide 'erlang-flymake) |
|||
;; erlang-flymake ends here |
|||
@ -1,3 +0,0 @@ |
|||
(define-package "erlang" "2.7.0" |
|||
"Erlang major mode" |
|||
'((flymake-mode "0.4.6"))) |
|||
1267
vendor/erlang-2.7.0/erlang-skels-old.el
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1553
vendor/erlang-2.7.0/erlang-skels.el
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,121 +0,0 @@ |
|||
;; erlang-start.el --- Load this file to initialize the Erlang package. |
|||
|
|||
;; Copyright (C) 1998 Ericsson Telecom AB |
|||
|
|||
;; Author: Anders Lindgren |
|||
;; Version: 2.3 |
|||
;; Keywords: erlang, languages, processes |
|||
;; Created: 1996-09-18 |
|||
;; Date: 1998-03-16 |
|||
|
|||
;;; Commentary: |
|||
|
|||
;; Introduction: |
|||
;; ------------ |
|||
;; |
|||
;; This package provides support for the programming language Erlang. |
|||
;; The package provides an editing mode with lots of bells and |
|||
;; whistles, compilation support, and it makes it possible for the |
|||
;; user to start Erlang shells that run inside Emacs. |
|||
;; |
|||
;; See the Erlang distribution for full documentation of this package. |
|||
|
|||
;; Installation: |
|||
;; ------------ |
|||
;; |
|||
;; Place this file in Emacs load path, byte-compile it, and add the |
|||
;; following line to the appropriate init file: |
|||
;; |
|||
;; (require 'erlang-start) |
|||
;; |
|||
;; The full documentation contains much more extensive description of |
|||
;; the installation procedure. |
|||
|
|||
;; Reporting Bugs: |
|||
;; -------------- |
|||
;; |
|||
;; Please send bug reports to the following email address: |
|||
;; support@erlang.ericsson.se |
|||
;; |
|||
;; Please state as exactly as possible: |
|||
;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, |
|||
;; and of any other relevant software. |
|||
;; - What the expected result was. |
|||
;; - What you did, preferably in a repeatable step-by-step form. |
|||
;; - A description of the unexpected result. |
|||
;; - Relevant pieces of Erlang code causing the problem. |
|||
;; - Personal Emacs customisations, if any. |
|||
;; |
|||
;; Should the Emacs generate an error, please set the emacs variable |
|||
;; `debug-on-error' to `t'. Repeat the error and enclose the debug |
|||
;; information in your bug-report. |
|||
;; |
|||
;; To set the variable you can use the following command: |
|||
;; M-x set-variable RET debug-on-error RET t RET |
|||
|
|||
;;; Code: |
|||
|
|||
;; |
|||
;; Declare functions in "erlang.el". |
|||
;; |
|||
|
|||
(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t) |
|||
(autoload 'erlang-version "erlang" |
|||
"Return the current version of Erlang mode." t) |
|||
(autoload 'erlang-shell "erlang" "Start a new Erlang shell." t) |
|||
(autoload 'run-erlang "erlang" "Start a new Erlang shell." t) |
|||
|
|||
(autoload 'erlang-compile "erlang" |
|||
"Compile Erlang module in current buffer." t) |
|||
|
|||
(autoload 'erlang-man-module "erlang" |
|||
"Find manual page for MODULE." t) |
|||
(autoload 'erlang-man-function "erlang" |
|||
"Find manual page for NAME, where NAME is module:function." t) |
|||
|
|||
(autoload 'erlang-find-tag "erlang" |
|||
"Like `find-tag'. Capable of retreiving Erlang modules.") |
|||
(autoload 'erlang-find-tag-other-window "erlang" |
|||
"Like `find-tag-other-window'. Capable of retreiving Erlang modules.") |
|||
|
|||
|
|||
;; |
|||
;; Associate files extensions ".erl" and ".hrl" with Erlang mode. |
|||
;; |
|||
|
|||
(let ((a '("\\.erl\\'" . erlang-mode)) |
|||
(b '("\\.hrl\\'" . erlang-mode))) |
|||
(or (assoc (car a) auto-mode-alist) |
|||
(setq auto-mode-alist (cons a auto-mode-alist))) |
|||
(or (assoc (car b) auto-mode-alist) |
|||
(setq auto-mode-alist (cons b auto-mode-alist)))) |
|||
|
|||
;; |
|||
;; Associate files using interpreter "escript" with Erlang mode. |
|||
;; |
|||
|
|||
(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode)) |
|||
|
|||
;; |
|||
;; Ignore files ending in ".jam", ".vee", and ".beam" when performing |
|||
;; file completion. |
|||
;; |
|||
|
|||
(let ((erl-ext '(".jam" ".vee" ".beam"))) |
|||
(while erl-ext |
|||
(let ((cie completion-ignored-extensions)) |
|||
(while (and cie (not (string-equal (car cie) (car erl-ext)))) |
|||
(setq cie (cdr cie))) |
|||
(if (null cie) |
|||
(setq completion-ignored-extensions |
|||
(cons (car erl-ext) completion-ignored-extensions)))) |
|||
(setq erl-ext (cdr erl-ext)))) |
|||
|
|||
|
|||
;; |
|||
;; The end. |
|||
;; |
|||
|
|||
(provide 'erlang-start) |
|||
|
|||
;; erlang-start.el ends here. |
|||
5588
vendor/erlang-2.7.0/erlang.el
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1345
vendor/erlang-2.7.0/erlang_appwiz.el
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,591 +0,0 @@ |
|||
;;; groovy-mode.el --- Groovy mode derived mode |
|||
|
|||
;; Author: Russel Winder <russel@winder.org.uk> |
|||
;; Created: 2006-08-01 |
|||
;; Version: 201203310931 |
|||
|
|||
;;;; NB Version number is date and time yyyymmddhhMM in GMT (aka UTC). |
|||
|
|||
;; Copyright (C) 2006,2009-10,2012 Russel Winder |
|||
|
|||
;; 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. |
|||
;; |
|||
;; You should have received a copy of the GNU General Public License along with this program; if not, write |
|||
;; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
|
|||
;;; Authors: |
|||
;; |
|||
;; Russel Winder <russel@winder.org.uk>, 2006-- |
|||
;; Jim Morris <morris@wolfman.com>, 2009-- |
|||
|
|||
;;; Commentary: |
|||
;; |
|||
;; This mode was initially developed using the Java and Awk modes that are part of CC Mode (the 5.31 source |
|||
;; was used) and C# Mode from Dylan R. E. Moonfire <contact@mfgames.com> (the 0.5.0 source was used). This |
|||
;; code may contain some code fragments from those sources that was cut-and-pasted then edited. All other |
|||
;; code was newly entered by the author. Obviously changes have been made since then. |
|||
;; |
|||
;; NB This derived mode requires CC Mode 5.31 or later for the virtual semicolon code to work. |
|||
;; |
|||
;; There appears to be a problem in CC Mode 5.31 such that csharp-mode and groovy-mode crash XEmacs 21.4 if |
|||
;; the files are byte compiled. |
|||
|
|||
;;; Bugs: |
|||
;; |
|||
;; Bug tracking is currently (2009-11-26) handled using the Groovy JIRA via the Emacs Mode component. |
|||
;; cf. http://jira.codehaus.org/browse/GROOVY/component/14245 |
|||
|
|||
;;; Versions: |
|||
;; |
|||
;; 0.1.0 - will be the initial release when it is ready :-) |
|||
|
|||
;;; Notes: |
|||
;; |
|||
;; Need to think about the `*.', `?.', `.&' and `.@' operators. Also, `..' and `..<'. This probably means |
|||
;; changing `c-after-id-concat-ops' but also `c-operators'. |
|||
;; |
|||
;; Need to deal with operator overloading (groovy has this but Java does not) so `c-overloadable-operators' |
|||
;; needs investigating. |
|||
;; |
|||
;; Need to investigate how to support the triple string delimiters for multi-line strings. |
|||
;; |
|||
;; Should we support GString / template markup ( e.g. `<%' and `%>') specially? |
|||
;; |
|||
;; Need to think whether Groovy needs a different c-decl-prefix-re compared to Java. Certainly, Java will |
|||
;; have to change to handle the generics. |
|||
;; |
|||
;; Probably need to change `c-block-prefix-disallowed-chars' as Groovy is not the same as Java. |
|||
;; |
|||
;; Probably need to change `c-type-decl-suffix-key' as Groovy is not the same as Java. |
|||
|
|||
;;; Changes: |
|||
;; |
|||
;; See the history in the Bazaar branch. |
|||
|
|||
;;; Code: |
|||
|
|||
(require 'cc-mode) |
|||
|
|||
;; CSharp mode comment says: These are only required at compile time to get the sources for the language |
|||
;; constants. (The cc-fonts require and the font-lock related constants could additionally be put inside an |
|||
;; (eval-after-load "font-lock" ...) but then some trickery is necessary to get them compiled.) |
|||
(eval-when-compile |
|||
(let ((load-path |
|||
(if (and (boundp 'byte-compile-dest-file) |
|||
(stringp byte-compile-dest-file)) |
|||
(cons (file-name-directory byte-compile-dest-file) load-path) |
|||
load-path))) |
|||
(load "cc-mode" nil t) ; C# mode has this |
|||
(load "cc-fonts" nil t) ; C# mode has this |
|||
(load "cc-langs" nil t) ; C# mode has this |
|||
(load "cc-bytecomp" nil t) ; Awk mode has this |
|||
)) |
|||
|
|||
(eval-and-compile |
|||
(c-add-language 'groovy-mode 'java-mode)) |
|||
|
|||
;; Groovy allows `?.' as well as `.' for creating identifiers. |
|||
(c-lang-defconst c-identifier-ops |
|||
groovy '((left-assoc "." "?."))) |
|||
|
|||
;; Groovy allows operators such as `*.', `?.', `.&' and `.@'. Java mode puts `*' here to deal with |
|||
;; import statement usage which we need for Groovy. |
|||
(c-lang-defconst c-after-id-concat-ops |
|||
groovy '( "*" "&" "@" )) |
|||
|
|||
;;;; Should really do something with `c-string-escaped-newlines' and `c-multiline-string-start-char' to |
|||
;;;; handle the triple delimeter multiline strings. |
|||
|
|||
;; Because of the above we have to redefine `c_operators' because no other language has `.&' and |
|||
;; `.@' operators. |
|||
|
|||
(c-lang-defconst c-operators |
|||
"List describing all operators, along with their precedence and |
|||
associativity. The order in the list corresponds to the precedence of |
|||
the operators: The operators in each element is a group with the same |
|||
precedence, and the group has higher precedence than the groups in all |
|||
following elements. The car of each element describes the type of of |
|||
the operator group, and the cdr is a list of the operator tokens in |
|||
it. The operator group types are: |
|||
|
|||
'prefix Unary prefix operators. |
|||
'postfix Unary postfix operators. |
|||
'postfix-if-paren |
|||
Unary postfix operators if and only if the chars have |
|||
parenthesis syntax. |
|||
'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c). |
|||
'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)). |
|||
'right-assoc-sequence |
|||
Right associative operator that constitutes of a |
|||
sequence of tokens that separate expressions. All the |
|||
tokens in the group are in this case taken as |
|||
describing the sequence in one such operator, and the |
|||
order between them is therefore significant. |
|||
|
|||
Operators containing a character with paren syntax are taken to match |
|||
with a corresponding open/close paren somewhere else. A postfix |
|||
operator with close paren syntax is taken to end a postfix expression |
|||
started somewhere earlier, rather than start a new one at point. Vice |
|||
versa for prefix operators with open paren syntax. |
|||
|
|||
Note that operators like \".\" and \"->\" which in language references |
|||
often are described as postfix operators are considered binary here, |
|||
since CC Mode treats every identifier as an expression." |
|||
|
|||
groovy `( |
|||
;; Primary. |
|||
,@(c-lang-const c-identifier-ops) |
|||
|
|||
(postfix-if-paren "<" ">") ; Templates. |
|||
|
|||
(prefix "super") |
|||
|
|||
;; Postfix. |
|||
(left-assoc "." "*." "?." ".&" ".@") |
|||
|
|||
(postfix "++" "--" "[" "]" "(" ")" "<:" ":>") |
|||
|
|||
;; Unary. |
|||
(prefix "++" "--" "+" "-" "!" "~" "new" "(" ")") |
|||
|
|||
;; Multiplicative. |
|||
(left-assoc "*" "/" "%") |
|||
|
|||
;; Additive. |
|||
(left-assoc "+" "-") |
|||
|
|||
;; Shift. |
|||
(left-assoc "<<" ">>" ">>>") |
|||
|
|||
;; Relational. |
|||
(left-assoc "<" ">" "<=" ">=" "instanceof" "<=>") |
|||
|
|||
;; Matching. |
|||
(left-assoc "=~" "==~" ) |
|||
|
|||
;; Equality. |
|||
(left-assoc "==" "!=" ) |
|||
|
|||
;; Bitwise and. |
|||
(left-assoc "&") |
|||
|
|||
;; Bitwise exclusive or. |
|||
(left-assoc "^") |
|||
|
|||
;; Bitwise or. |
|||
(left-assoc "|") |
|||
|
|||
;; Logical and. |
|||
(left-assoc "&&") |
|||
|
|||
;; Logical or. |
|||
(left-assoc "||") |
|||
|
|||
;; Conditional. |
|||
(right-assoc-sequence "?" ":") |
|||
|
|||
;; Assignment. |
|||
(right-assoc ,@(c-lang-const c-assignment-operators)) |
|||
|
|||
;; Exception. |
|||
;(prefix "throw") ; Java mode didn't have this but c++ mode does. Humm... |
|||
|
|||
;; Sequence. |
|||
(left-assoc ",") |
|||
|
|||
;; Separator for parameter list and code in a closure. |
|||
(left-assoc "->") |
|||
)) |
|||
|
|||
;; Groovy can overload operators where Java cannot. |
|||
(c-lang-defconst c-overloadable-operators |
|||
groovy '("+" "-" "*" "/" "%" |
|||
"&" "|" "^" "~" "<<" ">>" ">>>" |
|||
"==" "!=" ">" "<" ">=" "<=" |
|||
"<=>" |
|||
"=~" "==~" |
|||
"++" "--" "+=" "-=" "*=" "/=" "%=" |
|||
"&=" "|=" "^=" "~=" "<<=" ">>=" ">>>=" |
|||
"!" "&&" "||")) |
|||
|
|||
;; Groovy allows newline to terminate a statement unlike Java and like Awk. We draw on the Awk |
|||
;; Mode `Virtual semicolon material. The idea is to say when an EOL is a `virtual semicolon, |
|||
;; i.e. a statement terminator. |
|||
|
|||
(c-lang-defconst c-stmt-delim-chars |
|||
groovy "^;{}\n\r?:") |
|||
|
|||
(c-lang-defconst c-stmt-delim-chars-with-comma |
|||
groovy "^;,{}\n\r?:") |
|||
|
|||
;; Is there a virtual semicolon at POS or point? |
|||
;; |
|||
;; A virtual semicolon is considered to lie just after the last non-syntactic-whitespace |
|||
;; character on a line where the EOL is the statement terminator. A real semicolon never |
|||
;; counts as a virtual one. |
|||
(defun groovy-at-vsemi-p ( &optional pos ) |
|||
(save-excursion |
|||
(let ((pos-or-point (if pos (goto-char pos) (point)))) |
|||
(if (eq pos-or-point (point-min)) |
|||
nil |
|||
(and |
|||
(not (char-equal (char-before) ?\;)) |
|||
(groovy-ws-or-comment-to-eol-p pos-or-point) |
|||
(groovy-not-in-statement-p pos-or-point) |
|||
(groovy-not-if-or-else-etc-p pos-or-point)))))) |
|||
|
|||
(c-lang-defconst c-at-vsemi-p-fn |
|||
groovy 'groovy-at-vsemi-p) |
|||
|
|||
;; see if end of line or comment on rest of line |
|||
(defun groovy-ws-or-comment-to-eol-p ( pos ) |
|||
(save-excursion |
|||
(goto-char pos) |
|||
(skip-chars-forward " \t") |
|||
(or |
|||
(char-equal (char-after) ?\n) |
|||
(looking-at "/[/*].*")))) |
|||
|
|||
(defun groovy-not-in-statement-p ( pos ) |
|||
(save-excursion |
|||
(goto-char pos) |
|||
(if (equal (point) (point-min)) |
|||
nil |
|||
(backward-char 1) |
|||
(or |
|||
(not (looking-at "[=+*%<{:]")) |
|||
(if (char-equal (char-after) ?>) |
|||
(if (equal (point) (point-min)) |
|||
nil |
|||
(char-equal (char-before) ?-))))))) |
|||
|
|||
;; check for case of if(stuff) and nothing else on line |
|||
;; ie |
|||
;; if(x > y) |
|||
;; |
|||
;; if(x < y) do somehting will not match |
|||
;; else blah blah will not match either |
|||
(defun groovy-not-if-or-else-etc-p ( pos ) |
|||
(save-excursion |
|||
(goto-char pos) |
|||
(back-to-indentation) |
|||
(not |
|||
(or |
|||
(and (looking-at "if") ; make sure nothing else on line |
|||
(progn (forward-sexp 2) |
|||
(groovy-ws-or-comment-to-eol-p (point)))) |
|||
(and (looking-at "}?else") |
|||
(progn (forward-char) |
|||
(forward-sexp 1) |
|||
(groovy-ws-or-comment-to-eol-p (point)))))))) |
|||
|
|||
(defun groovy-vsemi-status-unknown-p () nil) |
|||
|
|||
(c-lang-defconst c-vsemi-status-unknown-p-fn |
|||
groovy 'c-groovy-vsemi-status-unknown-p) |
|||
|
|||
|
|||
;; Java does not do this but perhaps it should? |
|||
(c-lang-defconst c-type-modifier-kwds |
|||
groovy '("volatile" "transient")) |
|||
|
|||
(c-lang-defconst c-typeless-decl-kwds |
|||
groovy (append (c-lang-const c-class-decl-kwds) |
|||
(c-lang-const c-brace-list-decl-kwds) |
|||
'("def"))) |
|||
|
|||
;;;; Should we be tinkering with `c-block-stmt-1-key' or `c-block-stmt-2-key' to deal with closures |
|||
;;;; following what appears to be function calls or even field names? |
|||
|
|||
;; Groovy allows use of `<%' and `%>' in template expressions. |
|||
;(c-lang-defconst c-other-op-syntax-tokens |
|||
; groovy '( "<%" "%>" )) |
|||
|
|||
;; Groovy does not allow the full set of Java keywords in the moifier category and, of course, there is the |
|||
;; `def' modifier which Groovy introduces to support dynamic typing. Should `const' be treated |
|||
;; as reserved here as it is in Java? |
|||
(c-lang-defconst c-modifier-kwds |
|||
groovy '( "abstract" "def" "final" "private" "protected" "public" "static" "synchronized" )) |
|||
|
|||
;; Java does not define these pseudo-kewords as keywords, why not? |
|||
|
|||
(c-lang-defconst c-constant-kwds |
|||
groovy '( "true" "false" "null" )) |
|||
|
|||
;; Why does Java mode not put `super' into the `c-primary-expr-kwds? |
|||
|
|||
(c-lang-defconst c-primary-expr-kwds |
|||
groovy '( "this" "super" )) |
|||
|
|||
;; Groovy does not allow anonymous classes as Java does. |
|||
(c-lang-defconst c-inexpr-class-kwds |
|||
groovy nil) |
|||
|
|||
(c-lang-defconst c-inexpr-brace-list-kwds |
|||
groovy nil) |
|||
|
|||
;;;; Should we be changing `c-opt-inexpr-brace-list-key' to deal with closures after function calls and |
|||
;;;; field expressions? |
|||
|
|||
;; We need to include the "as" for the cast and "in" for for. |
|||
(c-lang-defconst c-other-kwds |
|||
groovy '( "in" "as" )) |
|||
|
|||
|
|||
(defconst groovy-font-lock-keywords-1 (c-lang-const c-matchers-1 groovy) |
|||
"Minimal highlighting for Groovy mode. |
|||
Fontifies nothing except the syntactic fontification of strings and |
|||
comments.") |
|||
|
|||
(defconst groovy-font-lock-keywords-2 (c-lang-const c-matchers-2 groovy) |
|||
"Fast normal highlighting for Groovy mode. |
|||
In addition to `java-font-lock-keywords-1', this adds fontification of |
|||
keywords, simple types, declarations that are easy to recognize, the |
|||
user defined types on `java-font-lock-extra-types', and the doc |
|||
comment styles specified by `c-doc-comment-style'.") |
|||
|
|||
(defconst groovy-font-lock-keywords-3 (c-lang-const c-matchers-3 groovy) |
|||
"Accurate normal highlighting for Groovy mode. |
|||
Like `java-font-lock-keywords-2' but detects declarations in a more |
|||
accurate way that works in most cases for arbitrary types without the |
|||
need for `java-font-lock-extra-types'.") |
|||
|
|||
(defvar groovy-font-lock-keywords groovy-font-lock-keywords-3 |
|||
"Default expressions to highlight in Groovy mode.") |
|||
|
|||
(defun groovy-font-lock-keywords-2 () |
|||
(c-compose-keywords-list groovy-font-lock-keywords-2)) |
|||
(defun groovy-font-lock-keywords-3 () |
|||
(c-compose-keywords-list groovy-font-lock-keywords-3)) |
|||
(defun groovy-font-lock-keywords () |
|||
(c-compose-keywords-list groovy-font-lock-keywords)) |
|||
|
|||
(defvar groovy-mode-syntax-table nil |
|||
"Syntax table used in Groovy mode buffers.") |
|||
(or groovy-mode-syntax-table |
|||
(setq groovy-mode-syntax-table |
|||
(funcall (c-lang-const c-make-mode-syntax-table groovy)))) |
|||
|
|||
(defvar groovy-mode-abbrev-table nil |
|||
"Abbreviation table used in groovy-mode buffers.") |
|||
(c-define-abbrev-table 'groovy-mode-abbrev-table |
|||
;; Keywords that if they occur first on a line might alter the syntactic context, and which |
|||
;; therefore should trigger reindentation when they are completed. |
|||
'(("else" "else" c-electric-continued-statement 0) |
|||
("while" "while" c-electric-continued-statement 0) |
|||
("catch" "catch" c-electric-continued-statement 0) |
|||
("finally" "finally" c-electric-continued-statement 0))) |
|||
|
|||
;; Jim Morris proposed changing to the following definition of groovy-mode-map 2009-11-27, but this change |
|||
;; has not made so as to continue to use the same code structure as still used in the Java mode. |
|||
|
|||
;(defvar groovy-mode-map (let ((map (c-make-inherited-keymap))) |
|||
; ;; Add bindings which are only useful for Groovy |
|||
; map) |
|||
; "Keymap used in groovy-mode buffers.") |
|||
|
|||
(defvar groovy-mode-map () |
|||
"Keymap used in groovy-mode buffers.") |
|||
(if groovy-mode-map |
|||
nil |
|||
(setq groovy-mode-map (c-make-inherited-keymap)) |
|||
;; add bindings which are only useful for Groovy |
|||
) |
|||
|
|||
;(easy-menu-define c-groovy-menu groovy-mode-map "Groovy Mode Commands" |
|||
; (cons "Groovy" (c-lang-const c-mode-menu groovy))) |
|||
|
|||
;;; Autoload mode trigger |
|||
;;;###autoload |
|||
;(eval-after-load 'groovy-mode |
|||
; (add-to-list 'auto-mode-alist '("\\.groovy" . groovy-mode))) |
|||
(add-to-list 'auto-mode-alist '("\\.groovy$" . groovy-mode)) |
|||
|
|||
;; Custom variables |
|||
;;;###autoload |
|||
(defcustom groovy-mode-hook nil |
|||
"*Hook called by `groovy-mode'." |
|||
:type 'hook |
|||
:group 'c) |
|||
|
|||
|
|||
;;; The following are used to overide cc-mode indentation behavior to match groovy |
|||
|
|||
;; if we are in a closure that has an argument eg ends with -> (excluding comment) then |
|||
;; change indent else lineup with previous one |
|||
(defun groovy-mode-fix-closure-with-argument (langelem) |
|||
(save-excursion |
|||
(back-to-indentation) |
|||
(c-backward-syntactic-ws) |
|||
(backward-char 2) |
|||
(if (looking-at "->") ; if the line has a -> in it |
|||
(vector (+ (current-indentation) c-basic-offset)) ; then indent from base |
|||
0))) |
|||
|
|||
;; A helper function from: http://mihai.bazon.net/projects/emacs-javascript-mode/javascript.el |
|||
;; Originally named js-lineup-arglist, renamed to groovy-lineup-arglist |
|||
(defun groovy-lineup-arglist (langelem) |
|||
;; the "DWIM" in c-mode doesn't Do What I Mean. |
|||
;; see doc of c-lineup-arglist for why I redefined this |
|||
(save-excursion |
|||
(let ((indent-pos (point))) |
|||
;; Normal case. Indent to the token after the arglist open paren. |
|||
(goto-char (c-langelem-2nd-pos c-syntactic-element)) |
|||
(if (and c-special-brace-lists |
|||
(c-looking-at-special-brace-list)) |
|||
;; Skip a special brace list opener like "({". |
|||
(progn (c-forward-token-2) |
|||
(forward-char)) |
|||
(forward-char)) |
|||
(let ((arglist-content-start (point))) |
|||
(c-forward-syntactic-ws) |
|||
(when (< (point) indent-pos) |
|||
(goto-char arglist-content-start) |
|||
(skip-chars-forward " \t")) |
|||
(vector (current-column)))))) |
|||
|
|||
(defun is-groovy-mode () |
|||
"return t if we are in groovy mode else nil" |
|||
(eq major-mode 'groovy-mode)) |
|||
|
|||
;; use defadvice to override the syntactic type if we have a |
|||
;; statement-cont, see if previous line has a virtual semicolon and if |
|||
;; so make it statement. |
|||
(defadvice c-guess-basic-syntax (after c-guess-basic-syntax-groovy activate) |
|||
(when (is-groovy-mode) |
|||
(save-excursion |
|||
(let* ((ankpos (progn |
|||
(beginning-of-line) |
|||
(c-backward-syntactic-ws) |
|||
(beginning-of-line) |
|||
(c-forward-syntactic-ws) |
|||
(point))) ; position to previous non-blank line |
|||
(curelem (c-langelem-sym (car ad-return-value)))) |
|||
(end-of-line) |
|||
(cond |
|||
((eq 'statement-cont curelem) |
|||
(when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a statement |
|||
(setq ad-return-value `((statement ,ankpos))))) |
|||
|
|||
((eq 'topmost-intro-cont curelem) |
|||
(when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a top-most-intro |
|||
(setq ad-return-value `((topmost-intro ,ankpos))))) |
|||
|
|||
))))) |
|||
|
|||
;; This disables bracelists, as most of the time in groovy they are closures |
|||
;; We need to check we are currently in groovy mode |
|||
(defadvice c-inside-bracelist-p (around groovy-c-inside-bracelist-p activate) |
|||
(if (not (is-groovy-mode)) |
|||
ad-do-it |
|||
(setq ad-return-value nil))) |
|||
|
|||
|
|||
;; based on java-function-regexp |
|||
;; Complicated regexp to match method declarations in interfaces or classes |
|||
;; A nasty test case is: |
|||
;; else if(foo instanceof bar) { |
|||
;; which will get mistaken for a function as Groovy does not require types on arguments |
|||
;; so we need to check for empty parens or comma separated list, or type args |
|||
(defvar groovy-function-regexp |
|||
(concat |
|||
"^[ \t]*" ; leading white space |
|||
"\\(public\\|private\\|protected\\|" ; some of these 8 keywords |
|||
"abstract\\|final\\|static\\|" |
|||
"synchronized\\|native|def" |
|||
"\\|[ \t\n\r]\\)*" ; or whitespace |
|||
"[a-zA-Z0-9_$]*" ; optional return type |
|||
"[ \t\n\r]*[[]?[]]?" ; (could be array) |
|||
"[ \t\n\r]+" ; whitespace |
|||
"\\([a-zA-Z0-9_$]+\\)" ; the name we want |
|||
"[ \t\n\r]*" ; optional whitespace |
|||
"(" ; open the param list |
|||
"[ \t]*" ; optional whitespace |
|||
"\\(" |
|||
"[ \t\n\r]*\\|" ; empty parens or |
|||
"[a-zA-Z0-9_$]+\\|" ; single param or |
|||
".+?,.+?\\|" ; multi comma separated params or |
|||
"[a-zA-Z0-9_$]+" ; a type |
|||
"[ \t\n\r]*[[]?[]]?" ; optional array |
|||
"[ \t\n\r]+[a-zA-Z0-9_$]+" ; and param |
|||
"\\)" |
|||
"[ \t\n\r]*" ; optional whitespace |
|||
")" ; end the param list |
|||
"[ \t\n\r]*" ; whitespace |
|||
; "\\(throws\\([, \t\n\r]\\|[a-zA-Z0-9_$]\\)+\\)?{" |
|||
"\\(throws[^{;]+\\)?" ; optional exceptions |
|||
"[;{]" ; ending ';' (interfaces) or '{' |
|||
; TODO groovy interfaces don't need to end in ; |
|||
) |
|||
"Matches method names in groovy code, select match 2") |
|||
|
|||
(defvar groovy-class-regexp |
|||
"^[ \t\n\r]*\\(final\\|abstract\\|public\\|[ \t\n\r]\\)*class[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;{]*{" |
|||
"Matches class names in groovy code, select match 2") |
|||
|
|||
(defvar groovy-interface-regexp |
|||
"^[ \t\n\r]*\\(abstract\\|public\\|[ \t\n\r]\\)*interface[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;]*;" |
|||
"Matches interface names in groovy code, select match 2") |
|||
|
|||
(defvar groovy-imenu-regexp |
|||
(list (list nil groovy-function-regexp 2) |
|||
(list ".CLASSES." groovy-class-regexp 2) |
|||
(list ".INTERFACES." groovy-interface-regexp 2) |
|||
(list ".CLOSURES." "def[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)[ \t]*=[ \t]*{" 1)) |
|||
"Imenu expression for Groovy") |
|||
|
|||
|
|||
;; Setup imenu to extract functions, classes, interfaces and closures assigned to variables |
|||
(defvar cc-imenu-groovy-generic-expression |
|||
groovy-imenu-regexp |
|||
"Imenu generic expression for Groovy mode. See `imenu-generic-expression'.") |
|||
|
|||
;;; The entry point into the mode |
|||
;;;###autoload |
|||
(defun groovy-mode () |
|||
"Major mode for editing Groovy code. |
|||
|
|||
The hook `c-mode-common-hook' is run with no args at mode |
|||
initialization, then `groovy-mode-hook'. |
|||
|
|||
Key bindings: |
|||
\\{groovy-mode-map}" |
|||
(interactive) |
|||
(kill-all-local-variables) |
|||
(c-initialize-cc-mode t) |
|||
(set-syntax-table groovy-mode-syntax-table) |
|||
(setq major-mode 'groovy-mode |
|||
mode-name "Groovy" |
|||
local-abbrev-table groovy-mode-abbrev-table |
|||
abbrev-mode t) |
|||
(use-local-map groovy-mode-map) |
|||
(c-init-language-vars groovy-mode) |
|||
(c-common-init 'groovy-mode) |
|||
;;(easy-menu-add groovy-menu) |
|||
(cc-imenu-init cc-imenu-groovy-generic-expression) |
|||
(c-run-mode-hooks 'c-mode-common-hook 'groovy-mode-hook) |
|||
|
|||
;; quick fix for misalignment of statements with = |
|||
(setq c-label-minimum-indentation 0) |
|||
|
|||
;; fix for indentation after a closure param list |
|||
(c-set-offset 'statement 'groovy-mode-fix-closure-with-argument) |
|||
|
|||
;; get arglists (in groovy lists or maps) to align properly |
|||
(c-set-offset 'arglist-close '(c-lineup-close-paren)) |
|||
(c-set-offset 'arglist-cont 0) |
|||
(c-set-offset 'arglist-cont-nonempty '(groovy-lineup-arglist)) |
|||
(c-set-offset 'arglist-intro '+) |
|||
|
|||
(c-update-modeline)) |
|||
|
|||
|
|||
(provide 'groovy-mode) |
|||
|
|||
;;; groovy-mode.el ends here |
|||
@ -1,110 +0,0 @@ |
|||
;;; melpa.el --- special handling for the MELPA repository |
|||
;; |
|||
;; Copyright 2012 Donald Ephraim Curtis |
|||
;; |
|||
;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net> |
|||
;; URL: https://github.com/milkypostman/melpa |
|||
;; Version: 0.3 |
|||
;; |
|||
;; |
|||
;; Credits: |
|||
;; Steve Purcell |
|||
;; |
|||
;; |
|||
;; Installation: |
|||
;; |
|||
;; (progn |
|||
;; (switch-to-buffer |
|||
;; (url-retrieve-synchronously |
|||
;; "https://raw.github.com/milkypostman/melpa/master/melpa.el")) |
|||
;; (package-install-from-buffer (package-buffer-info) 'single)) |
|||
;; |
|||
;; |
|||
;; |
|||
;; Code goes here |
|||
;; |
|||
|
|||
|
|||
;;;###autoload |
|||
(defcustom package-archive-enable-alist nil |
|||
"Optional Alist of enabled packages used by `package-filter'. |
|||
The format is (ARCHIVE . PACKAGE ...), where ARCHIVE is a string |
|||
matching an archive name in `package-archives', PACKAGE is a |
|||
symbol of a package in ARCHIVE to enable. |
|||
|
|||
If no ARCHIVE exists in the alist, all packages are enabled." |
|||
:group 'package |
|||
:type '(alist :key-type string :value-type (repeat symbol))) |
|||
|
|||
|
|||
;;;###autoload |
|||
(defcustom package-archive-exclude-alist nil |
|||
"Alist of packages excluded by `package-filter'. |
|||
The format is (ARCHIVE . PACKAGE ...), where ARCHIVE is a string |
|||
matching an archive name in `package-archives', PACKAGE is a |
|||
symbol of a package in that archive to exclude. |
|||
|
|||
Any specified package is excluded regardless of the value of |
|||
`package-archive-enable-alist'" |
|||
:group 'package |
|||
:type '(alist :key-type string :value-type (repeat symbol))) |
|||
|
|||
|
|||
;;;###autoload |
|||
(defcustom package-filter-function 'package-filter |
|||
"Optional predicate function used to internally |
|||
filter packages used by package.el. |
|||
|
|||
Return nil to filter a function from the list. |
|||
|
|||
The function is called with the arguments PACKAGE VERSION ARCHIVE, where |
|||
PACKAGE is a symbol, VERSION is a vector as produced by `version-to-list', and |
|||
ARCHIVE is the string name of the package archive." |
|||
:group 'package |
|||
:type 'function) |
|||
|
|||
|
|||
;;;###autoload |
|||
(defadvice package-compute-transaction |
|||
(before |
|||
package-compute-transaction-reverse (package-list requirements) |
|||
activate compile) |
|||
"reverse the requirements" |
|||
(setq requirements (reverse requirements)) |
|||
(print requirements)) |
|||
|
|||
|
|||
;;;###autoload |
|||
(defadvice package--add-to-archive-contents |
|||
(around package-filter-add-to-archive-contents (package archive) |
|||
activate compile) |
|||
"Add filtering of available packages using `package-filter-function', |
|||
if non-nil." |
|||
(when (and package-filter-function |
|||
(funcall package-filter-function |
|||
(car package) |
|||
(package-desc-vers (cdr package)) |
|||
archive)) |
|||
ad-do-it)) |
|||
|
|||
|
|||
;;;###autoload |
|||
(defun package-filter (package version archive) |
|||
"Check package against enabled and excluded list for the `archive'. |
|||
|
|||
Filter packages not in the associated list for `archive' in |
|||
`package-archive-enable-alist'. |
|||
|
|||
Filter packages in the associated list for `archive' in |
|||
`package-archive-exclude-alist'." |
|||
(let ((enable-rules (cdr (assoc archive package-archive-enable-alist))) |
|||
(exclude-rules (cdr (assoc archive package-archive-exclude-alist)))) |
|||
(and (not (memq package exclude-rules)) |
|||
(or (not enable-rules) |
|||
(memq package enable-rules))))) |
|||
|
|||
|
|||
|
|||
(provide 'melpa) |
|||
|
|||
;;; melpa.el ends here |
|||
@ -1,253 +0,0 @@ |
|||
;;; ruby-block.el --- highlight matching block |
|||
|
|||
;; Copyright (C) 2007-2009 khiker |
|||
|
|||
;; Author: khiker <khiker.mail+elisp@gmail.com> |
|||
;; Keywords: languages, faces, ruby |
|||
|
|||
;; This file is free software; you can redistribute it and/or modify |
|||
;; it under the terms of the GNU General Public License as published by |
|||
;; the Free Software Foundation; either version 2, or (at your option) |
|||
;; any later version. |
|||
|
|||
;; This file is distributed in the hope that it will be useful, |
|||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
;; GNU General Public License for more details. |
|||
|
|||
;; You should have received a copy of the GNU General Public License |
|||
;; along with GNU Emacs; see the file COPYING. If not, write to |
|||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
;; Boston, MA 02110-1301, USA. |
|||
|
|||
;;; Commentary: |
|||
|
|||
;;; Usage: |
|||
|
|||
;; Add this line to your .emacs |
|||
;; |
|||
;; (require 'ruby-block) |
|||
;; (ruby-block-mode t) |
|||
;; |
|||
;; In addition, you can also add this line too. |
|||
;; |
|||
;; ;; do overlay |
|||
;; (setq ruby-block-highlight-toggle 'overlay) |
|||
;; ;; display to minibuffer |
|||
;; (setq ruby-block-highlight-toggle 'minibuffer) |
|||
;; ;; display to minibuffer and do overlay |
|||
;; (setq ruby-block-highlight-toggle t) |
|||
;; |
|||
;; Default is minibuffer. |
|||
;; |
|||
;; Tested on Emacs 22.3.2 and Emacs 23.0.95.2. |
|||
|
|||
;;; Note: |
|||
|
|||
;; A ruby-mode.el is necessary to use this package. |
|||
|
|||
;;; Code: |
|||
|
|||
(require 'ruby-mode) |
|||
|
|||
;; Variables: |
|||
|
|||
(defconst ruby-block-version "0.0.8" |
|||
"Ruby block package version.") |
|||
|
|||
(defconst ruby-block-keyword-list |
|||
(list "end" "for" "while" "until" "if" "class" "module" |
|||
"case" "unless" "def" "begin" "do") |
|||
"Keyword for highlighting.") |
|||
|
|||
(defconst ruby-block-keyword-regex |
|||
"\\(end\\|for\\|while\\|until\\|if\\|class\\|module\\|case\\|unless\\|def\\|begin\\|do\\)" |
|||
"Rregular expression to look for correspondence.") |
|||
|
|||
(defgroup ruby-block nil |
|||
"Ruby block" |
|||
:tag "Ruby block" |
|||
:group 'ruby-block) |
|||
|
|||
(defcustom ruby-block-delay 0.50 |
|||
"*Time in seconds to delay before showing a matching paren." |
|||
:type 'number |
|||
:group 'ruby-block) |
|||
|
|||
(defcustom ruby-block-highlight-face 'highlight |
|||
"*Face for block highlighting." |
|||
:type 'face |
|||
:group 'ruby-block) |
|||
|
|||
(defcustom ruby-block-highlight-toggle 'minibuffer |
|||
"*How do you display corresponding line. |
|||
Default is minibuffer. display to minibuffer. |
|||
|
|||
The possible choice is as follows. |
|||
|
|||
nil => nothing |
|||
minibuffer => minibuffer |
|||
overlay => overlay |
|||
t => minibuffer and overlay" |
|||
:type '(choice (const :tag "nothing" nil) |
|||
(const :tag "minibuffer" minibuffer) |
|||
(const :tag "overlay" overlay) |
|||
(const :tag "minibuffer and overlay" t)) |
|||
:group 'ruby-block) |
|||
|
|||
(defvar ruby-block-timer nil) |
|||
|
|||
(defvar ruby-block-highlight-overlay nil) |
|||
|
|||
|
|||
;; Functions: |
|||
|
|||
(define-minor-mode ruby-block-mode |
|||
"In ruby-mode, Displays the line where there is keyword corresponding |
|||
to END keyword. this is Minor mode for ruby-mode only." |
|||
:init-value t |
|||
:global nil |
|||
:keymap nil |
|||
:lighter " RBlock" |
|||
(if ruby-block-mode |
|||
(ruby-block-start-timer) |
|||
(ruby-block-stop-timer))) |
|||
|
|||
(defun ruby-block-start-timer () |
|||
"start timer." |
|||
(when ruby-block-timer |
|||
(cancel-timer ruby-block-timer)) |
|||
(setq ruby-block-timer |
|||
(run-with-idle-timer ruby-block-delay t 'ruby-block-hook))) |
|||
|
|||
(defun ruby-block-stop-timer () |
|||
"stop timer." |
|||
(when ruby-block-timer |
|||
(cancel-timer ruby-block-timer) |
|||
(setq ruby-block-timer nil))) |
|||
|
|||
(defun ruby-block-hook () |
|||
"When Major-mode is ruby-mode, this package is running." |
|||
(if (eq major-mode 'ruby-mode) |
|||
(condition-case err |
|||
(ruby-block-function) |
|||
(error |
|||
(setq ruby-block-mode nil) |
|||
(message "Error: %S; ruby-block-mode now disabled." err))) |
|||
(setq ruby-block-mode nil))) |
|||
|
|||
(defun ruby-block-get-line-start-pos () |
|||
(save-excursion |
|||
(let ((xor '(lambda (a b) (and (or a b) (not (and a b))))) |
|||
(point (point)) |
|||
(count 0)) |
|||
(while (and (not (funcall xor (bobp) (eolp))) |
|||
(> point (point-min))) |
|||
(setq point (1- point)) |
|||
(goto-char (1- (point)))) |
|||
;; delete linefeed of start point. |
|||
(when (and (eolp) (>= (point-max) (1+ point))) |
|||
(setq point (1+ point))) |
|||
point))) |
|||
|
|||
(defun ruby-block-get-line-end-pos () |
|||
(save-excursion |
|||
(let ((xor '(lambda (a b) (and (or a b) (not (and a b))))) |
|||
(point (point))) |
|||
(while (and (not (funcall xor (eobp) (eolp))) |
|||
(>= (point-max) point)) |
|||
(setq point (1+ point)) |
|||
(goto-char (1+ (point)))) |
|||
point))) |
|||
|
|||
(defun ruby-block-function () |
|||
"Point position's word decides behavior." |
|||
(let ((current (current-word))) |
|||
(setq current (car (member current ruby-block-keyword-list))) |
|||
(cond |
|||
;; not keyword |
|||
((null current) |
|||
nil) |
|||
;; keyword "end" |
|||
((and (string= "end" current) |
|||
(eq 'font-lock-keyword-face (get-text-property (point) 'face))) |
|||
(let ((point (ruby-block-get-corresponding-point)) |
|||
(slinep 0)(elinep 0)) |
|||
;; get whole line(exists point). and, display minibuffer. |
|||
(when (> point 0) |
|||
(save-excursion |
|||
(goto-char point) |
|||
(setq slinep (ruby-block-get-line-start-pos) |
|||
elinep (ruby-block-get-line-end-pos))) |
|||
;; display line contents to minibuffer |
|||
(when (or (eq ruby-block-highlight-toggle t) |
|||
(eq ruby-block-highlight-toggle 'minibuffer)) |
|||
(message "%d: %s" (1+ (count-lines (point-min) slinep)) |
|||
(buffer-substring slinep elinep))) |
|||
;; do overlay. |
|||
(when (or (eq ruby-block-highlight-toggle t) |
|||
(eq ruby-block-highlight-toggle 'overlay)) |
|||
(ruby-block-do-highlight slinep elinep))))) |
|||
;; keyword except "end" |
|||
(t |
|||
nil)))) |
|||
|
|||
(defun ruby-block-get-corresponding-point () |
|||
"Get point of corresponding line." |
|||
(let ((orig-col (- (point) (ruby-block-get-line-start-pos))) |
|||
(recent-col (- (point) (ruby-block-get-line-start-pos))) |
|||
(count 1)(check t)(point 0)(face "")(string "")) |
|||
(save-excursion |
|||
(while check |
|||
(if (re-search-backward ruby-block-keyword-regex (point-min) t 1) |
|||
(setq point (match-beginning 1) |
|||
face (get-text-property point 'face) |
|||
string (current-word)) |
|||
(setq point -1 face "" string "" check nil)) |
|||
(when (and (eq face 'font-lock-keyword-face) |
|||
(not (string= string "elsif")) |
|||
(member string ruby-block-keyword-list) |
|||
;; case: STMT if(or unless, while, untill) EXPR |
|||
(if (member string '("if" "unless" "while" "until")) |
|||
(let ((col (- point (ruby-block-get-line-start-pos)))) |
|||
(if (or (> (+ orig-col 3) col) |
|||
(> (+ recent-col 3) col)) |
|||
t nil)) |
|||
t)) |
|||
(if (and (string= string "end") check) |
|||
(setq count (1+ count) |
|||
recent-col (- (point) (ruby-block-get-line-start-pos))) |
|||
(setq count (1- count)))) |
|||
(when (= count 0) |
|||
(setq check nil))) |
|||
point))) |
|||
|
|||
(defun ruby-block-do-highlight (beg end) |
|||
"Do overlay corresponding line." |
|||
(if ruby-block-highlight-overlay |
|||
(move-overlay ruby-block-highlight-overlay beg end) |
|||
(setq ruby-block-highlight-overlay (make-overlay beg end))) |
|||
(overlay-put ruby-block-highlight-overlay |
|||
'face ruby-block-highlight-face) |
|||
(add-hook 'pre-command-hook 'ruby-block-highlight-done)) |
|||
|
|||
(defun ruby-block-highlight-done () |
|||
"After do overlay, restore the line to original color." |
|||
(remove-hook 'pre-command-hook 'ruby-block-highlight-done) |
|||
(if ruby-block-highlight-overlay |
|||
(delete-overlay ruby-block-highlight-overlay))) |
|||
|
|||
(defun ruby-block-highlight-toggle () |
|||
"Switch on/off for ruby-block-mode." |
|||
(interactive) |
|||
(if ruby-block-highlight-toggle |
|||
(setq ruby-block-highlight-toggle nil) |
|||
(setq ruby-block-highlight-toggle t))) |
|||
|
|||
(provide 'ruby-block) |
|||
|
|||
;; Local Variables: |
|||
;; Coding: iso-2022-7bit |
|||
;; End: |
|||
|
|||
;;; ruby-block.el ends here |
|||
@ -1,138 +0,0 @@ |
|||
;;; ruby-end.el --- Automatic insertion of end blocks for Ruby |
|||
|
|||
;; Copyright (C) 2010 Johan Andersson |
|||
|
|||
;; Author: Johan Andersson <johan.rejeep@gmail.com> |
|||
;; Maintainer: Johan Andersson <johan.rejeep@gmail.com> |
|||
;; Version: 0.1.0 |
|||
;; Keywords: speed, convenience |
|||
;; URL: http://github.com/rejeep/ruby-end |
|||
|
|||
;; This file is NOT part of GNU Emacs. |
|||
|
|||
|
|||
;;; License: |
|||
|
|||
;; This program is free software; you can redistribute it and/or modify |
|||
;; it under the terms of the GNU General Public License as published by |
|||
;; the Free Software Foundation; either version 3, or (at your option) |
|||
;; any later version. |
|||
|
|||
;; This program is distributed in the hope that it will be useful, |
|||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
;; GNU General Public License for more details. |
|||
|
|||
;; You should have received a copy of the GNU General Public License |
|||
;; along with GNU Emacs; see the file COPYING. If not, write to the |
|||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
;; Boston, MA 02110-1301, USA. |
|||
|
|||
|
|||
;;; Commentary: |
|||
|
|||
;; ruby-end is a minor mode for Emacs that can be used with ruby-mode |
|||
;; to automatically close blocks by inserting "end" when typing a |
|||
;; block-keyword, followed by a space. |
|||
;; |
|||
;; To use ruby-end-mode, make sure that this file is in Emacs load-path: |
|||
;; (add-to-list 'load-path "/path/to/directory/or/file") |
|||
;; |
|||
;; Then require ruby-end: |
|||
;; (require 'ruby-end) |
|||
;; |
|||
;; ruby-end-mode is automatically started in ruby-mode. |
|||
|
|||
|
|||
;;; Code: |
|||
|
|||
(defvar ruby-end-expand-key "SPC" |
|||
"Space key name.") |
|||
|
|||
(defvar ruby-end-mode-map |
|||
(let ((map (make-sparse-keymap)) |
|||
(key (read-kbd-macro ruby-end-expand-key))) |
|||
(define-key map key 'ruby-end-space) |
|||
map) |
|||
"Keymap for `ruby-end-mode'.") |
|||
|
|||
(defcustom ruby-end-check-statement-modifiers t |
|||
"*Disable or enable expansion (insertion of end) for statement modifiers" |
|||
:type 'boolean |
|||
:group 'ruby) |
|||
|
|||
(defconst ruby-end-expand-postfix-modifiers-before-re |
|||
"\\(?:if\\|unless\\|while\\)" |
|||
"Regular expression matching statements before point.") |
|||
|
|||
(defconst ruby-end-expand-prefix-check-modifiers-re |
|||
"^\\s-*" |
|||
"Prefix for regular expression to prevent expansion with statement modifiers") |
|||
|
|||
(defconst ruby-end-expand-prefix-re |
|||
"\\(?:^\\|\\s-+\\)" |
|||
"Prefix for regular expression") |
|||
|
|||
(defconst ruby-end-expand-keywords-before-re |
|||
"\\(?:^\\|\\s-+\\)\\(?:do\\|def\\|class\\|module\\|case\\|for\\|begin\\)" |
|||
"Regular expression matching blocks before point.") |
|||
|
|||
|
|||
(defconst ruby-end-expand-after-re |
|||
"\\s-*$" |
|||
"Regular expression matching after point.") |
|||
|
|||
(defun ruby-end-space () |
|||
"Called when SPC-key is pressed." |
|||
(interactive) |
|||
(cond |
|||
((ruby-end-expand-p) |
|||
(ruby-end-insert-end) |
|||
(insert " ")) |
|||
(t |
|||
(let ((ruby-end-mode nil)) |
|||
(call-interactively |
|||
(key-binding |
|||
(read-kbd-macro ruby-end-expand-key))))))) |
|||
|
|||
(defun ruby-end-insert-end () |
|||
"Closes block by inserting end." |
|||
(save-excursion |
|||
(newline) |
|||
(insert "end") |
|||
(indent-according-to-mode))) |
|||
|
|||
(defun ruby-end-expand-p () |
|||
"Checks if expansion (insertion of end) should be done." |
|||
(let ((ruby-end-expand-statement-modifiers-before-re |
|||
(concat |
|||
(if ruby-end-check-statement-modifiers |
|||
ruby-end-expand-prefix-check-modifiers-re |
|||
ruby-end-expand-prefix-re) |
|||
ruby-end-expand-postfix-modifiers-before-re))) |
|||
(and |
|||
(ruby-end-code-at-point-p) |
|||
(or |
|||
(looking-back ruby-end-expand-statement-modifiers-before-re) |
|||
(looking-back ruby-end-expand-keywords-before-re)) |
|||
(looking-at ruby-end-expand-after-re)))) |
|||
|
|||
(defun ruby-end-code-at-point-p () |
|||
"Checks if point is code, or comment or string." |
|||
(let ((properties (text-properties-at (point)))) |
|||
(and |
|||
(null (memq 'font-lock-string-face properties)) |
|||
(null (memq 'font-lock-comment-face properties))))) |
|||
|
|||
;;;###autoload |
|||
(define-minor-mode ruby-end-mode |
|||
"Automatic insertion of end blocks for Ruby." |
|||
:init-value nil |
|||
:lighter " end" |
|||
:keymap ruby-end-mode-map) |
|||
|
|||
(add-hook 'ruby-mode-hook 'ruby-end-mode) |
|||
|
|||
(provide 'ruby-end) |
|||
|
|||
;;; ruby-end.el ends here |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue