0

I am working on adding some functionality to phpunit.el such as selecting from a list of functions found in the current buffer (populated in Helm).

The issue is that I can't get Helm to be populated, even though I can find all the matches and when I dump out the list into the mini-buffer it shows ("test1" "test2" "functionA" "functionB") which is expected.

My code can be found here: https://github.com/eric-hansen/phpunit.el/blob/minor-mode/phpunit.el#L169-190

I've also checked out the multi-term question that was asked on here but didn't help me very much.

2 Answers 2

0

I ran into this problem myself when I was writing a similar function. The problem is that your generating function isn't getting called in the right buffer. (I can't remember which buffer it's actually getting called in--maybe the Helm buffer itself?)

Anyway, the fix is to wrap the generating function in with-helm-current-buffer, like this:

(defun phpunit-helm-get-all-test-candidates ()
  ""
  (with-helm-current-buffer
    (let ((test-functions '())) 
      (save-excursion
        (beginning-of-buffer)
        (while (search-forward-regexp php-beginning-of-defun-regexp nil t)
          (add-to-list 'test-functions
                       (format "%S" (match-string-no-properties 1)))))
      (message "test-functions found ZOMG: %s" test-functions)
      test-functions)))
4
  • I saw that function (with-helm-current-buffer) but couldn't find anything on what it is was for (or I just didn't look enough). I'll give this a whirl and let you know what happens! Commented May 11, 2016 at 16:25
  • Was wondering if you could help me on one more thing... (defvar phpunit-helm-select-test-source '((name . "PHPUnit Tests") (candidates . phpunit-helm-get-all-test-candidates) (action . (lambda (test) (message "Test: %s" test))))) The above shows the actual function name as the only candidate, and even if I wrap it in `() or ,() it still does the same. Commented May 11, 2016 at 16:38
  • Never mind, I got it to work after redoing some stuff. Thanks! I'll mark this as the answer. Commented May 11, 2016 at 16:49
  • So what was the issue? It may be useful for future reference. Commented May 11, 2016 at 20:30
0

Does it work if you remove the quote for the source?

1
  • No, sadly. What I'm wondering is if save-excursion might be causing an issue but what I need to do is search the entire buffer. Commented May 11, 2016 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.