minad / cape

🦸cape.el - Completion At Point Extensions
GNU General Public License v3.0
584 stars 20 forks source link

emacs-lisp-mode and cape #34

Closed hjudt closed 2 years ago

hjudt commented 2 years ago

In your configuration example in the README, you provide the following code: (add-to-list 'completion-at-point-functions #'cape-file)

This works for e.g. text-mode and likely other modes, but I had to add another hook to get it working in emacs-lisp-mode, e.g.:

(use-package cape
  :hook
  ((emacs-lisp-mode . (lambda ()
                        (add-to-list 'completion-at-point-functions #'cape-file))))
…

Otherwise, it seems the hook gets overwritten (could also be a problem with my configuration of course) and only contains in emacs-lisp-buffers: (elisp-completion-at-point t)

I just wanted to add this because it took me a while to figure out why it works in some modes, but not in others (so far, I only know of emacs-lisp-mode). Maybe - if this not only a problem with my config - it would be wise to add a note to some section in the README?

minad commented 2 years ago

The t value in the end of the buffer local hook list ensures that the hooks registered in the global hook list are tried after the elisp capf. Your configuration achieves something different. It puts cape-file before the elisp capf which is usually not desirable.

hjudt commented 2 years ago

You are right, and astonishingly, after removing that :hook it still works as I would expect. I wonder why it did not last time I tried, I've certainly restarted emacs multiple times.