I have a buffer open in emacs. I want a function that will return t if the current buffer contains the string, otherwise it returns nil.
(defun buffer-contains-substring (string)
    ...
)
                This is careful to not change where you are, or damage any match data.
(defun buffer-contains-substring (string)
  (save-excursion
    (save-match-data
      (goto-char (point-min))
      (search-forward string nil t))))
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With