Author Topic: Expand tabs to spaces woes  (Read 5545 times)

Mr68360

  • Community Member
  • Posts: 57
  • Hero Points: 3
Expand tabs to spaces woes
« on: March 22, 2007, 06:07:06 PM »
[This is a repost of my last response to a thread in 2007 Beta subgroup regarding the issue of being able to select "expand tabs to spaces" on a per-filetype basis.  Bringing it here 'cause I just want make sure you see it, SlickEdit  ;) ]


I do check "Expand to Spaces" because I do not want c/cpp/h files to have tabs (ASCII 09) in them, but I do want makefiles to have them.

gnu make will treat leading spaces in target actions as illegal: one MUST use the actual tab character in the file.  c/cpp/h files, on the other hand, benefit from no tabs because if other developers happen to have a different tab setting, they will see the code displayed funny.

Being in charge of makefiles here, I edit them a lot.  Right now, I have to use another editor to edit them, because "Expand to Spaces" is more important to keep for c/cpp/h files; I would have to close all c/cpp/h files, uncheck "Expand to Spaces", then open and edit makefiles, then reverse the setup.  (The other day, I loaded up and edited all my makefiles.  That little conversion cost me about an hour's work--I had to reenter leading tabs--but not everywhere in the file, so I couldn't use a space-to-tab utility!)

Moving "Expand to Spaces" into the file extension dialog would be a big, helpful deal for me, and for anyone else who maintains makefiles (or any other file that requires hard ASCII 09 tabs).

Hey, SlickEdit--I'm begging here!


 

Phil Barila

  • Senior Community Member
  • Posts: 745
  • Hero Points: 61
Re: Expand tabs to spaces woes
« Reply #1 on: March 22, 2007, 07:23:52 PM »
I've asked for this before, and I hope SE is going to give it for us.  Until then, you can mostly work around it by only converting tabs to spaces on open, but not on save, and then doing a Ctrl+Z first, before you do anything else, each time you open a makefile.  Yes it's inconvenient.  Workarounds usually are less convenient or desirable in some way than having it work the way you want without the workaround.  But it's a whole lot more convenient than having to fix them all.
You can also run two instances of SE, from two different configs, one with the tab conversion on, and the other with tab conversion off, that you start from different launchers.  Search the archive for the command line switches for running multiple instances, and specifying different configs for each.  Only edit makefiles in your SE instance that doesn't convert tabs to spaces, and only edit source files in the instance that does.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Expand tabs to spaces woes
« Reply #2 on: March 22, 2007, 08:25:43 PM »
I'd propose instead of adding that attribute to every extension there should be a single exclusion list for the extensions to which the (global) auto-conversion shouldn't be applied.
Another way would be to skip the conversion for file types where 'Indent with tabs' is configured.
For these it doesn't make much sense to convert'em on save, right ?
For the time being you could add this patch (v12 based - but it's the same on v11)

saveload.e - build_save_options() [line 535]:
Code: [Select]
   ext = _bufname2ext ( filename );
   _str indent_with_tabs = 0;
   parse name_info(find_index('def_setup_'ext,MISC_TYPE)) with 'IWT='indent_with_tabs',';
   if (isinteger(indent_with_tabs) && indent_with_tabs) {
      options=stranslate( options,'-E', '+E', 'I' );
   }

If you don't want to patch the installed file just rip just the function to your macro collection and load it.
It overloads the org. command - until you install the next patch or sth.

HS2

BTW: Made a build env based on good old make last time - so I know make's weird TAB sensitivity ;)
« Last Edit: March 22, 2007, 08:33:34 PM by hs2 »