HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/jed/lib/untab.sl
% untabify region function

define untab_convert_to_tabs ()
{
   variable c;
   while (fsearch_char (' '))
     {
	c = what_column ();
	push_mark ();
	skip_white ();
	c = what_column () - c;
	if (c > 1)
	  {
	     del_region ();
	     whitespace (c);
	  }
	else pop_mark_0 ();
     }
}

%!%+
%\function{untab}
%\synopsis{untab}
%\usage{Void untab ();}
%\description
% This function may be used either to convert tabs to spaces or, if called
% with a prefix argument, it will perform the opposite conversion from
% spaces to tabs.  This function operates on a region.
%!%-
define untab ()
{
   check_region (0);
   narrow ();
   bob ();
   if (-1 != prefix_argument (-1))
     {
	untab_convert_to_tabs ();
     }
   else
     {
	while (fsearch ("\t"))
	  {
	     TAB;                       % on stack
	     skip_white ();
	     what_column ();   % on stack
	     bskip_chars ("\t ");
	     () - what_column ();   % on stack
	     trim ();
	     TAB = 0;
	     whitespace (());
	     TAB = ();
	  }
     }

   widen ();
}