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 >
Wrap
Text File
|
1995-01-14
|
2KB
|
61 lines
;; twiddle.mut : twiddle characters
;; twiddle-left-of-dot: (C-T in Gosling's or Unipress Emacs)
;; Transpose the 2 characters left of the cursor. Does nothing if the
;; cursor is within a character of left edge.
;; For example: to change "abc" to "bac", put the cursor on the "c" and
;; twiddle.
;; twiddle-about-dot: (a bit more like C-T in GNU Emacs)
;; Transpose the characters on either side of the dot. At the end of a
;; line, does a twiddle-left-of-dot. Does nothing if the cursor is
;; at the left edge.
;; For example: to change "abc" to "bac", put the cursor on the "b" and
;; twiddle.
;; transpose-chars: Clone of GNU Emacs transpose-chars.
;;
;; C Durland Public Domain
(defun
twiddle-left-of-dot
{
(if (< 2 (current-column))
{
(previous-character)(looking-at '.')
(delete-character)
(previous-character)(insert-text (get-matched '&'))
(next-character)
})
}
twiddle-about-dot
{
(if (looking-at '$')
(twiddle-left-of-dot)
(if (next-character) { (twiddle-left-of-dot)(previous-character) })
)
}
transpose-chars ;; GNU Emacs
{
(if (not (previous-character)) ;; beginning of buffer
{ (msg "Can't transpose at the beginning of buffer.")(done) })
(next-character)
(if (== 1 (current-column)) ;; at the start of the line
{
(if (looking-at '$') ;; empty line
{
(delete-previous-character)
(if (!= 1 (current-column)) ;; before line not empty
(previous-character))
}
{
(delete-previous-character)
(next-character)
})
(newline)
(done)
})
(if (not (looking-at '$')) (next-character)) ;; not end of line
(twiddle-left-of-dot)
}
)