From 4d2874bd435b6e678c43dd660688b26548cf4a2d Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sat, 19 May 2018 12:44:03 +0300 Subject: [PATCH] elisp/guile: Fix finding the current definition Reported by Pierre Neidhardt: . Well, it was not really the issue but it is better to define the definition from its start position, anyway. * elisp/guix-guile.el (guix-guile-current-definition): Define the current definition properly when the point is in the beginning of it. --- elisp/guix-guile.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/elisp/guix-guile.el b/elisp/guix-guile.el index 339955f..d56701e 100644 --- a/elisp/guix-guile.el +++ b/elisp/guix-guile.el @@ -39,9 +39,17 @@ (defun guix-guile-current-definition () "Return string with name of the current top-level guile definition." (save-excursion + ;; If the point is in the beginning of the current definition, + ;; `beginning-of-defun' will move it to the previous one, so we + ;; narrow to the definition at first (there is also a commentary + ;; about this problem in `narrow-to-defun'). + (narrow-to-defun) (beginning-of-defun) (if (looking-at guix-guile-definition-regexp) - (match-string-no-properties 1) + (progn + (widen) + (match-string-no-properties 1)) + (widen) (error "Couldn't find the current definition")))) (defun guix-guile-current-module ()