Any existing package that can do incremental search inside a function definition instead of the whole buffer?

Now the best I can do is to turn on semantic-mode along with semantic-stickyfunc-mode and carefully search within its scope.

  • 1
    Can you explain what you want more clearly? Do what to do the search from an elisp function, or do want to search interactively within the text of a function definition in some file? In the latter case, you could use narrowing to limit the search. Mar 13, 2017 at 7:39
  • 7
    C-x n d (or M-x narrow-to-defun) then search?
    – xuchunyang
    Mar 13, 2017 at 9:17

1 Answer 1


As @xuchunyang said in a comment to your question, you can first narrow the buffer to the function definition.

Or you can use library Isearch+, which lets you search just the active region, without narrowing.

Non-nil option isearchp-restrict-to-region-flag does this. You can use C-x n (command isearchp-toggle-region-restriction) during search to toggle this option value.

Also, deactivation of the active region when you search is controlled by option isearchp-deactivate-region-flag.

(NOTE: For search to be limited to the active region in Info, you must also use library Info+.)

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.