[ale] Make emacs show "invisible" characters
Michael B. Trausch
fd0man at gmail.com
Tue Nov 21 20:22:04 EST 2006
On Fri, 2006-11-17 at 17:34 -0500, William Bagwell wrote:
> On Thursday 16 November 2006 05:10 pm, JK wrote:
> > I used to know how to do this, but neither my brain
> > nor Google is my friend today.
> >
> > I'm editing a source file that has line-ending issues --
> > it's got a mix of DOS and Unix line endings. I know
> > there is a way to provoke emacs to explicitly display
> > the line-ending characters (^M, ^J, etc) and other
> > normally "invisible" whitespace, but I can't find it.
> > Any clues?
>
> Sorry no clue how to do this in emacs. But if you got a private reply
> please share. I would be intersted in showing line feeds in *any* text
> editor. Recently needed to do something similar, and resorted to using a
> hex editor. Fortunately it was a short script...
The best solution that I can think of (at the moment...) comes from a
web site (http://xahlee.org/emacs/emacs_adv_tips.html) that tells how to
change the file line endings:
M-x set-buffer-file-coding-system
Or:
C-x RET f
There are a ton of options for it, but you can use utf-8 (which relies
on the host system, I would presume), utf-8-dos, utf-8-mac, and
utf-8-unix.
I created a file in the buffer, and set the option and did a Save As for
it in different modes, and it came out just as expected by converting
the newlines before writing the file to disk:
fd0man at pepper:~[0]$ xxd DOS_UTF-8
0000000: 5465 7374 696e 6720 666f 7220 444f 5320 Testing for DOS
0000010: 5554 462d 3820 4d6f 6465 2e0d 0a0d 0a48 UTF-8 Mode.....H
0000020: 6f77 2064 6f20 7468 6520 6c69 6e65 2065 ow do the line e
0000030: 6e64 696e 6773 2077 6f72 6b3f ndings work?
fd0man at pepper:~[0]$ xxd Macintosh_UTF-8
0000000: 5465 7374 696e 6720 666f 7220 444f 5320 Testing for DOS
0000010: 5554 462d 3820 4d6f 6465 2e0d 0d48 6f77 UTF-8 Mode...How
0000020: 2064 6f20 7468 6520 6c69 6e65 2065 6e64 do the line end
0000030: 696e 6773 2077 6f72 6b3f ings work?
fd0man at pepper:~[0]$ xxd UNIX_UTF-8
0000000: 5465 7374 696e 6720 666f 7220 444f 5320 Testing for DOS
0000010: 5554 462d 3820 4d6f 6465 2e0a 0a48 6f77 UTF-8 Mode...How
0000020: 2064 6f20 7468 6520 6c69 6e65 2065 6e64 do the line end
0000030: 696e 6773 2077 6f72 6b3f ings work?
fd0man at pepper:~[0]$
The important part to look at would be line 0000010, sixth block in,
second character onward. The file itself in plaintext:
Testing for DOS UTF-8 Mode.
How do the line endings work?
-- Mike
--
Michael B. Trausch
fd0man at gmail.com
Phone: (404) 592-5746
Jabber IM: fd0man at livejournal.com
Demand Freedom! Use open and free protocols, standards, and software!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ale
mailing list