From 85d5b7345e10720d10ea63d79bca282bcd44cdf7 Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Thu, 20 May 2010 22:05:40 +0100 Subject: 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}. --- lib/tools/emacs/erlang.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/tools') 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 -- cgit v1.2.3