cperl-mode vs vi 
Author Message
 cperl-mode vs vi

i use emacs (just started using cperl-mode), the rest of my team uses emacs.
they check in code with tabs, i check in code with spaces. heartache ensues.

i've explored a bit, and it seems that cperl-mode, perl-mode, c-mode, java-mode
all indent with spaces, none with tabs. fine. it sounds like i need some type of
perl-mode hook that will run through the entire buffer and replace each tab
character with the appropriate number of spaces. anything like that built into
cperl-mode or emacs that i dont know about? alternatively, is there a variant of
indent for perl that would achieve the same effect?

--
Brian Moseley
Agent of Chaos - Critical Path



Sun, 14 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi

  bm> i've explored a bit, and it seems that cperl-mode, perl-mode,
  bm> c-mode, java-mode all indent with spaces, none with tabs. fine.

You didn't explore far enough! :)

Turn your Emacs help facility on the variable (C-h v) indent-tabs-mode.

  bm> it sounds like i need some type of perl-mode hook that will run
  bm> through the entire buffer and replace each tab character with the
  bm> appropriate number of spaces. anything like that built into
  bm> cperl-mode or emacs that i dont know about?

Next, examine the functions (C-h f) tabify, tabify-buffer, untabify, and
untabify-buffer.

--
-------------------------------------------------------------------------------

 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
     These are my opinions--Bay Networks takes no responsibility for them.



Sun, 14 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi

Quote:

>   bm> it sounds like i need some type of perl-mode hook that will run
>   bm> through the entire buffer and replace each tab character with the
>   bm> appropriate number of spaces. anything like that built into
>   bm> cperl-mode or emacs that i dont know about?

> Next, examine the functions (C-h f) tabify, tabify-buffer, untabify, and
> untabify-buffer.

ah yes. it looks like i could either tabify-buffer when writing the file or
untabify-buffer when finding the file. i've very little elisp knowledge .. can
somebody provide the code for this functionality, or at least name the hooks i
should be using?

oh and, tabify-buffer and untabify-buffer don't seem to be available :) i'm
using 20.2.1.

--
Brian Moseley
Agent of Chaos - Critical Path



Sun, 14 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi
On Wed, 29 Jul 1998 15:34:16 -0700,

Quote:
> i use emacs (just started using cperl-mode), the rest of my team
> uses emacs.  they check in code with tabs, i check in code with
> spaces.  heartache ensues.

Well that's because you should be using vi. :)

Quote:
> i've explored a bit, and it seems that cperl-mode, perl-mode,
> c-mode, java-mode all indent with spaces, none with tabs.  fine.
> it sounds like i need some type of perl-mode hook that will run
> through the entire buffer and replace each tab character with the
> appropriate number of spaces.  anything like that built into
> cperl-mode or emacs that i dont know about?  alternatively, is
> there a variant of indent for perl that would achieve the same
> effect?

Look at expand(1) and unexpand(1).

--
Brian Moore                             Kill A Spammer For Jesus
Sysadmin, C/Perl Hacker, Usenet Vandal



Mon, 15 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi

15:34:16 -0700, Brian Moseley (a) felt the following information
to be of use:
Quote:
> i use emacs (just started using cperl-mode), the rest of my team uses emacs.
> they check in code with tabs, i check in code with spaces. heartache ensues.

> i've explored a bit, and it seems that cperl-mode, perl-mode, c-mode, java-mode
> all indent with spaces, none with tabs. fine. it sounds like i need some type of
> perl-mode hook that will run through the entire buffer and replace each tab
> character with the appropriate number of spaces. anything like that built into
> cperl-mode or emacs that i dont know about? alternatively, is there a variant of
> indent for perl that would achieve the same effect?

If you just want to replace all tabs with a number of spaces, do
this:

perl -i -pe 's/\t/    /g;' file1 file2 file3 etc

Converting back to tabs is not easily done with a single regex,
as you have to take quotes, etc into account.

Hope this helps!

--Matthew



Mon, 15 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi
 [courtesy cc of this posting sent to cited author via email]


:perl -i -pe 's/\t/    /g;' file1 file2 file3 etc

That is terrible wrong!  How much it expands depends on where the
tab falls.  This is the standard algorithm:

  perl -i -pe '1 while s/\t+/' ' x (length($&)*8 - length($`)%8)/e'

Or, more normally, just

    :1,$perl -i -pe '1 while s/\t+/' ' x (length($&)*8 - length($`)\%8)/e'

The standard expand program does this, of course.

But the question arises: why is this a problem for you?  

--tom

:set sw=4
:map! ^O {^M}^[O^T

--
    I know it's weird, but it does make it easier to write poetry in perl.    :-)



Mon, 15 Jan 2001 03:00:00 GMT  
 cperl-mode vs vi

  > i use emacs (just started using cperl-mode), the rest of my team
  > uses emacs.  they check in code with tabs, i check in code with
  > spaces. heartache ensues.

I don't understand where the problem is.  Do they have a problem
reading your files, or vice versa?  (A possible problem could occur
when they have set their tab-width to be something different than 8,
and you have written a file using tabs assuming a width of 8.  Or have
*you* changed tab-width?)

There is a variable indent-tabs-mode which controls whether
indentation inserts spaces only or tabs/spaces combinations.

kai
--
Abort this operation?   [Abort]  [Cancel]



Mon, 15 Jan 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Emacs cperl-mode.el vs font-lock/lazy-lock

2. Enhanced cperl-mode.el (Perl editing mode for Emacs)

3. cperl-mode: Another perl mode for Gnuemacs

4. Perl and Emacs question - perl debugging mode & cperl-mode vs perl-mode??

5. cperl-mode.el version for emacs21.1.1

6. cperl-mode in Emacs

7. xemacs and cperl-mode

8. Where can I find cperl-mode.el

9. cperl-mode.el troubles on XEmacs.

10. Anyone else have cperl-mode problems?

11. cperl-mode.el 1.8 available

12. Newer cperl-mode.el

 

 
Powered by phpBB® Forum Software