help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs removes whitespaces at the end of lines


From: F. Unglaub
Subject: Re: Emacs removes whitespaces at the end of lines
Date: Mon, 3 Aug 2009 12:54:19 +0200
User-agent: slrn/0.9.9p1 (Linux)

On 2009-08-03, Anselm Helbig <anselm.helbig+news2009@googlemail.com> wrote:
>> On 2009-08-02, Tassilo Horn <tassilo@member.fsf.org> wrote:
>> > "F. Unglaub" <f.unglaub@gmail.com> writes:
>> >
>> > Hi!
>> >
>> >>> Back to the problem: Normally, emacs should not do that, so I guess
>> >>> that's something you (or your sysadmin) configured.  Something like:
>> >>>
>> >>>   (add-hook 'before-save-hook 'delete-trailing-whitespace)
>> >>>
>> >>> So grep your ~/.emacs and the files in the site-lisp directory for
>> >>> `delete-trailing-whitespace'.
>> >>
>> >> I can only find delete-trailing-whitespace in my rails-mode.el
>> >> file. And I'm certain that I'm not using rails-mode for posting emails
>> >> and news.
>> >
>> > Well, it could be that rails-mode adds that to some hook globally.  In
>> > the worst case, then simply loading the mode would cause that behavior.
>> 
>> Looks like this is the case here. I removed rails-mode from my .emacs
>> and that seems to solve the problem for me.
>> 
>> > Please poste the relevant lines of rails-mode, then we'll see if they
>> > are the culprit.
>> 
>> Here are the relevant lines: (untabify-file.el)
>> 
>> (defun untabify-before-write ()
>>   "Strip all trailing whitespaces and untabify buffer before
>> save."
>>   (when (and (eq this-command 'save-buffer)
>>              (not (find nil
>>                         untabify-exclude-list
>>                         :if #'(lambda (r)
>>                                 (typecase r
>>                                   (string (string-match r (buffer-name)))
>>                                   (symbol (eq major-mode r)))))))
>>     (save-excursion
>>       (untabify (point-min) (point-max))
>>       (delete-trailing-whitespace))))
>> 
>> (add-hook 'write-file-hooks 'untabify-before-write)
>
> Yes, unfortunately emacs-rails behaves more like rails and not like a
> well-behaved, humble emacs extension should: it just turns on a lot of
> behavior, assuming that you'll probably like it. I'd rather turn stuff
> on that I like than have to turn stuff off that comes into my way... 
>
> If you want to keep emacs-rails and don't want to remove the line
> containing the call to `add-hook', you can just remove the hook after
> untabify-file is loaded:
>
>   (eval-after-load "untabify-file"
>     '(remove-hook 'write-file-hooks 'untabify-before-write))

Thanks a lot, that did the trick.

Regards, Florian.
-- 
What we need is either less corruption, or more chance to participate in it.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]