Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to edit markdown source in emacs using the It's All Text plugin for firefox.

In markdown you have to add two spaces to the line-end to get a new line. Suppose there is such a newline in a markdown source. If I open this in emacs via It's All Text, change something else and save it then the two spaces at the end of the line dissapear which is very annoying. So is there a way to configure emacs not to touch such spaces at line ends in this case?

share|improve this question
    
I'm far from sure it is an emacs problem and not an "It's All Text" one. Do you reproduce with a simple text file? If yes, does customizing require-final-newline solve your problem? –  AProgrammer Apr 16 '12 at 16:42
    
It's All Text (an excellent! FF plugin) works fine in my emacs.. Yes there is a way to do what you want. It is more a case of do you only want the keep-whitespace behaviour for those particular files, or for all files.. I have my emacs set to keep whitespace... I can't recall off-hand the setting... You will need a hook to some process to be buffer specific.. and that's just a bit out of my scope, but the blanket setting is probably(?) available from the menu in... (not sure though, I don't use the menu_.. –  Peter.O Apr 16 '12 at 16:58
1  
Keeping trailing whitespace is emacs default behaviour, so perhaps you can test it with no extras loaded. Do this by telling It's All Text to launch emacs via restrictive options. The command is emacs -Q, but It's All Text doesn't like the arg, so put the command into a bash script, eg. ita-emacs, and tell It's All Text to run ita-emacs, then test it. (emacs -Q is equivalent to -q --no-site-file --no-splash) –  Peter.O Apr 16 '12 at 17:52
    
@Peter.O Thanks, that helped. After seeing that it worked with emacs -Q I figured out, that I have the following line in my .emacs file: (add-hook 'before-save-hook 'delete-trailing-whitespace) Commenting out this line solved the problem. Perhaps you could convert your comment into an answer then I can accept it. –  student Apr 16 '12 at 18:37

1 Answer 1

up vote 3 down vote accepted

As a follow-on to my comment, the following procedure is often helpful in tracking down what is causing what.. (trial and error testing, really...)...

Keeping trailing whitespace is emacs default behaviour, so perhaps you can test it with no extras loaded. Do this by telling It's All Text to launch emacs via restrictive options. The command is emacs -Q, but It's All Text doesn't like the arg, so put the command into a bash script, eg. ita-emacs, and tell It's All Text to run ita-emacs, then test it. (emacs -Q is equivalent to -q --no-site-file --no-splash) ...

If the spaces are not deleted , then you at least know that it is an emacs issue in the loaded extras..


PS: for anyone who may not have already read all the comments (above), student tested as mentioned, and found the following line in his .emacs file: (add-hook 'before-save-hook 'delete-trailing-whitespace) ... The culprit! :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.