2

Is there a way to perform incremental search that filters out all non-math environments (i.e., only searches within $...$, $$...$$, and if possible other relevant \begin{..}..\end{..} environments)?

Note: a similar question provided an answer without the incremental part.

| improve this question | | | | |
1

The following works.

(defun latex-isearch-in-math ()
  "Call `isearch-forward' with `isearch-filter-predicate' set to filter out matches outside LaTeX math environments."
  (interactive)
  (let ((isearch-filter-predicate
         (lambda (BEG END)
           (save-excursion (save-match-data (goto-char BEG) (texmathp)))))
        (case-fold-search nil))
    (funcall 'isearch-forward)))

Note: it is almost identical to this answer, except call-interactively must be replaced with funcall.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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