Search code examples
emacsruby-mode

emacs: ruby mode after reindent-then-newline-and-indent


i am using emacs 23.2 and reference configurations from purcell https://github.com/purcell/emacs.d i met a problem when i am edit ruby file and rails file, see belowenter image description here

steps:
1. move the cursor to somewhere
2. hit "RET" key to add more new line, then move the cursor to somewhere
3. the red space happened at the last new line.

do you know how to turn this mark off?


Solution

  • What's your problem with this feature? The red space goes away as soon as you start typing doesn't it?

    The feature is show-trailing-whitespace, and it's meant to help you see spurious space at EOL. Which is very helpful for team development environment, as checking in such code will annoy your teammates.

    What you should do is add a before-save-hook that removes spurious whitespace see:

    http://www.emacswiki.org/emacs/DeletingWhitespace#toc3

    code:

    (add-hook 'before-save-hook 'delete-trailing-whitespace)
    

    If you want to disable show-trailing-whitespace as well:

    (add-hook 'ruby-mode-hook (lambda ()
                                (setq show-trailing-whitespace nil)))