aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/emacs/erlang.el
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tools/emacs/erlang.el')
-rw-r--r--lib/tools/emacs/erlang.el196
1 files changed, 137 insertions, 59 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index b5da9e79d8..ddd22707dd 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -1,7 +1,13 @@
-;; erlang.el --- Major modes for editing and running Erlang
+;;; erlang.el --- Major modes for editing and running Erlang
+
+;; Copyright (C) 2004 Free Software Foundation, Inc.
+;; Author: Anders Lindgren
+;; Keywords: erlang, languages, processes
+;; Date: 2011-12-11
+
;; %CopyrightBegin%
;;
-;; Copyright Ericsson AB 1996-2012. All Rights Reserved.
+;; Copyright Ericsson AB 1996-2013. 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
@@ -15,10 +21,7 @@
;; under the License.
;;
;; %CopyrightEnd%
-;;
-;; Copyright (C) 2004 Free Software Foundation, Inc.
-;; Author: Anders Lindgren
-;; Keywords: erlang, languages, processes
+;;
;; Lars Thors�n's modifications of 2000-06-07 included.
;; The original version of this package was written by Robert Virding.
@@ -483,10 +486,6 @@ function.")
"*Non-nil means TAB in Erlang mode should always re-indent the current line,
regardless of where in the line point is when the TAB command is used.")
-(defvar erlang-error-regexp-alist
- '(("^\\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" . (1 2)))
- "*Patterns for matching Erlang errors.")
-
(defvar erlang-man-inhibit (eq system-type 'windows-nt)
"Inhibit the creation of the Erlang Manual Pages menu.
@@ -724,31 +723,32 @@ resulting regexp is surrounded by \\_< and \\_>."
(eval-and-compile
(defvar erlang-int-bifs
'("abs"
- "adler32"
- "adler32_combine"
- "alive"
"apply"
"atom_to_binary"
"atom_to_list"
"binary_to_atom"
"binary_to_existing_atom"
+ "binary_to_float"
+ "binary_to_integer"
"binary_to_list"
"binary_to_term"
+ "binary_part"
"bit_size"
+ "bitsize"
"bitstring_to_list"
"byte_size"
+ "check_old_code"
"check_process_code"
- "contact_binary"
- "crc32"
- "crc32_combine"
"date"
- "decode_packet"
"delete_module"
+ "demonitor"
"disconnect_node"
"element"
"erase"
+ "error"
"exit"
"float"
+ "float_to_binary"
"float_to_list"
"garbage_collect"
"get"
@@ -757,7 +757,7 @@ resulting regexp is surrounded by \\_< and \\_>."
"halt"
"hd"
"integer_to_list"
- "internal_bif"
+ "integer_to_binary"
"iolist_size"
"iolist_to_binary"
"is_alive"
@@ -788,13 +788,13 @@ resulting regexp is surrounded by \\_< and \\_>."
"list_to_tuple"
"load_module"
"make_ref"
+ "max"
+ "min"
"module_loaded"
+ "monitor"
"monitor_node"
"node"
- "node_link"
- "node_unlink"
"nodes"
- "notalive"
"now"
"open_port"
"pid_to_list"
@@ -838,48 +838,102 @@ resulting regexp is surrounded by \\_< and \\_>."
(eval-and-compile
(defvar erlang-ext-bifs
- '("append_element"
+ '("adler32"
+ "adler32_combine"
+ "alloc_info"
+ "alloc_sizes"
+ "append"
+ "append_element"
+ "await_proc_exit"
+ "await_sched_wall_time_modifications"
+ "bitstr_to_list"
"bump_reductions"
+ "call_on_load_function"
"cancel_timer"
- "demonitor"
+ "crasher"
+ "crc32"
+ "crc32_combine"
+ "decode_packet"
+ "delay_trap"
+ "delete_element"
+ "dexit"
+ "dgroup_leader"
"display"
+ "display_nl"
+ "display_string"
+ "dist_exit"
+ "dlink"
+ "dmonitor_node"
+ "dmonitor_p"
+ "dsend"
+ "dt_append_vm_tag_data"
+ "dt_get_tag"
+ "dt_get_tag_data"
+ "dt_prepend_vm_tag_data"
+ "dt_put_tag"
+ "dt_restore_tag"
+ "dt_spread_tag"
+ "dunlink"
+ "external_size"
+ "finish_after_on_load"
+ "finish_loading"
+ "flush_monitor_message"
+ "format_cpu_topology"
"fun_info"
"fun_to_list"
"function_exported"
+ "garbage_collect_message_area"
+ "gather_sched_wall_time_result"
"get_cookie"
+ "get_module_info"
"get_stacktrace"
"hash"
- "integer_to_list"
+ "hibernate"
+ "insert_element"
"is_builtin"
- "list_to_integer"
+ "list_to_bitstr"
+ "load_nif"
"loaded"
"localtime"
"localtime_to_universaltime"
+ "make_fun"
"make_tuple"
- "max"
+ "match_spec_test"
"md5"
"md5_final"
"md5_init"
"md5_update"
"memory"
- "min"
- "monitor"
+ "module_info"
"monitor_node"
+ "nif_error"
"phash"
"phash2"
"port_call"
+ "port_get_data"
"port_info"
+ "port_set_data"
"port_to_list"
"ports"
+ "posixtime_to_universaltime"
+ "prepare_loading"
"process_display"
+ "raise"
"read_timer"
"ref_to_list"
"resume_process"
"send"
"send_after"
"send_nosuspend"
+ "seq_trace"
+ "seq_trace_info"
+ "seq_trace_print"
"set_cookie"
+ "set_cpu_topology"
+ "setnode"
+ "spawn_opt"
"start_timer"
+ "subtract"
"suspend_process"
"system_flag"
"system_info"
@@ -891,6 +945,7 @@ resulting regexp is surrounded by \\_< and \\_>."
"trace_pattern"
"universaltime"
"universaltime_to_localtime"
+ "universaltime_to_posixtime"
"yield")
"Erlang built-in functions (BIFs) that needs erlang: prefix"))
@@ -998,6 +1053,22 @@ behaviour.")
1 'font-lock-function-name-face t))
"Font lock keyword highlighting a function header.")
+(defface erlang-font-lock-exported-function-name-face
+ '((default (:inherit font-lock-function-name-face)))
+ "Face used for highlighting exported functions.")
+
+(defvar erlang-font-lock-exported-function-name-face
+ 'erlang-font-lock-exported-function-name-face)
+
+(defvar erlang-inhibit-exported-function-name-face nil
+ "Inhibit separate face for exported functions")
+
+(defvar erlang-font-lock-keywords-exported-function-header
+ (list
+ (list #'erlang-match-next-exported-function
+ 1 'erlang-font-lock-exported-function-name-face t))
+ "Font lock keyword highlighting an exported function header.")
+
(defvar erlang-font-lock-keywords-int-bifs
(list
(list (concat erlang-int-bif-regexp "\\s-*(")
@@ -1133,7 +1204,8 @@ There exists three levels of Font Lock keywords for Erlang:
`erlang-font-lock-keywords-1' - Function headers and reserved keywords.
`erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'.
`erlang-font-lock-keywords-3' - Variables, macros and records.
- `erlang-font-lock-keywords-4' - Function names, Funs, LCs (not Atoms)
+ `erlang-font-lock-keywords-4' - Exported functions, Function names,
+ Funs, LCs (not Atoms).
To use a specific level, please set the variable
`font-lock-maximum-decoration' to the appropriate level. Note that the
@@ -1175,6 +1247,7 @@ Example:
(defvar erlang-font-lock-keywords-4
(append erlang-font-lock-keywords-3
+ erlang-font-lock-keywords-exported-function-header
erlang-font-lock-keywords-int-function-calls
erlang-font-lock-keywords-ext-function-calls
erlang-font-lock-keywords-fun-n
@@ -1327,7 +1400,6 @@ Other commands:
(erlang-menu-init)
(erlang-mode-variables)
(erlang-check-module-name-init)
- (erlang-add-compilation-alist erlang-error-regexp-alist)
(erlang-man-init)
(erlang-tags-init)
(erlang-font-lock-init)
@@ -1443,31 +1515,6 @@ Other commands:
(set (make-local-variable 'outline-level) (lambda () 1))
(set (make-local-variable 'add-log-current-defun-function)
'erlang-current-defun))
-
-
-;; Compilation.
-;;
-;; The following code is compatible with the standard package `compilation',
-;; making it possible to go to errors using `erlang-next-error' (or just
-;; `next-error' in Emacs 21).
-;;
-;; The normal `compile' command works of course. For best result, please
-;; execute `make' with the `-w' flag.
-;;
-;; Please see the variables named `compiling-..' above.
-
-(defun erlang-add-compilation-alist (alist)
- (require 'compile)
- (cond ((boundp 'compilation-error-regexp-alist) ; Emacs 19
- (while alist
- (or (assoc (car (car alist)) compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist
- (cons (car alist) compilation-error-regexp-alist)))
- (setq alist (cdr alist))))
- ((boundp 'compilation-error-regexp)
- ;; Emacs 18, Only one regexp is allowed.
- (funcall (symbol-function 'set)
- 'compilation-error-regexp (car (car alist))))))
(defun erlang-font-lock-init ()
"Initialize Font Lock for Erlang mode."
@@ -1527,9 +1574,9 @@ Other commands:
. (("\\(?:^\\|[^$]\\)\"\\(?:[^\"\n]\\|\\\\\"\\)*\\(\\$\\)\"" 1 "w")
;; Likewise for atoms
("\\(?:^\\|[^$]\\)'\\(?:[^'\n]\\|\\\\'\\)*\\(\\$\\)'" 1 "w")
- ;; And the dollar sign in $\" escapes two characters, not
- ;; just one.
- ("\\(\\$\\)\\\\\\\"" 1 "'"))))))
+ ;; And the dollar sign in $\" or $\' escapes two
+ ;; characters, not just one.
+ ("\\(\\$\\)\\\\[\"']" 1 "'"))))))
@@ -3689,6 +3736,38 @@ In the future the list may contain more elements."
str)
(store-match-data md))))
+(defun erlang-match-next-exported-function (max)
+ "Returns non-nil if there is an exported function in the current
+buffer between point and MAX."
+ (block nil
+ (while (and (not erlang-inhibit-exported-function-name-face)
+ (erlang-match-next-function max))
+ (when (erlang-last-match-exported-p)
+ (return (match-data))))))
+
+(defun erlang-match-next-function (max)
+ "Searches forward in current buffer for the next erlang function,
+bounded by position MAX."
+ (re-search-forward erlang-defun-prompt-regexp max 'move-point))
+
+(defun erlang-last-match-exported-p ()
+ "Returns non-nil if match-data describes the name and arity of an
+exported function."
+ (save-excursion
+ (save-match-data
+ (goto-char (match-beginning 1))
+ (erlang-function-exported-p
+ (erlang-remove-quotes (erlang-get-function-name))
+ (erlang-get-function-arity)))))
+
+(defun erlang-function-exported-p (name arity)
+ "Returns non-nil if function of name and arity is exported in current buffer."
+ (save-excursion
+ (let* ((old-match-data (match-data))
+ (exports (erlang-get-export)))
+ (store-match-data old-match-data)
+ (member (cons name arity) exports))))
+
;;; Check module name
@@ -4896,7 +4975,6 @@ The following special commands are available:
(set (make-local-variable 'compilation-old-error-list) nil))
;; Needed when compiling directly from the Erlang shell.
(setq compilation-last-buffer (current-buffer))
- (erlang-add-compilation-alist erlang-error-regexp-alist)
(setq comint-prompt-regexp "^[^>=]*> *")
(setq comint-eol-on-send t)
(setq comint-input-ignoredups t)