vlion: cut of the flammarion woodcut, colored (Default)
[personal profile] vlion in [community profile] emacs
Hello my fellow Emacs users!

This snippet should give you the abiility to remove those ^M characters you get from time to time if you do much emacs work relating to Windows systems. If the first argument in search-forward doesn't copy over right, it can be inserted with C-q C-m.

Have fun!


(defun remove-dos-line-endings () 
"Removes those pesky ^M from a buffer"
  (interactive)
  (save-excursion 
    (goto-char 0) 
    (while (search-forward " " nil t) 
             (replace-match "" nil t))))

on 2011-12-17 07:54 pm (UTC)
vatine: Generated with some CL code and a hand-designed blackletter font (Default)
Posted by [personal profile] vatine
May be worth sticking a (save-match-data ...) around the body, as well as a (save-excursion ...).

on 2011-12-18 10:15 am (UTC)
vatine: Generated with some CL code and a hand-designed blackletter font (Default)
Posted by [personal profile] vatine
Ah, yes, s/a/the/ (that was what I intended to write, since I saw the save-excursion and thought "aha, I needed to do some match-and-replace yesterday and I used save-match-data".

I was turning spreadsheet columns of "OK" or not into binary numbers, long story, quite boring.

on 2011-12-18 02:59 am (UTC)
jld: (vessel)
Posted by [personal profile] jld
"\C-m" might be a nicer way to get that string into the script.
Edited on 2011-12-18 03:00 am (UTC)

Profile

emacs: Emacs Community Logo (Default)
emacs community

December 2011

S M T W T F S
    123
45678910
1112131415 1617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 26th, 2017 08:27 am
Powered by Dreamwidth Studios