diff --git a/src/calibre/gui2/preferences/search.py b/src/calibre/gui2/preferences/search.py
index e41f2f50b6..936d1a2e9e 100644
--- a/src/calibre/gui2/preferences/search.py
+++ b/src/calibre/gui2/preferences/search.py
@@ -26,6 +26,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('search_as_you_type', config)
r('highlight_search_matches', config)
r('limit_search_columns', prefs)
+ r('use_primary_find_in_search', prefs)
r('limit_search_columns_to', prefs, setting=CommaSeparatedList)
fl = db.field_metadata.get_search_terms()
self.opt_limit_search_columns_to.update_items_cache(fl)
diff --git a/src/calibre/gui2/preferences/search.ui b/src/calibre/gui2/preferences/search.ui
index 33c61dd215..7e41b9e40f 100644
--- a/src/calibre/gui2/preferences/search.ui
+++ b/src/calibre/gui2/preferences/search.ui
@@ -29,6 +29,18 @@
-
+
+
+ Base characters match accented characters
+
+
+ Characters typed in the search box will match their
+accented versions, using language rules. For example, in
+English, searching for e will match é and è.
+
+
+
+ -
What to search by default
@@ -77,7 +89,7 @@
- -
+
-
Clear search histories from all over calibre. Including the book list, e-book viewer, fetch news dialog, etc.
@@ -87,7 +99,7 @@
- -
+
-
Grouped Search Terms
diff --git a/src/calibre/gui2/preferences/tweaks.py b/src/calibre/gui2/preferences/tweaks.py
index 290fff37ba..43370642c5 100644
--- a/src/calibre/gui2/preferences/tweaks.py
+++ b/src/calibre/gui2/preferences/tweaks.py
@@ -341,9 +341,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
tweak = self.tweaks.data(idx, Qt.UserRole)
self.context_menu = QMenu(self)
self.context_menu.addAction(self.copy_icon,
- _('Copy to clipboard'),
- partial(self.copy_item_to_clipboard,
- val=tweak.name))
+ _('Copy to clipboard'),
+ partial(self.copy_item_to_clipboard,
+ val=u"%s (%s: %s)"%(tweak.name,
+ _('ID'),
+ tweak.var_names[0])))
self.context_menu.popup(self.mapToGlobal(point))
return True
diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py
index 72e39e5651..4d94e3dec7 100644
--- a/src/calibre/library/caches.py
+++ b/src/calibre/library/caches.py
@@ -119,6 +119,8 @@ class MetadataBackup(Thread): # {{{
# }}}
+pref_use_primary_find_in_search = False
+
### Global utility function for get_match here and in gui2/library.py
CONTAINS_MATCH = 0
EQUALS_MATCH = 1
@@ -151,7 +153,10 @@ def _match(query, value, matchkind):
elif matchkind == REGEXP_MATCH:
return re.search(query, t, re.I|re.UNICODE)
elif matchkind == CONTAINS_MATCH:
- return primary_find(query, t)[0] != -1
+ if pref_use_primary_find_in_search:
+ return primary_find(query, t)[0] != -1
+ else:
+ return query in t
except re.error:
pass
return False
@@ -613,6 +618,9 @@ class ResultCache(SearchQueryParser): # {{{
def get_matches(self, location, query, candidates=None,
allow_recursion=True):
+ global pref_use_primary_find_in_search
+ pref_use_primary_find_in_search = prefs['use_primary_find_in_search']
+
matches = set([])
if candidates is None:
candidates = self.universal_set()
@@ -639,8 +647,10 @@ class ResultCache(SearchQueryParser): # {{{
else:
invert = False
for loc in location:
- matches |= self.get_matches(loc, query,
+ m = self.get_matches(loc, query,
candidates=candidates, allow_recursion=False)
+ matches |= m
+ candidates -= m
if invert:
matches = self.universal_set() - matches
return matches
@@ -657,8 +667,10 @@ class ResultCache(SearchQueryParser): # {{{
if terms:
for l in terms:
try:
- matches |= self.get_matches(l, query,
+ m = self.get_matches(l, query,
candidates=candidates, allow_recursion=allow_recursion)
+ matches |= m
+ candidates -= m
except:
pass
return matches
diff --git a/src/calibre/utils/config_base.py b/src/calibre/utils/config_base.py
index ab22c6b30b..7a4e15753e 100644
--- a/src/calibre/utils/config_base.py
+++ b/src/calibre/utils/config_base.py
@@ -422,6 +422,10 @@ def _prefs():
'title:Red. Enter a list of search/lookup names '
'separated by commas. Only takes effect if you set the option '
'to limit search columns above.'))
+ c.add_opt('use_primary_find_in_search', default=True,
+ help=_('Characters typed in the search box will match their '
+ 'accented versions, using language rules. For example, in '
+ ' English, searching for e will match é and è.'))
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
return c