(defun stolfi-python-find-module-and-proc-def (arg) "Expects to be called when the point is within or adjacent to a function call of the form {modproc} consisting of one or more letters, digits, periods (\".\"), and underscores (\"_\"). If {modproc} has at least one period, splits it into \"{module}.{proc}\" at the last period and searches for the file \"{module}.py\" in the current directory or some near ancestor thereof, with each period in {module} replaced by a slash (\"/\"). If it finds such a file, visits it, otherwise gives an error message. If there are no periods in {modproc}, uses the current buffer instead, and takes {proc} to be {modproc}. Either way, searches in that buffer for the presumed definition of {proc}. With a prefix arg, uses the current window, else an alternate window. [stolfi]" (interactive "P") (let* ( ( modproc (stolfi-grab-module-and-proc "[^.a-zA-Z0-9_]") ) mcomps fname proc defpat found-module ) ; (message (concat "py-vmap: modproc = " modproc)) (if modproc (progn (setq mcomps (split-string modproc "[.]") ) ; (message (concat "py-vmap: mcomps = " (prin1-to-string mcomps))) (setq proc (car (last mcomps))) ; (message (concat "py-vmap: proc = " (prin1-to-string proc))) (setq mcomps (butlast mcomps)) ; (message (concat "py-vmap: mcomps = " (prin1-to-string mcomps))) (setq defpat (concat "^[ ]*def[ ]+" proc "\\b")) ; (message (concat "py-vmap: defpat = " (prin1-to-string defpat))) (setq fname (concat (string-join mcomps "/") ".py")) ; (message (concat "py-vmap: fname = " (prin1-to-string fname))) (setq found-module (stolfi-visit-module-and-proc arg fname defpat)) ; (message (concat "py-vmap: found-module = " (prin1-to-string found-module))) ) (error "no valid function call here") ) ) )