senny / emacs-eclim

This project brings some of the great eclipse features to emacs developers. It is based on the eclim project, which provides eclipse features for vim.
http://www.emacswiki.org/emacs/EmacsEclim
587 stars 102 forks source link

Completion using company mode does not work well with whitespace mode cleanup enabled. #246

Open yesudeep opened 9 years ago

yesudeep commented 9 years ago

Namaste,

Here's my configuration for whitespace-mode:

;; Use whitespace mode. Cleans up trailing spaces, shows tabs, unnecessary
;; whitespace, EOF newline, bad indentation, margin bleeds, etc.
(require 'whitespace)
(global-whitespace-mode t)
(setq whitespace-style
      '(face empty indentation lines-tail newline trailing)
      whitespace-action '(auto-cleanup warn-read-only)
      whitespace-line-column 80)

Somewhere in the completion routines, emacs-eclim saves the buffer to disk, which triggers a call to whitespace-cleanup, so by the time autocompletion suggestions can be displayed, the pointer moves one character to the left as a result of the trailing space being removed.

I'm not sure why completion needs saving the buffer. Can this be reworked in some way so that completion does not require saving the file? I'd most certainly like to clean up trailing whitespace automatically!

Thank you. :)

Cheers, Yesudeep.

yesudeep commented 9 years ago

I've currently worked around this by disabling automatic whitespace sanitization for java-mode (although this is not a real solution):

(add-hook 'java-mode-hook (lambda ()
                        (setq c-basic-offset 2
                              tab-width 2
                              indent-tabs-mode nil)
                        (eclim-mode t)
                        ;; Whitespace mode does not work well with completion in java mode with eclim.
                        (set (make-local-variable 'whitespace-action) nil)
                        ))
jchochli commented 9 years ago

AFAIK the buffer has to be saved for eclipse to pick up the changes.

How about trying a before-save-hook and maybe this package https://github.com/purcell/whitespace-cleanup-mode?