home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
builtin
/
search.mut
< prev
next >
Wrap
Text File
|
1995-01-14
|
2KB
|
85 lines
;; search.mut : For those times when you don't want to use incremental
;; search.
;; C Durland Public Domain
(string search-pattern re-search-pattern)
(defun
MAIN
{
; (bind-to-key "forward-search" "C-s")
; (bind-to-key "reverse-search" "C-r")
(bind-to-key "forward-re-search" "M-C-s")
}
forward-search
{
(and
(get-search-pattern "Forward search" search-pattern)
(not (search-forward search-pattern))
{ (msg "Not found") FALSE })
}
reverse-search
{
(and
(get-search-pattern "Reverse search" search-pattern)
(not (search-reverse search-pattern))
{ (msg "Not found") FALSE })
}
forward-re-search
{
(and
(get-search-pattern "Forward RE search" re-search-pattern)
(not (re-search-forward re-search-pattern))
{ (msg "Not found") FALSE })
}
reverse-re-search
{
(and
(get-search-pattern "Reverse RE search" re-search-pattern)
(not (re-search-reverse re-search-pattern))
{ (msg "Not found") FALSE })
}
)
;; Some routines copied from qr.mut
(defun
get-search-pattern (string prompt pattern replace-pattern-default) HIDDEN
{
(string pat)
(pat (prompt-and-ask prompt pattern))
(if (== "" pat) ;; user hit Enter so use default
{
(if (== "" pattern) ;; no default
{ (msg "Gotta search for something!") FALSE (done) })
;; old pattern exists and is good so use it
}
(if (== "^W" pat) ;; C-W => look for word cursor is on
{
(if (looking-at '\w+')
{
;;(replace-pattern-default "") ;; clear replace pattern default
(pattern (get-matched '&')) ;; use user entered pattern
}
{ (msg "Not a word!") FALSE (done) })
}
{
;;(replace-pattern-default "") ;; clear replace pattern default
(pattern pat) ;; use user entered pattern
}))
TRUE
}
; prompt-and-ask (string prompt pattern) HIDDEN
; {
; (ask-user)
; (ask
; prompt
; (if (!= "" pattern) ;; old pattern exists
; (concat " [" pattern "]") ;; prompt [pattern]:
; "")
; ": ")
; }
)