aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMagnus Henoch <[email protected]>2010-05-20 22:05:40 +0100
committerMagnus Henoch <[email protected]>2010-05-20 22:05:40 +0100
commit85d5b7345e10720d10ea63d79bca282bcd44cdf7 (patch)
tree9fe067808dc4506d0e830b4e9d8427fb9c43bb62 /lib
parentc0895d14994c5e98b1171b0174c70a0244d52f86 (diff)
downloadotp-85d5b7345e10720d10ea63d79bca282bcd44cdf7.tar.gz
otp-85d5b7345e10720d10ea63d79bca282bcd44cdf7.tar.bz2
otp-85d5b7345e10720d10ea63d79bca282bcd44cdf7.zip
Let imenu distinguish functions by arity
Make the function names used by M-x imenu contain the function arity as well as the name. This makes it possible to jump to all functions of the same name, as opposed to only the one that is defined first. For example, in the following module there is now a way to jump directly to foo/1: -module(foo). foo() -> ok. bar() -> error. foo(A) -> {ok, A}.
Diffstat (limited to 'lib')
-rw-r--r--lib/tools/emacs/erlang.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index 0132587d28..8c3afd7f66 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -1402,7 +1402,7 @@ Other commands:
(set (make-local-variable 'imenu-prev-index-position-function)
'erlang-beginning-of-function)
(set (make-local-variable 'imenu-extract-index-name-function)
- 'erlang-get-function-name)
+ 'erlang-get-function-name-and-arity)
(set (make-local-variable 'tempo-match-finder)
"[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=")
(set (make-local-variable 'beginning-of-defun-function)
@@ -3505,6 +3505,13 @@ Normally used in conjunction with `erlang-beginning-of-clause', e.g.:
res)
(error nil)))))
+(defun erlang-get-function-name-and-arity ()
+ "Return the name and arity of the function at point, or nil.
+The return value is a string of the form \"foo/1\"."
+ (let ((name (erlang-get-function-name))
+ (arity (erlang-get-function-arity)))
+ (and name arity (format "%s/%d" name arity))))
+
(defun erlang-get-function-arguments ()
"Return arguments of current function, or nil."
(if (not (looking-at (eval-when-compile