purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

Two completion pop-ups in php-mode #764

Closed quimm2003 closed 3 years ago

quimm2003 commented 3 years ago

Hi Steve. Thank you for your work, I'm using your config and enjoying it.

I'm experiencing a strange thing when using completion in PHP mode. There are two pop-ups with completion choices as shown in the image.

two_popups

I'm using Emacs 26 under Debian 9. I've not changed your configs for php or company.

I've added this hook for php-mode:

(add-hook 'php-mode-hook
          '(lambda ()
             ;; Enable auto-complete-mode
             (auto-complete-mode t)

             (require 'ac-php)
             (setq ac-sources '(ac-source-php))

             (set (make-local-variable 'company-backends)
                  '((company-ac-php-backend company-dabbrev-code)
                    company-capf company-files))

             ;; ;; Enable ElDoc support (optional)
             (ac-php-core-eldoc-setup)

             ;; ;; Jump to definition (optional)
             (define-key php-mode-map (kbd "M-]")
               'ac-php-find-symbol-at-point)

             ;; ;; Return back (optional)
             (define-key php-mode-map (kbd "M-[")
               'ac-php-location-stack-back)

             ;; uncomment-region
             (define-key php-mode-map "\C-u\C-c\C-c" 'uncomment-region)))

Disabling auto-complete-mode or commenting ac-php related things does not help, nor does deleting ac-php.

Any ideas?

Thank you very much.

purcell commented 3 years ago

Disabling auto-complete-mode or commenting ac-php related things does not help, nor does deleting ac-php.

It's probably unsurprising that you'd get two pop-ups if you have both enabled, but it's strange that disabling auto-complete-mode wouldn't change things. I'd guess that some parts of it are still active in the buffer. If you've been modifying the lambda then you might have ended up with multiple variations of it in php-mode-hook. Turn the lambda into a redefinable named function to make it easier to experiment.

BTW, you'd including code that should only be executed once - like loading libraries and modifying the global php-mode keymap - in a function that is called every time you open a php buffer. Better to put that code at the top level.

quimm2003 commented 3 years ago

You are right. The problem was the lambda function being called when opening a php buffer.

Thank you very much!

purcell commented 3 years ago

Great, glad you figured it out. BTW, auto-complete-mode is rather obsolete these days, so I'd recommend doing without it if you can.