>> Yes, this is a harder problem. We have to remember meta-data for >> every search history element. There are several possibilities: >> >> 4. Adding meta-data by text-properties to the strings in >> ‘search-ring’ and ‘regexp-search-ring’ poses a problem of saving >> the values in the desktop and restoring in another session. > > This feels like the best solution. I looked at desktop.el, and it > doesn't save the properties, as you say. But it could be made to. Do you > think some external packages would get broken by this change? This seems to be the least radical change as concluded in https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00296.html The patch makes the search mode to be remembered in isearch as well as in query-replace.