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

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

Re: those strange characters


From: Kevin Rodgers
Subject: Re: those strange characters
Date: Mon, 01 Aug 2005 11:27:11 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Baloff wrote:
> Emilio Lopes <eclig@gmx.net> writes:
> > Baloff <vddr2u <at> bi.edu.gr> writes:
> > > I did
> > > $script somefile
> > > $ls
> > > $exit
> > > $cat somefile
> > > shows the output of $ls
> > >
> > > in emacs, C-x C-f somefile
> > > the output of $ls, each item is listed between ^[[0m group of charactres
> > > on both sided of each item.
> > >
> > > so if I have an item like myFile, it would look ^[[0mmyFile^[[0m
> >
> > Go to the said buffer.  Type "M-:" (`eval-expression').
> > At the prompt type
> >
> >    (ansi-color-apply-on-region (point-min) (point-max))
> >
> > You might need to type "M-x load-library RET ansi-color RET"
> > before.
>
> thanks, now how do I make this fix a permenant action when ever I use
> emacs in the future. do I need to add the 2 lines in my /.emacs file
>
> (load-library "ansi-color")
> (ansi-color-apply-on-region (point-min) (point-max))

No, your .emacs file is loaded with the *scratch* buffer as the current
buffer.  You want the ANSI escape sequences translated when you visit a
script output file.  It would be best if such files could be identified
by name, for example if you used a ".script" extension for them:

(require 'ansi-color)
(add-hook 'find-file-hooks
          (lambda ()
            (when (equal (file-name-extension buffer-file-name) "script")
              (ansi-color-apply-on-region (point-min) (point-max)))))

But if you don't want to adhere to such a convention, you could try
translating all files:

(require 'ansi-color)
(add-hook 'find-file-hooks
          (lambda ()
            (ansi-color-apply-on-region (point-min) (point-max))))

--
Kevin Rodgers





reply via email to

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