PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/jed-0.99-19/lib/untab.sl

#
Unknown | 59 lines | 53 code | 6 blank | 0 comment | 0 complexity | a751c9e787a24ea5043a11b3b3213035 MD5 | raw file
Possible License(s): GPL-2.0
  1. % untabify region function
  2. define untab_convert_to_tabs ()
  3. {
  4. variable c;
  5. while (fsearch_char (' '))
  6. {
  7. c = what_column ();
  8. push_mark ();
  9. skip_white ();
  10. c = what_column () - c;
  11. if (c > 1)
  12. {
  13. del_region ();
  14. whitespace (c);
  15. }
  16. else pop_mark_0 ();
  17. }
  18. }
  19. %!%+
  20. %\function{untab}
  21. %\synopsis{untab}
  22. %\usage{Void untab ();}
  23. %\description
  24. % This function may be used either to convert tabs to spaces or, if called
  25. % with a prefix argument, it will perform the opposite conversion from
  26. % spaces to tabs. This function operates on a region.
  27. %!%-
  28. define untab ()
  29. {
  30. check_region (0);
  31. narrow ();
  32. bob ();
  33. if (-1 != prefix_argument (-1))
  34. {
  35. untab_convert_to_tabs ();
  36. }
  37. else
  38. {
  39. while (fsearch ("\t"))
  40. {
  41. TAB; % on stack
  42. skip_white ();
  43. what_column (); % on stack
  44. bskip_chars ("\t ");
  45. () - what_column (); % on stack
  46. trim ();
  47. TAB = 0;
  48. whitespace (());
  49. TAB = ();
  50. }
  51. }
  52. widen ();
  53. }