Loading ...
Sorry, an error occurred while loading the content.

Spotless Macro

Expand Messages
  • Jon Green
    Heres a macro that I am using a lot these days, called spotless . It s a varient of clean but it also reduces multiple blank lines to a single blank line.
    Message 1 of 1 , Jun 6, 2000
    • 0 Attachment
      Heres a macro that I am using a lot these days, called
      "spotless". It's a varient of "clean" but it also reduces
      multiple blank lines to a single blank line.

      May be useful - should it be added to the standard macros ??
      Add to your <user>.emf to use.

      Regards
      Jon.

      define-macro spotless
      ;
      ; Prepare to clean up file.
      ; Remember line & magic mode
      set-variable #l0 $window-line
      set-variable #l1 ¬ &bmod magic
      !if #l1
      1 buffer-mode "magic"
      !endif
      ;
      ; Get rid of trailing white space on EOL
      beginning-of-buffer
      replace-string "[\t ]+$" ""
      beginning-of-buffer
      replace-string "[ ]+\t" "\t"
      ;
      ; Strip trailing blank lines.
      end-of-buffer
      backward-line
      !while &and &gre $window-line 1 &sequal @wc "\n"
      kill-line
      -1 yank
      backward-line
      !done
      ;
      ; Reduce multiple blank lines to single blanks.
      ;
      !repeat
      beginning-of-buffer
      replace-string "\n\n\n" "\n\n"
      beginning-of-buffer
      !force search-forward "\n\n\n"
      !until ¬ $status
      ;
      ; Clean up - restore buffer modes etc.
      ; Move back to starting line & restore original magic mode
      !force goto-line #l0
      !if #l1
      -1 buffer-mode "magic"
      !endif
      screen-update
      ml-write "[Cleaned up buffer]"
      !emacro
    Your message has been successfully submitted and would be delivered to recipients shortly.