Use region as initial search regexp

Marco Wahl <[email protected]> Thu, 23 May 2019 16:19:10 +0200
Newsgroups gmane.emacs.bbdb.user
Message-ID <[email protected]>
Hi!

What do you think about using the region as initial value for
bbdb-search-read?  See the (small amount of) code below.

On the plus side this change eases the path to some contacts sometimes.


Ciao,  Marco
0001-bbdb-search-read-Use-region-as-initial-value-for-sea.patch (text/x-patch, 959 B)
From dffff54d04665e602c75cdc479242e6df0ae3b82 Mon Sep 17 00:00:00 2001
From: Marco Wahl <[email protected]>
Date: Thu, 23 May 2019 15:57:28 +0200
Subject: [PATCH] bbdb-search-read: Use region as initial value for search.

---
 lisp/bbdb-com.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/bbdb-com.el b/lisp/bbdb-com.el
index d0e9879..b239f84 100644
--- a/lisp/bbdb-com.el
+++ b/lisp/bbdb-com.el
@@ -413,7 +413,9 @@ This usage is discouraged."
   "Read regexp to search FIELD values of records."
   (read-string (format "Search records%s %smatching regexp: "
                        (if field (concat " with " field) "")
-                       (if bbdb-search-invert "not " ""))))
+                       (if bbdb-search-invert "not " ""))
+               (when (region-active-p)
+                 (buffer-substring (region-beginning) (region-end)))))
 
 ;;;###autoload
 (defun bbdb (regexp &optional layout)
-- 
2.21.0