From f3b9678b26a4b4e8b4bcd45ae25213364930b6fd Mon Sep 17 00:00:00 2001 From: Daniel Eliasson Date: Fri, 30 Mar 2012 14:56:39 +0200 Subject: [PATCH] Fix so who-calls/function-under-point work correctly when both function definition and body are on a single line --- elisp/erlookup.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/elisp/erlookup.el b/elisp/erlookup.el index 2c5189d..4bd63d9 100644 --- a/elisp/erlookup.el +++ b/elisp/erlookup.el @@ -167,10 +167,18 @@ we are standing on a variable" (if (eq 'font-lock-variable-name-face (get-text-property (point) 'face)) t nil)) +(defvar erl-function-definition-and-call-regex + (concat "^" erlang-atom-regexp "\\s *(.*)\\s-*->.*(.*$") + "Regex for finding functions with definition and body on the same line") + (defvar erl-function-definition-regex (concat "^" erlang-atom-regexp "\\s *(") "Regex for finding function definitions") +(defvar erl-function-definition-with-arrow-regex + (concat "^" erlang-atom-regexp "\\s *(.*)\\s-*->.*") + "Regex for finding function definitions to the left of point") + (defun erlang-in-arglist-p () (if (erlang-stop-when-inside-argument-list) (save-excursion @@ -180,11 +188,20 @@ we are standing on a variable" t nil)) nil)) +(defun erlang-on-function-definition-and-call-p () + (save-excursion + (beginning-of-line) + (looking-at erl-function-definition-and-call-regex))) + (defun erlang-on-function-definition-p () (save-excursion (beginning-of-line) (looking-at erl-function-definition-regex))) +(defun erlang-point-left-of-arrow-p () + (save-excursion + (if (looking-back erl-function-definition-with-arrow-regex) + nil t))) ;;; lookup related things @@ -341,6 +358,11 @@ we are standing on a variable" (erl-find-source-pattern-under-point pattern)) ((erlang-at-variable-p) (erl-find-variable-binding)) + ((erlang-on-function-definition-and-call-p) + (cond ((erlang-point-left-of-arrow-p) + (erl-who-calls (erl-target-node))) + (t + (erl-find-function-under-point)))) ((erlang-on-function-definition-p) (erl-who-calls (erl-target-node))) (t