diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc33bdfb..faa46569e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * [#2593](https://github.com/clojure-emacs/cider/issues/2593): The REPL's initial namespace is now set correctly if configured in another tool (e.g. Leiningen's `:init-ns`). * [#2607](https://github.com/clojure-emacs/cider/pull/2607): Use markers for specifying insertion point for `cider-eval-*-to-comment`commands. This fixes a bug where editing the buffer during a pending evaluation resulted in comments appearing in unintended locations. * [#2308](https://github.com/clojure-emacs/cider/issues/2308): Don't rely on the classpath in `cider-library-present-p`. Now it does a `require` instead to check if some library is present or not. +* [#2541](https://github.com/clojure-emacs/cider/issues/2541): Hook properly CIDER's code completion machinery. ## 0.21.0 (2019-02-19) diff --git a/cider-mode.el b/cider-mode.el index 68f3f6552..3cde05d22 100644 --- a/cider-mode.el +++ b/cider-mode.el @@ -1032,9 +1032,7 @@ property." (progn (setq-local sesman-system 'CIDER) (cider-eldoc-setup) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions - #'cider-complete-at-point) + (add-hook 'completion-at-point-functions #'cider-complete-at-point nil t) (font-lock-add-keywords nil cider--static-font-lock-keywords) (cider-refresh-dynamic-font-lock) (font-lock-add-keywords nil cider--reader-conditionals-font-lock-keywords) @@ -1050,6 +1048,7 @@ property." (setq-local clojure-get-indent-function #'cider--get-symbol-indent)) (setq-local clojure-expected-ns-function #'cider-expected-ns) (setq next-error-function #'cider-jump-to-compilation-error)) + ;; Mode cleanup (mapc #'kill-local-variable '(completion-at-point-functions next-error-function x-gtk-use-system-tooltips @@ -1059,7 +1058,8 @@ property." (font-lock-add-keywords nil cider--reader-conditionals-font-lock-keywords) (font-lock-remove-keywords nil cider--dynamic-font-lock-keywords) (font-lock-remove-keywords nil cider--static-font-lock-keywords) - (cider--font-lock-flush))) + (cider--font-lock-flush) + (remove-hook 'completion-at-point-functions #'cider-complete-at-point t))) (defun cider-set-buffer-ns (ns) "Set this buffer's namespace to NS and refresh font-locking." diff --git a/cider-repl.el b/cider-repl.el index d284954ad..9a701cf65 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -1676,9 +1676,6 @@ constructs." (cider-repl-wrap-fontify-function font-lock-fontify-region-function)) (setq-local font-lock-unfontify-region-function (cider-repl-wrap-fontify-function font-lock-unfontify-region-function)) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions - #'cider-complete-at-point) (set-syntax-table cider-repl-mode-syntax-table) (cider-eldoc-setup) ;; At the REPL, we define beginning-of-defun and end-of-defun to be @@ -1693,6 +1690,7 @@ constructs." (cider-repl-history-load cider-repl-history-file) (add-hook 'kill-buffer-hook #'cider-repl-history-just-save t t) (add-hook 'kill-emacs-hook #'cider-repl-history-just-save)) + (add-hook 'completion-at-point-functions #'cider-complete-at-point nil t) (add-hook 'paredit-mode-hook (lambda () (clojure-paredit-setup cider-repl-mode-map)))) (provide 'cider-repl)