all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs removes whitespaces at the end of lines
@ 2009-08-02 13:28 F. Unglaub
  2009-08-02 16:22 ` David Kastrup
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: F. Unglaub @ 2009-08-02 13:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I use emacs with mutt and slrn (post-mode) and noticed that
whitespaces at the end of lines are auto-removed. This leads to
problems, for example, with the signature delimiter "-- \n". In my
case it's reduced to "--\n" which certain newsreaders like tin
consider wrong.

Also those unused headers should have the trailing whitespace IIRC
(for example Summary, Keywords etc.).

Is there any setting that can circumvent this issue?

Regards.
--
"... the Mayo Clinic, named after its founder, Dr. Ted Clinic ..."
                -- Dave Barry


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-02 13:28 Emacs removes whitespaces at the end of lines F. Unglaub
@ 2009-08-02 16:22 ` David Kastrup
  2009-08-02 16:37 ` Tassilo Horn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: David Kastrup @ 2009-08-02 16:22 UTC (permalink / raw)
  To: help-gnu-emacs

"F. Unglaub" <f.unglaub@gmail.com> writes:

> Hello,
>
> I use emacs with mutt and slrn (post-mode) and noticed that
> whitespaces at the end of lines are auto-removed. This leads to
> problems, for example, with the signature delimiter "-- \n". In my
> case it's reduced to "--\n" which certain newsreaders like tin
> consider wrong.
>
> Also those unused headers should have the trailing whitespace IIRC
> (for example Summary, Keywords etc.).
>
> Is there any setting that can circumvent this issue?

It is not the default, so you have something in your .emacs or other
customizations that does this.

-- 
David Kastrup


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-02 13:28 Emacs removes whitespaces at the end of lines F. Unglaub
  2009-08-02 16:22 ` David Kastrup
@ 2009-08-02 16:37 ` Tassilo Horn
       [not found] ` <mailman.3703.1249231048.2239.help-gnu-emacs@gnu.org>
  2009-08-02 17:58 ` Noah Slater
  3 siblings, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2009-08-02 16:37 UTC (permalink / raw)
  To: help-gnu-emacs

"F. Unglaub" <f.unglaub@gmail.com> writes:

Hi!

> I use emacs with mutt and slrn (post-mode) and noticed that
> whitespaces at the end of lines are auto-removed. This leads to
> problems, for example, with the signature delimiter "-- \n". In my
> case it's reduced to "--\n" which certain newsreaders like tin
> consider wrong.

All newsreaders should consider it wrong, cause it is, well, wrong. :-)

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'.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
       [not found] ` <mailman.3703.1249231048.2239.help-gnu-emacs@gnu.org>
@ 2009-08-02 16:47   ` F. Unglaub
  2009-08-02 18:41     ` Tassilo Horn
       [not found]     ` <mailman.3707.1249238538.2239.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: F. Unglaub @ 2009-08-02 16:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 2009-08-02, Tassilo Horn <tassilo@member.fsf.org> wrote:
> "F. Unglaub" <f.unglaub@gmail.com> writes:
>> I use emacs with mutt and slrn (post-mode) and noticed that
>> whitespaces at the end of lines are auto-removed. This leads to
>> problems, for example, with the signature delimiter "-- \n". In my
>> case it's reduced to "--\n" which certain newsreaders like tin
>> consider wrong.

[...]

> 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.

Could there be anything besides the mentioned hook that could cause
this problem?

Regards.
--
Never lend your car to anyone to whom you have given birth.
                -- Erma Bombeck


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-02 13:28 Emacs removes whitespaces at the end of lines F. Unglaub
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.3703.1249231048.2239.help-gnu-emacs@gnu.org>
@ 2009-08-02 17:58 ` Noah Slater
  3 siblings, 0 replies; 10+ messages in thread
From: Noah Slater @ 2009-08-02 17:58 UTC (permalink / raw)
  To: F. Unglaub; +Cc: help-gnu-emacs

On Sun, Aug 02, 2009 at 03:28:16PM +0200, F. Unglaub wrote:
> I use emacs with mutt and slrn (post-mode) and noticed that
> whitespaces at the end of lines are auto-removed. This leads to
> problems, for example, with the signature delimiter "-- \n". In my
> case it's reduced to "--\n" which certain newsreaders like tin
> consider wrong.

I was getting this too, and I came up with:

  (defun cleanup-buffer ()
    (unless (or (equal major-mode 'makefile-mode)
                (equal major-mode 'makefile-automake-mode)
                (equal major-mode 'makefile-gmake-mode))
      (untabify (point-min) (point-max)))
    (delete-trailing-whitespace)
    (when (equal major-mode 'post-mode)
      (save-excursion
        (goto-char (point-min))
      (while (re-search-forward "^--$" nil t) (replace-match "-- " nil nil)))))

  (add-hook 'write-file-hooks 'cleanup-buffer)

That should add the space back in as you save the file.

Best,

-- 
Noah Slater, http://tumbolia.org/nslater




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-02 16:47   ` F. Unglaub
@ 2009-08-02 18:41     ` Tassilo Horn
       [not found]     ` <mailman.3707.1249238538.2239.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2009-08-02 18:41 UTC (permalink / raw)
  To: help-gnu-emacs

"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.

Please poste the relevant lines of rails-mode, then we'll see if they
are the culprit.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
       [not found]     ` <mailman.3707.1249238538.2239.help-gnu-emacs@gnu.org>
@ 2009-08-03  8:47       ` F. Unglaub
  2009-08-03 10:22         ` Anselm Helbig
  0 siblings, 1 reply; 10+ messages in thread
From: F. Unglaub @ 2009-08-03  8:47 UTC (permalink / raw)
  To: help-gnu-emacs

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)


Regards.
-- 
Troubles are like babies; they only grow by nursing.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-03  8:47       ` F. Unglaub
@ 2009-08-03 10:22         ` Anselm Helbig
  2009-08-03 10:54           ` F. Unglaub
  2009-08-03 11:20           ` Tassilo Horn
  0 siblings, 2 replies; 10+ messages in thread
From: Anselm Helbig @ 2009-08-03 10:22 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

At Mon, 3 Aug 2009 10:47:50 +0200,
"F. Unglaub" <f.unglaub@gmail.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))

HTH, 

Anselm


-- 
Anselm Helbig 
mailto:anselm.helbig+news2009@googlemail.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-03 10:22         ` Anselm Helbig
@ 2009-08-03 10:54           ` F. Unglaub
  2009-08-03 11:20           ` Tassilo Horn
  1 sibling, 0 replies; 10+ messages in thread
From: F. Unglaub @ 2009-08-03 10:54 UTC (permalink / raw)
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs removes whitespaces at the end of lines
  2009-08-03 10:22         ` Anselm Helbig
  2009-08-03 10:54           ` F. Unglaub
@ 2009-08-03 11:20           ` Tassilo Horn
  1 sibling, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2009-08-03 11:20 UTC (permalink / raw)
  To: help-gnu-emacs

Anselm Helbig <anselm.helbig+news2009@googlemail.com> writes:

Hi!

>> > 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)
>> 
>> [...]
>> 
>> (add-hook 'write-file-hooks 'untabify-before-write)

The right approach (if it's really a convention for rails code) would be
to call

   (add-hook 'write-file-hooks 'untabify-before-write nil t)

inside the `rails-mode' function.  The last parameter to `add-hook'
makes this hook buffer-local, so the untabify function would only be run
when saving a file that is in rails-mode.

> 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 think you (or F. Unglaub) should send a bug report to the rails-mode
devs.  Modes must not change global settings.

> 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))

Yes, that's a workaround.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-08-03 11:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-02 13:28 Emacs removes whitespaces at the end of lines F. Unglaub
2009-08-02 16:22 ` David Kastrup
2009-08-02 16:37 ` Tassilo Horn
     [not found] ` <mailman.3703.1249231048.2239.help-gnu-emacs@gnu.org>
2009-08-02 16:47   ` F. Unglaub
2009-08-02 18:41     ` Tassilo Horn
     [not found]     ` <mailman.3707.1249238538.2239.help-gnu-emacs@gnu.org>
2009-08-03  8:47       ` F. Unglaub
2009-08-03 10:22         ` Anselm Helbig
2009-08-03 10:54           ` F. Unglaub
2009-08-03 11:20           ` Tassilo Horn
2009-08-02 17:58 ` Noah Slater

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.