2

I often use helm-lisp-completion-at-point to "search" for elisp symbol names. The problem for me is that if I start the completion with

(line|

it filters the completion candidates to symbols beginning with "line". But sometimes I guessed wrong and the symbol does not begin with "line". When I delete the helm input line it will only show the candidates starting with "line".

How can I always get the full list of completion candidates?

4

There's no way to do this by default, see (glob-syms (and target pred (all-completions target obarray pred))) in the code - it's all pre-determined.

But this is a good thing, since pre-narrowing the candidate list really speeds up the completion. For example, I have 70k symbols bound/fbound in my current session - narrowing them to "line" gives just 12. Of course, 70k isn't that drastic, but you may get a 0.1s delay here and there - perceptible if you use the command a lot.

Here's how to patch the function to do what you want (if you decide to accept the slowdown). The change is (all-completions target obarray pred) -> (all-completions "" obarray pred).

(defun helm-lisp-completion-at-point ()
  "Preconfigured helm for lisp symbol completion at point."
  (interactive)
  (setq helm-lgst-len 0)
  (let* ((target (helm-thing-before-point))
         (beg (car (helm-bounds-of-thing-before-point)))
         (end (point))
         (pred (and beg (helm-lisp-completion--predicate-at-point beg)))
         (loc-vars (and (fboundp 'elisp--local-variables)
                        (ignore-errors
                          (mapcar #'symbol-name (elisp--local-variables)))))
         (glob-syms (and target pred (all-completions "" obarray pred)))
         (candidates (append loc-vars glob-syms))
         (helm-quit-if-no-candidate t)
         (helm-execute-action-at-once-if-one t)
         (enable-recursive-minibuffers t))
    (setq helm-lisp-completion--cache (cl-loop for sym in candidates
                                         for len = (length sym)
                                         when (> len helm-lgst-len)
                                         do (setq helm-lgst-len len)
                                         collect sym))
    (if candidates
        (with-helm-show-completion beg end
          ;; Overlay is initialized now in helm-current-buffer.
          (helm
           :sources (helm-build-in-buffer-source "Lisp completion"
                      :data helm-lisp-completion--cache
                      :persistent-action 'helm-lisp-completion-persistent-action
                      :nomark t
                      :fuzzy-match helm-lisp-fuzzy-completion
                      :persistent-help (helm-lisp-completion-persistent-help)
                      :filtered-candidate-transformer
                      'helm-lisp-completion-transformer
                      :action `(lambda (candidate)
                                 (with-helm-current-buffer
                                   (run-with-timer
                                    0.01 nil
                                    'helm-insert-completion-at-point
                                    ,beg ,end candidate))))
           :input (if helm-lisp-fuzzy-completion
                      target (concat target " "))
           :resume 'noresume
           :buffer "*helm lisp completion*"
           :allow-nest t))
      (message "[No Match]"))))
  • 1
    If you use the patched version, and delete the input you'll get the full list of candidates. – abo-abo Dec 9 '15 at 15:37
  • I edit the question so it is a better match to the answer because the reloading of the helm source seems to be good candidate for a separate question. – clemera Dec 14 '15 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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