Re: Use region as initial search regexp

Marco Wahl <[email protected]> Sat, 25 May 2019 21:35:00 +0200
Newsgroups gmane.emacs.bbdb.user
Organization Marco Wahl
Message-ID <[email protected]>
"Roland Winkler" <[email protected]> writes:

> On Fri May 24 2019 Basil L. Contovounesios wrote:
>> FWIW, DEFAULT-VALUE is made available for editing via M-n
>> (next-history-element).
>
> Thanks, good to know! - When I wrote the previous message I thought
> that implementing such a scheme n times reinvents the wheel (n-1)
> times.  But this problem has been solved.

Thanks Roland and Basil for the enlightenment.

IIUC you could consider

#v+
(defun bbdb-search-read (&optional field)
  "Read regexp to search FIELD values of records.
When region is active make it available at the prompt via M-n."
  (read-string (format "Search records%s %smatching regexp: "
                       (if field (concat " with " field) "")
                       (if bbdb-search-invert "not " ""))
               nil nil
               (when (region-active-p)
                 (buffer-substring (region-beginning) (region-end)))))
#v-

as a new candidate.

                 
Ciao,
-- 
Marco