home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34exe.zip
/
mutt
/
contrib
/
zap.mut
< prev
Wrap
Text File
|
1995-01-14
|
2KB
|
64 lines
;; `Zap' for ME3
;; Patrick TJ McPhee 11 July 1993
;;
;; This is meant to work like the zap-to-char command in GNU emacs, with one
;; exception. Here's the documentation:
;; zap-to-char prompts for a character and deletes up-to but not including
;; the (arg-prefix)th occurrence of that character. Suppose the dot
;; were sitting just after the closing parenthesis in the previous sentence.
;; Pressing (by default) M-Z and then `space' would have the same effect
;; as pressing M-D. On the other hand, pressing M-Z and then `f' would
;; delete up to, but not including, the `f' of `of'. In GNU emacs, pressing
;; M-Z f again would have no effect. In my version, if the dot is immediately
;; before the character to be zapped, that instance of the character does not
;; get included in the count. The other difference from GNU: if the character
;; is not found, no deletion takes place (GNU will delete to the end of the
;; buffer). A negative argument causes the search to go backwards.
;; I changed it to work the same as GNU zap-to-char so I could say "same as
;; GNU". Patrick's exceptions probably make more sense but thats now how
;; GNU did it so ... (I wonder if I'm getting too carried with GNU
;; compatibility?) C Durland 7/93
(include me.mh)
(defun
zap-to-char {
(int start number-to-skip)
(string character)
(bool found reverse)
(msg "Zap to char: ")
(character (getchar))
(number-to-skip (arg-prefix))
(arg-flag FALSE 1) ;; reset arg count
(reverse (<= number-to-skip 0))
(set-mark (start (create-mark FALSE)))
(found FALSE)
;; search backwards if negative argument, otherwise forwards
(if reverse {
(while (and
(< (number-to-skip) 0)
(found (search-reverse (character))))
(+= number-to-skip 1))
(forward-char 1)
} {
(while (and
(> (number-to-skip) 0)
(found (search-forward (character))))
(-= number-to-skip 1))
(forward-char -1)
})
(if (not found)
(if reverse (beginning-of-buffer)(end-of-buffer)))
(delete-region start THE-DOT)
}
; MAIN { (bind-to-key "zap-to-char" "M-Z") }
)