home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / mutt / builtin / twiddle.mut < prev    next >
Text File  |  1995-01-14  |  2KB  |  61 lines

  1.   ;; twiddle.mut : twiddle characters
  2.   ;; twiddle-left-of-dot:  (C-T in Gosling's or Unipress Emacs)
  3.   ;;   Transpose the 2 characters left of the cursor.  Does nothing if the
  4.   ;;     cursor is within a character of left edge.
  5.   ;;   For example:  to change "abc" to "bac", put the cursor on the "c" and
  6.   ;;     twiddle.
  7.   ;; twiddle-about-dot:  (a bit more like C-T in GNU Emacs)
  8.   ;;   Transpose the characters on either side of the dot.  At the end of a
  9.   ;;     line, does a twiddle-left-of-dot.  Does nothing if the cursor is
  10.   ;;     at the left edge.
  11.   ;;   For example:  to change "abc" to "bac", put the cursor on the "b" and
  12.   ;;     twiddle.
  13.   ;; transpose-chars:  Clone of GNU Emacs transpose-chars.
  14.   ;;
  15.   ;; C Durland    Public Domain
  16.  
  17. (defun
  18.   twiddle-left-of-dot
  19.   {
  20.     (if (< 2 (current-column))
  21.     {
  22.       (previous-character)(looking-at '.')
  23.       (delete-character)
  24.       (previous-character)(insert-text (get-matched '&'))
  25.       (next-character)
  26.     })
  27.   }
  28.   twiddle-about-dot
  29.   {
  30.     (if (looking-at '$')
  31.       (twiddle-left-of-dot)
  32.       (if (next-character) { (twiddle-left-of-dot)(previous-character) })
  33.     )
  34.   }
  35.   transpose-chars        ;; GNU Emacs
  36.   {
  37.     (if (not (previous-character))        ;; beginning of buffer
  38.     { (msg "Can't transpose at the beginning of buffer.")(done) })
  39.     (next-character)
  40.  
  41.     (if (== 1 (current-column))            ;; at the start of the line
  42.       {
  43.     (if (looking-at '$')        ;; empty line
  44.       {
  45.         (delete-previous-character)
  46.         (if (!= 1 (current-column))        ;; before line not empty
  47.           (previous-character))
  48.       }
  49.       {
  50.         (delete-previous-character)
  51.         (next-character)
  52.       })
  53.     (newline)
  54.     (done)
  55.       })
  56.  
  57.     (if (not (looking-at '$')) (next-character))    ;; not end of line
  58.     (twiddle-left-of-dot)
  59.   }
  60. )
  61.