Skip to content

Commit ab45c21

Browse files
committed
Merge pull request rost#4 from del/master
Fix so who-calls/function-under-point work correctly when both function definition and body are on a single line
2 parents 5b9e23f + f3b9678 commit ab45c21

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

elisp/erlookup.el

+22
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,18 @@ we are standing on a variable"
167167
(if (eq 'font-lock-variable-name-face (get-text-property (point) 'face))
168168
t nil))
169169

170+
(defvar erl-function-definition-and-call-regex
171+
(concat "^" erlang-atom-regexp "\\s *(.*)\\s-*->.*(.*$")
172+
"Regex for finding functions with definition and body on the same line")
173+
170174
(defvar erl-function-definition-regex
171175
(concat "^" erlang-atom-regexp "\\s *(")
172176
"Regex for finding function definitions")
173177

178+
(defvar erl-function-definition-with-arrow-regex
179+
(concat "^" erlang-atom-regexp "\\s *(.*)\\s-*->.*")
180+
"Regex for finding function definitions to the left of point")
181+
174182
(defun erlang-in-arglist-p ()
175183
(if (erlang-stop-when-inside-argument-list)
176184
(save-excursion
@@ -180,11 +188,20 @@ we are standing on a variable"
180188
t nil))
181189
nil))
182190

191+
(defun erlang-on-function-definition-and-call-p ()
192+
(save-excursion
193+
(beginning-of-line)
194+
(looking-at erl-function-definition-and-call-regex)))
195+
183196
(defun erlang-on-function-definition-p ()
184197
(save-excursion
185198
(beginning-of-line)
186199
(looking-at erl-function-definition-regex)))
187200

201+
(defun erlang-point-left-of-arrow-p ()
202+
(save-excursion
203+
(if (looking-back erl-function-definition-with-arrow-regex)
204+
nil t)))
188205

189206
;;; lookup related things
190207

@@ -341,6 +358,11 @@ we are standing on a variable"
341358
(erl-find-source-pattern-under-point pattern))
342359
((erlang-at-variable-p)
343360
(erl-find-variable-binding))
361+
((erlang-on-function-definition-and-call-p)
362+
(cond ((erlang-point-left-of-arrow-p)
363+
(erl-who-calls (erl-target-node)))
364+
(t
365+
(erl-find-function-under-point))))
344366
((erlang-on-function-definition-p)
345367
(erl-who-calls (erl-target-node)))
346368
(t

0 commit comments

Comments
 (0)