branch: elpa/swift-mode
commit c67b950d019041a98742443320d898810ce78357
Author: John <j...@olivetoast.com>
Commit: John <j...@olivetoast.com>

    Fixes which-function-mode hang when running swift-mode:current-defun-name 
in a non swift-mode buffer.
    
    This affected users who have which-function-mode enabled globally.
---
 swift-mode.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/swift-mode.el b/swift-mode.el
index 063c967..d3159e9 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -215,7 +215,9 @@ Signal `scan-error' if it hits opening parentheses."
 
   (delete-overlay swift-mode:anchor-overlay)
 
-  (add-hook 'which-func-functions #'swift-mode:current-defun-name)
+  (add-hook 'which-func-functions (lambda ()
+                                    (when (equal (with-current-buffer 
(current-buffer) major-mode) 'swift-mode)
+                                      (swift-mode:current-defun-name))))
   (setq-local add-log-current-defun-function #'swift-mode:current-defun-name))
 
 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.swift\\'" . swift-mode))

Reply via email to