3

Everyone knows you can repeat the last I-search with C-s C-s, but that doesn't preserve all the parameters from the last search. As a concrete example, I often use symbol I-search (M-s _), and typing M-s _ C-s is a fair bit cumbersome when going through a lot of matches.

It would be nice if C-s C-s could see if the last I-search was a symbol search and reactivate that. Similar things can of course be said for other I-search states, like regex searches (though that isn't quite as cumbersome to do manually to begin with).

Is there a way to do this with the existing I-search implementation, or will I have to write it myself?

2
  • 1
    What version of emacs? In current upstrean, toggling symbol search, quitting the search and restarting it with C-s C-s brings back both the symbol and the option for further searching.
    – NickD
    Oct 12, 2022 at 3:36
  • @NickD: Would you look at that. I'm still using Emacs 26.1 on this computer, but on another computer with 27.1 you are indeed right that it does repeat the search as I wanted it to. That's great!
    – Dolda2000
    Oct 12, 2022 at 12:11

1 Answer 1

0

Use M-s . for symbol search, and M-p and M-n for retrieving previous search strings (or if it is the first search, suggested search strings).

M-s . runs the command isearch-forward-symbol-at-point (found in global-map), which is an interactive byte-compiled Lisp function in isearch.el.


When in minibuffer use M-p and M-n to retrieve previous search terms.

M-p runs the command isearch-ring-retreat (found in overriding-terminal-local-map), which is an interactive byte-compiled Lisp function in isearch.el.


M-n runs the command isearch-ring-advance (found in overriding-terminal-local-map), which is an interactive byte-compiled Lisp function in isearch.el.


You can use M-p and M-n almost always in the minibuffer to retrieve historical items. It works for simple search, as well as search and replace.

1
  • 1
    This doesn't seem to answer the question that was asked - about repeating the same type of search, rather than using the history of search values. Oct 12, 2022 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.